From 9be556d50d78e502eb2fc23ba779a14391a4a4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=9Al=C4=99zak?= <102536422+filipslezaklab@users.noreply.github.com> Date: Mon, 21 Aug 2023 13:59:55 +0200 Subject: [PATCH 1/2] style: add user modal (#313) --- web/src/i18n/en/index.ts | 5 +- web/src/i18n/i18n-types.ts | 16 +- web/src/i18n/pl/index.ts | 3 + .../users/UsersOverview/UsersOverview.tsx | 10 +- .../UserEditButton/UserEditButton.tsx | 12 +- .../modals/AddUserModal/AddUserModal.tsx | 43 ++-- .../AddUserForm}/AddUserForm.tsx | 86 ++++---- .../components/AddUserForm/style.scss | 44 ++++ .../EnrollmentTokenCard.tsx | 64 ++++++ .../components/EnrollmentTokenCard/style.scss | 33 +++ .../StartEnrollmentForm.tsx | 171 ++++++++++++++++ .../components/StartEnrollmentForm/style.scss | 10 + .../AddUserModal/hooks/useAddUserModal.tsx | 38 ++++ .../modals/AddUserModal/style.scss | 40 +--- .../StartEnrollmentModal.tsx | 29 --- .../components/StartEnrollmentForm.tsx | 191 ------------------ .../hooks/useEnrollmentModalStore.tsx | 31 --- web/src/shared/defguard-ui | 2 +- web/src/shared/hooks/store/useModalStore.ts | 5 - web/src/shared/types.ts | 2 - 20 files changed, 481 insertions(+), 354 deletions(-) rename web/src/pages/users/UsersOverview/modals/AddUserModal/{ => components/AddUserForm}/AddUserForm.tsx (76%) create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/components/AddUserForm/style.scss create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/components/EnrollmentTokenCard/EnrollmentTokenCard.tsx create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/components/EnrollmentTokenCard/style.scss create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/components/StartEnrollmentForm/StartEnrollmentForm.tsx create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/components/StartEnrollmentForm/style.scss create mode 100644 web/src/pages/users/UsersOverview/modals/AddUserModal/hooks/useAddUserModal.tsx delete mode 100644 web/src/pages/users/UsersOverview/modals/StartEnrollmentModal/StartEnrollmentModal.tsx delete mode 100644 web/src/pages/users/UsersOverview/modals/StartEnrollmentModal/components/StartEnrollmentForm.tsx delete mode 100644 web/src/pages/users/UsersOverview/modals/StartEnrollmentModal/hooks/useEnrollmentModalStore.tsx diff --git a/web/src/i18n/en/index.ts b/web/src/i18n/en/index.ts index 2453e17ba..5587ffe22 100644 --- a/web/src/i18n/en/index.ts +++ b/web/src/i18n/en/index.ts @@ -318,6 +318,9 @@ const en: BaseTranslation = { }, addUser: { title: 'Add new user', + messages: { + userAdded: 'User added', + }, form: { submit: 'Add user', fields: { @@ -346,7 +349,7 @@ const en: BaseTranslation = { label: 'Phone', }, enableEnrollment: { - label: 'Use remote enrollment', + label: 'Use enrollment process', }, }, }, diff --git a/web/src/i18n/i18n-types.ts b/web/src/i18n/i18n-types.ts index 3ac8aa4bc..2b7c310aa 100644 --- a/web/src/i18n/i18n-types.ts +++ b/web/src/i18n/i18n-types.ts @@ -657,6 +657,12 @@ type RootTranslation = { * A​d​d​ ​n​e​w​ ​u​s​e​r */ title: string + messages: { + /** + * U​s​e​r​ ​a​d​d​e​d + */ + userAdded: string + } form: { /** * A​d​d​ ​u​s​e​r @@ -725,7 +731,7 @@ type RootTranslation = { } enableEnrollment: { /** - * U​s​e​ ​r​e​m​o​t​e​ ​e​n​r​o​l​l​m​e​n​t + * U​s​e​ ​e​n​r​o​l​l​m​e​n​t​ ​p​r​o​c​e​s​s */ label: string } @@ -3926,6 +3932,12 @@ export type TranslationFunctions = { * Add new user */ title: () => LocalizedString + messages: { + /** + * User added + */ + userAdded: () => LocalizedString + } form: { /** * Add user @@ -3994,7 +4006,7 @@ export type TranslationFunctions = { } enableEnrollment: { /** - * Use remote enrollment + * Use enrollment process */ label: () => LocalizedString } diff --git a/web/src/i18n/pl/index.ts b/web/src/i18n/pl/index.ts index 700a527a7..92a937c6b 100644 --- a/web/src/i18n/pl/index.ts +++ b/web/src/i18n/pl/index.ts @@ -318,6 +318,9 @@ const pl: Translation = { }, }, addUser: { + messages: { + userAdded: 'Stworzono użytkownika', + }, title: 'Dodaj nowego użytkownika', form: { submit: 'Dodaj użytkownika', diff --git a/web/src/pages/users/UsersOverview/UsersOverview.tsx b/web/src/pages/users/UsersOverview/UsersOverview.tsx index f1e185b60..d89ad55f4 100644 --- a/web/src/pages/users/UsersOverview/UsersOverview.tsx +++ b/web/src/pages/users/UsersOverview/UsersOverview.tsx @@ -22,13 +22,12 @@ import { SelectSelectedValue, SelectSizeVariant, } from '../../../shared/defguard-ui/components/Layout/Select/types'; -import { useModalStore } from '../../../shared/hooks/store/useModalStore'; import useApi from '../../../shared/hooks/useApi'; import { QueryKeys } from '../../../shared/queries'; import { User } from '../../../shared/types'; import { UsersList } from './components/UsersList/UsersList'; -import AddUserModal from './modals/AddUserModal/AddUserModal'; -import { StartEnrollmentModal } from './modals/StartEnrollmentModal/StartEnrollmentModal'; +import { AddUserModal } from './modals/AddUserModal/AddUserModal'; +import { useAddUserModal } from './modals/AddUserModal/hooks/useAddUserModal'; enum FilterOptions { ALL = 'all', @@ -83,7 +82,7 @@ export const UsersOverview = () => { const [usersSearchValue, setUsersSearchValue] = useState(''); - const setUserAddModalState = useModalStore((state) => state.setAddUserModal); + const openAddUserModal = useAddUserModal((state) => state.open); const filteredUsers = useMemo(() => { if (!users || (users && !users.length)) { @@ -161,7 +160,7 @@ export const UsersOverview = () => { )}