diff --git a/client/src/components/UserCreate.tsx b/client/src/components/UserCreate.tsx index 996b9df..a1cd8f8 100644 --- a/client/src/components/UserCreate.tsx +++ b/client/src/components/UserCreate.tsx @@ -8,12 +8,15 @@ import { UploadFile, GetProp, UploadProps, + message, + Spin, } from 'antd'; import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useUserSelector } from '@/store/userStore'; import { UserUpdate } from '@/types/user'; import { UserService } from '@/services/userService'; +import { LoadingOutlined } from '@ant-design/icons'; const { Option } = Select; @@ -36,6 +39,7 @@ export default function UserCreate({ closeDrawer }: UserCreateProps) { const { t } = useTranslation(); const [previewOpen, setPreviewOpen] = useState(false); const [previewImage, setPreviewImage] = useState(''); + const [loading, setLoading] = useState(false); const [fileList, setFileList] = useState([]); @@ -52,9 +56,11 @@ export default function UserCreate({ closeDrawer }: UserCreateProps) { setFileList(newFileList); const onFinish = async (values: UserUpdate) => { - console.log(values); + setLoading(true); await UserService.createUser(values); closeDrawer(); + setLoading(false); + message.info(t('createdAccountMessage'), 4); }; const customUploadButton = ( @@ -231,12 +237,21 @@ export default function UserCreate({ closeDrawer }: UserCreateProps) { block style={{ color: '#000' }} > - save{' '} - {t('addAccount')} + {loading ? ( + <> + } size="small">{' '} + {t('saving')} + + ) : ( + <> + save{' '} + {t('addAccount')} + + )} diff --git a/client/src/config/i18n.ts b/client/src/config/i18n.ts index db55a45..bc44352 100644 --- a/client/src/config/i18n.ts +++ b/client/src/config/i18n.ts @@ -47,6 +47,8 @@ i18n VIEWER: 'Viewer', nameLogin: 'Name, login', createdAt: 'Created', + saving: 'Saving...', + createdAccountMessage: 'User successfully created!', }, }, ru: { @@ -86,6 +88,8 @@ i18n VIEWER: 'Наблюдатель', nameLogin: 'Имя, Логин', createdAt: 'Создано', + saving: 'Сохранение...', + createdAccountMessage: 'Пользователь успешно создан!' }, }, },