diff --git a/src/contexts/UserContext/index.tsx b/src/contexts/UserContext/index.tsx index 6bf0949..d03c748 100644 --- a/src/contexts/UserContext/index.tsx +++ b/src/contexts/UserContext/index.tsx @@ -52,8 +52,6 @@ const UserContextProvider = ({ children }: Props) => { const handleLogin = async (props: { email: string; code: string }) => { const response = await AuthService.login(props); - console.log({ response }); - setUser(response.data); StorageService.setUser(response.data); StorageService.setAccessToken(response.headers.token || ''); diff --git a/src/pages/Settings/ChangePassword/index.tsx b/src/pages/Settings/ChangePassword/index.tsx deleted file mode 100644 index 0021c67..0000000 --- a/src/pages/Settings/ChangePassword/index.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import Icon from '@/components/Base/Icon'; -import Loader from '@/components/Base/Loader'; -import { UserContext } from '@/contexts/UserContext'; -import { IUser } from '@/types'; -import { Button, Center, FormControl, FormLabel, Input, Text, VStack } from '@chakra-ui/react'; -import React, { useContext, useState } from 'react'; -import { useForm } from 'react-hook-form'; -import { yupResolver } from '@hookform/resolvers/yup'; -import * as yup from 'yup'; -import { useTranslation } from 'react-i18next'; - -const ChangePassword = () => { - const { t } = useTranslation(); - const { handleUpdateUser } = useContext(UserContext); - const [isLoading, setIsLoading] = useState(false); - - const schema = yup - .object({ - currentPassword: yup.string().required('This field is required'), - password: yup.string().required('This field is required'), - confirmPassword: yup - .string() - .required('This field is required') - .oneOf([yup.ref('password')], 'Password not equals'), - }) - .required(); - - const { - register, - handleSubmit, - formState: { errors }, - } = useForm({ resolver: yupResolver(schema) }); - - const handleSubmitForm = async (user: Partial) => { - setIsLoading(true); - await handleUpdateUser({ password: user.password, currentPassword: user.currentPassword } as any); - setIsLoading(false); - }; - - return ( - <> - {isLoading ? ( -
- -
- ) : ( - - - {t('settings.tabs.change-password.title')} - - - {t('settings.tabs.change-password.description')} - - -
- - {t('settings.tabs.change-password.current-password')} - - - {errors.currentPassword?.message} - - - - - {t('settings.tabs.change-password.new-password')} - - - {errors.password?.message} - - - - - {t('settings.tabs.change-password.confirm-password')} - - - {errors.confirmPassword?.message} - - - - -
-
- )} - - ); -}; - -export default ChangePassword; diff --git a/src/pages/Settings/Users/Form/index.tsx b/src/pages/Settings/Users/Form/index.tsx index 4494c9d..7f12cea 100644 --- a/src/pages/Settings/Users/Form/index.tsx +++ b/src/pages/Settings/Users/Form/index.tsx @@ -76,28 +76,6 @@ const UserForm: React.FC = ({ defaultValues, handleSubmitForm, handleClos )} /> - {defaultValues && !('id' in defaultValues) && ( - <> - - {t('settings.tabs.users.form.password')} - - ( - - )} - /> - - )} - {t('settings.tabs.users.form.role')} diff --git a/src/pages/Settings/index.tsx b/src/pages/Settings/index.tsx index 4fde405..d4450e3 100644 --- a/src/pages/Settings/index.tsx +++ b/src/pages/Settings/index.tsx @@ -22,11 +22,6 @@ const SettingsPage: React.FC = () => { icon: 'user-circle', component: , }, - { - label: t('settings.tabs.change-password.title'), - icon: 'lock', - component: , - }, ...(user?.role === 'admin' ? [ { diff --git a/src/types/index.ts b/src/types/index.ts index 14d8b26..93a4dea 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -41,7 +41,6 @@ export interface IUser { region_id?: string; region?: IRegion; district?: string; - password: string; } export interface IGuide {