diff --git a/src/langs/fa.json b/src/langs/fa.json index 089fa42..ff1909d 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -786,7 +786,10 @@ "confrim_email": "تایید ایمیل", "confrim": "تایید صورتحساب ", "link_email": "یک لینک برای تایید ایمیل برای شما ارسال شد.", - "email_not_verified": "ایمیل تایید نشده" + "email_not_verified": "ایمیل تایید نشده", + "resend_email": "ارسال مجدد تایید", + "first_name": "نام", + "last_name": "نام خانوادگی" }, "email": "ایمیل", "customer": { diff --git a/src/pages/profile/Profile.tsx b/src/pages/profile/Profile.tsx index 58ac5a9..16fece3 100644 --- a/src/pages/profile/Profile.tsx +++ b/src/pages/profile/Profile.tsx @@ -1,70 +1,31 @@ -import { FC, useCallback, useEffect, useState } from 'react' +import { FC, useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' import AvatarImage from '../../assets/images/avatar_image.png' import Button from '../../components/Button' import { DocumentUpload } from 'iconsax-react' -import Input from '../../components/Input' -import DatePickerComponent from '../../components/DatePicker' import { useGetProfile, useUpdateProfile } from './hooks/useProfileData' import Username from './components/Username' import { useDropzone } from 'react-dropzone' -import { toast } from '../../components/Toast'; +import { toast } from '../../components/Toast' import { ErrorType } from '../../helpers/types' import { UpdateProfileType } from './types/ProfileTypes' import PageLoading from '../../components/PageLoading' -import { useFormik } from 'formik' -import * as Yup from 'yup' import Email from './components/Email' import Phone from './components/Phone' -import { useGetProvines } from '../customer/hooks/useCustomerData' +import FirstName from './components/FirstName' +import LastName from './components/LastName' +import BirthDate from './components/BirthDate' +import NationalCode from './components/NationalCode' import { useSingleUpload } from '../service/hooks/useServiceData' const Profile: FC = () => { const { t } = useTranslation('global') const [file, setFile] = useState() - const getProvines = useGetProvines() const getProfile = useGetProfile() const singleUpload = useSingleUpload() const updateProfile = useUpdateProfile() - const formik = useFormik({ - initialValues: { - cityId: '', - userAddress: '', - postalCode: '', - }, - validationSchema: Yup.object({ - cityId: Yup.string().required(t('errors.required')), - userAddress: Yup.string().required(t('errors.required')), - postalCode: Yup.string().required(t('errors.required')), - }), - onSubmit: (values) => { - updateProfile.mutate(values, { - onSuccess: () => { - toast(t('success'), 'success') - }, - onError: (error: ErrorType) => { - toast(error.response?.data?.error?.message[0], 'error') - } - }) - } - }) - - useEffect(() => { - - if (getProfile.data) { - formik.setValues({ - cityId: getProfile.data.data.user.city?.id || '', - userAddress: getProfile.data.data.user.userAddress || '', - postalCode: getProfile.data.data.user.postalCode || '', - }) - } - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [getProfile.data]) - - const onDrop = useCallback((acceptedFiles: File[]) => { if (acceptedFiles.length > 0) { @@ -83,12 +44,12 @@ const Profile: FC = () => { toast(t('profile.image_uploaded_successfully'), 'success') }, onError: (error: ErrorType) => { - toast(error.response?.data?.error?.message[0], 'error') + toast(error.response?.data?.error?.message?.[0], 'error') } }) }, onError: (error: ErrorType) => { - toast(error.response?.data?.error?.message[0], 'error') + toast(error.response?.data?.error?.message?.[0], 'error') } }) } else { @@ -107,7 +68,7 @@ const Profile: FC = () => { { - getProfile.isPending || getProvines.isPending ? + getProfile.isPending ? :
@@ -175,87 +136,15 @@ const Profile: FC = () => {
- { }} - placeholder='' - defaulValue={getProfile.data?.data?.user?.birthDate} - /> - + +
- +
+
- {/*
-
-
- {t('profile.address')} -
-
- {t('profile.address_live')} -
-
-
-
- ({ label: item.name, value: item.id })) : []} - placeholder={t('select')} - {...formik.getFieldProps('cityId')} - error_text={formik.touched.cityId && formik.errors.cityId ? formik.errors.cityId : ''} - /> -
- -
- -
-
-