From d841d0e69c2e7dbe1475c166065f1ed25272c232 Mon Sep 17 00:00:00 2001 From: Felipe <84182706+felipe-rod123@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:37:25 -0300 Subject: [PATCH] fix review --- .../admin/users/UsersTable/UsersTable.tsx | 83 +++++++++---------- .../admin/users/UsersTable/UsersTableRow.tsx | 11 +-- .../admin/users/hooks/useFilterActiveUsers.ts | 5 +- .../users/hooks/useFilterPendingUsers.ts | 5 +- .../admin/users/hooks/useFilterUsersByRole.ts | 5 +- .../rocketchat-i18n/i18n/en.i18n.json | 4 + 6 files changed, 55 insertions(+), 58 deletions(-) diff --git a/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx b/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx index 7e24e60317eb..2dcc0b941073 100644 --- a/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx +++ b/apps/meteor/client/views/admin/users/UsersTable/UsersTable.tsx @@ -86,15 +86,21 @@ const UsersTable = ({ reload, tab, onReload }: UsersTableProps): ReactElement | const headers = useMemo( () => [ + + {t('Name')} + , mediaQuery && ( - - {t('Name')} + + {t('Username')} ), - - - {t('Username')} - , mediaQuery && ( ), tab === 'all' && ( - + {t('Registration_status')} ), @@ -132,7 +131,7 @@ const UsersTable = ({ reload, tab, onReload }: UsersTableProps): ReactElement | ), tab === 'pending' && ( - + {t('Pending_action')} ), @@ -152,50 +151,44 @@ const UsersTable = ({ reload, tab, onReload }: UsersTableProps): ReactElement | )} - {/* TODO: finish error state -> improve tab verification and add translations */} - {!isLoading && !isSuccess && tab !== 'all' && tab !== 'active' && ( - - {headers} - + + {headers} + + {!isLoading && !isSuccess && tab !== 'all' && tab !== 'active' && ( - No deactivated users - Deactivated users appear here + {tab === 'pending' ? t('No_pending_users') : t('No_deactivated_users')} + {tab === 'pending' ? t('Users_who_are_pending') : t('Deactivated_users_appear_here')} - - - )} + )} - {isSuccess && !!data && !!filteredUsers && data.count > 0 && ( - <> - - {headers} - - {/* TODO: fix user type */} + {isSuccess && !!data && !!filteredUsers && data.count > 0 && ( + <> {filteredUsers.map((user) => ( ))} - - - - - )} + + )} + + + + {isSuccess && data?.count === 0 && } {isError && ( diff --git a/apps/meteor/client/views/admin/users/UsersTable/UsersTableRow.tsx b/apps/meteor/client/views/admin/users/UsersTable/UsersTableRow.tsx index 0e3733105cb2..3a3c36a07971 100644 --- a/apps/meteor/client/views/admin/users/UsersTable/UsersTableRow.tsx +++ b/apps/meteor/client/views/admin/users/UsersTable/UsersTableRow.tsx @@ -13,7 +13,7 @@ import UserAvatar from '../../../../components/avatar/UserAvatar'; import ActionsMenu from './ActionsMenu'; type UsersTableRowProps = { - user: Pick; + user: Pick; onClick: (id: IUser['_id'], e: React.MouseEvent | React.KeyboardEvent) => void; mediaQuery: boolean; refetchUsers: ReturnType['refetch']; @@ -92,15 +92,6 @@ const UsersTableRow = ({ user, onClick, mediaQuery, refetchUsers, onReload, tab > {active ? t('User_first_log_in') : t('Activation')} - {/* {active ? ( - - ) : ( - - )} */} )} diff --git a/apps/meteor/client/views/admin/users/hooks/useFilterActiveUsers.ts b/apps/meteor/client/views/admin/users/hooks/useFilterActiveUsers.ts index ab42e925fa36..762042638353 100644 --- a/apps/meteor/client/views/admin/users/hooks/useFilterActiveUsers.ts +++ b/apps/meteor/client/views/admin/users/hooks/useFilterActiveUsers.ts @@ -1,6 +1,9 @@ import type { IUser } from '@rocket.chat/core-typings'; -export const useFilterActiveUsers = (users: Partial[] | undefined, tab: string) => { +export const useFilterActiveUsers = ( + users: Pick[] | undefined, + tab: string, +) => { if (!users || tab !== 'active') return []; return users.filter((currentUser) => currentUser.active); diff --git a/apps/meteor/client/views/admin/users/hooks/useFilterPendingUsers.ts b/apps/meteor/client/views/admin/users/hooks/useFilterPendingUsers.ts index 54c5051bb7d6..4cab19242463 100644 --- a/apps/meteor/client/views/admin/users/hooks/useFilterPendingUsers.ts +++ b/apps/meteor/client/views/admin/users/hooks/useFilterPendingUsers.ts @@ -1,6 +1,9 @@ import type { IUser } from '@rocket.chat/core-typings'; -export const useFilterPendingUsers = (users: Partial[] | undefined, tab: string) => { +export const useFilterPendingUsers = ( + users: Pick[] | undefined, + tab: string, +) => { if (!users || tab !== 'pending') return []; return users.filter((currentUser) => currentUser.active === false || !currentUser.lastLogin); diff --git a/apps/meteor/client/views/admin/users/hooks/useFilterUsersByRole.ts b/apps/meteor/client/views/admin/users/hooks/useFilterUsersByRole.ts index 926fce0e0c70..41a2509b74d3 100644 --- a/apps/meteor/client/views/admin/users/hooks/useFilterUsersByRole.ts +++ b/apps/meteor/client/views/admin/users/hooks/useFilterUsersByRole.ts @@ -1,6 +1,9 @@ import type { IUser } from '@rocket.chat/core-typings'; -export const useFilterUsersByRole = (users: Partial[], selectedRoles: string[]) => { +export const useFilterUsersByRole = ( + users: Pick[], + selectedRoles: string[], +) => { if (!users.length || !selectedRoles.length || selectedRoles.includes('all')) return users; return users.filter((currentUser) => { diff --git a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json index c7b4a0fa096e..9fc4b2052ee7 100644 --- a/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json @@ -6058,5 +6058,9 @@ "User_first_log_in": "User first log in", "Resend_welcome_email": "Resend welcome email", "Activation": "Activation", + "No_pending_users": "No pending users", + "No_deactivated_users": "No deactivated users", + "Users_who_are_pending": "Users who are pending activation or have been manually created but haven't logged in yet appear here.", + "Deactivated_users_appear_here": "Deactivated users appear here.", "Theme_Appearence": "Theme Appearence" }