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: { createReferralSet: {
isTeam: true, isTeam: true,
team: { team: {
name: fields.name, name: fields.name.trim(),
teamUrl: fields.url, teamUrl: fields.url,
avatarUrl: fields.avatarUrl, avatarUrl: fields.avatarUrl,
closed: fields.private, closed: fields.private,
@ -62,7 +62,7 @@ const prepareTransaction = (
id: fields.id, id: fields.id,
isTeam: true, isTeam: true,
team: { team: {
name: fields.name, name: fields.name.trim(),
teamUrl: fields.url, teamUrl: fields.url,
avatarUrl: fields.avatarUrl, avatarUrl: fields.avatarUrl,
closed: fields.private, closed: fields.private,
@ -116,7 +116,17 @@ export const TeamForm = ({
<input type="hidden" {...register('id')} /> <input type="hidden" {...register('id')} />
<TradingFormGroup label={t('Team name')} labelFor="name"> <TradingFormGroup label={t('Team name')} labelFor="name">
<TradingInput <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" data-testid="team-name-input"
/> />
{errors.name?.message && ( {errors.name?.message && (

View File

@ -56,7 +56,10 @@ export const CompetitionsLeaderboard = ({
className="hover:underline" className="hover:underline"
to={Links.COMPETITIONS_TEAM(td.teamId)} 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> </Link>
), ),
earned: num(td.totalQuantumRewards), earned: num(td.totalQuantumRewards),

View File

@ -90,6 +90,7 @@
"Earned by me": "Earned by me", "Earned by me": "Earned by me",
"Eligible teams": "Eligible teams", "Eligible teams": "Eligible teams",
"Enactment date reached and usual auction exit checks pass": "Enactment date reached and usual auction exit checks pass", "Enactment date reached and usual auction exit checks pass": "Enactment date reached and usual auction exit checks pass",
"[empty]": "[empty]",
"Ends in": "Ends in", "Ends in": "Ends in",
"Entity scope": "Entity scope", "Entity scope": "Entity scope",
"{{entity}} scope": "{{entity}} scope", "{{entity}} scope": "{{entity}} scope",
@ -317,6 +318,7 @@
"Target stake": "Target stake", "Target stake": "Target stake",
"Team": "Team", "Team": "Team",
"Team name": "Team name", "Team name": "Team name",
"Team name cannot be empty": "Team name cannot be empty",
"Team creation transaction successful": "Team creation transaction successful", "Team creation transaction successful": "Team creation transaction successful",
"Team joined": "Team joined", "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.", "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.",