fix(trading): validate whitespace team names, show empty in list (#5727)

Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
This commit is contained in:
Matthew Russell 2024-02-12 08:23:12 -05:00 committed by GitHub
parent 0d850bd8b9
commit c7dd5e846a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View File

@ -46,7 +46,7 @@ const prepareTransaction = (
createReferralSet: {
isTeam: true,
team: {
name: fields.name,
name: fields.name.trim(),
teamUrl: fields.url,
avatarUrl: fields.avatarUrl,
closed: fields.private,
@ -62,7 +62,7 @@ const prepareTransaction = (
id: fields.id,
isTeam: true,
team: {
name: fields.name,
name: fields.name.trim(),
teamUrl: fields.url,
avatarUrl: fields.avatarUrl,
closed: fields.private,
@ -116,7 +116,17 @@ export const TeamForm = ({
<input type="hidden" {...register('id')} />
<TradingFormGroup label={t('Team name')} labelFor="name">
<TradingInput
{...register('name', { required: t('Required') })}
{...register('name', {
required: t('Required'),
validate: {
notEmpty: (value) => {
if (/^\s*$/.test(value)) {
return t('Team name cannot be empty');
}
return true;
},
},
})}
data-testid="team-name-input"
/>
{errors.name?.message && (

View File

@ -56,7 +56,10 @@ export const CompetitionsLeaderboard = ({
className="hover:underline"
to={Links.COMPETITIONS_TEAM(td.teamId)}
>
{td.name}
{
// Its possible for a tx to be submitted with an empty space as team name
td.name.trim() !== '' ? td.name : t('[empty]')
}
</Link>
),
earned: num(td.totalQuantumRewards),

View File

@ -90,6 +90,7 @@
"Earned by me": "Earned by me",
"Eligible teams": "Eligible teams",
"Enactment date reached and usual auction exit checks pass": "Enactment date reached and usual auction exit checks pass",
"[empty]": "[empty]",
"Ends in": "Ends in",
"Entity scope": "Entity scope",
"{{entity}} scope": "{{entity}} scope",
@ -317,6 +318,7 @@
"Target stake": "Target stake",
"Team": "Team",
"Team name": "Team name",
"Team name cannot be empty": "Team name cannot be empty",
"Team creation transaction successful": "Team creation transaction successful",
"Team joined": "Team joined",
"Team switch successful. You will switch team at the end of the epoch.": "Team switch successful. You will switch team at the end of the epoch.",