Skip to content

Commit

Permalink
feat: add the user.type column (#383)
Browse files Browse the repository at this point in the history
Co-authored-by: Antoine D <[email protected]>
  • Loading branch information
Suboyyy and Antoine D authored Sep 19, 2024
1 parent ddb798f commit 28e63eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/app/(dashboard)/admin/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const columnTitles = {
scannedLabel: 'Scanné',
permissionsLabel: 'Permissions',
teamName: 'Équipe',
status: 'Rôle',
tournamentName: 'Tournoi',
place: 'Place',
};
Expand Down Expand Up @@ -79,6 +80,7 @@ const Users = () => {
lockedLabel: true,
paidLabel: true,
scannedLabel: true,
status: true,
permissionsLabel: true,
teamName: true,
tournamentName: true,
Expand Down
18 changes: 17 additions & 1 deletion src/modules/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,31 @@ const initialState: UsersAction = {
};

const format = (users: Array<UserWithTeamAndMessageAndTournamentInfo>) => {
function userType(type: string) {
switch (type) {
case UserType.player:
return 'Joueur';
case UserType.coach:
return 'Coach';
case UserType.spectator:
return 'Spectateur';
case UserType.attendant:
return 'Accompagnateur';
default:
return type;
}
}

return users.map((user) => ({
...user,
fullname: `${user.firstname} ${user.lastname}`,
tournamentName: user.team ? user.team.tournament.name : '',
teamName: user.team ? user.team.name : user.type === UserType.spectator ? '(spectateur)' : '',
teamName: user.team ? user.team.name : '',
lockedLabel: user.team && user.team.lockedAt ? '✔' : '✖',
paidLabel: user.hasPaid ? '✔' : '✖',
scannedLabel: user.scannedAt ? '✔' : '✖',
permissionsLabel: user.permissions.join(', ') || '',
status: user.type ? userType(user.type) : '',
}));
};

Expand Down

0 comments on commit 28e63eb

Please sign in to comment.