diff --git a/src/pages/settings/GeneralSettings.tsx b/src/pages/settings/GeneralSettings.tsx index 2beb2e5..1392deb 100644 --- a/src/pages/settings/GeneralSettings.tsx +++ b/src/pages/settings/GeneralSettings.tsx @@ -17,11 +17,15 @@ import * as yup from 'yup' import { toast } from 'react-toastify' import { extractErrorMessage } from '@/config/func' import ServiceAreaPicker from './components/ServiceAreaPicker' +import PhonesSection from './components/PhonesSection' const validationSchema = yup.object({ name: yup.string().required('نام رستوران الزامی است'), menuColor: yup.string().required('رنگ منو الزامی است'), - phone: yup.string().required('شماره تماس الزامی است'), + phones: yup + .array() + .min(1, 'حداقل یک شماره تماس الزامی است') + .of(yup.string().required('شماره تماس الزامی است')), instagram: yup.string().url('لینک اینستاگرام معتبر نیست').nullable(), address: yup.string().required('آدرس الزامی است'), latitude: yup.number().required('انتخاب موقعیت روی نقشه الزامی است'), @@ -40,7 +44,7 @@ const GeneralSettings: FC = () => { initialValues: { name: '', menuColor: '#000000', - phone: '', + phones: [''], instagram: '', address: '', latitude: 0, @@ -93,7 +97,12 @@ const GeneralSettings: FC = () => { formik.setValues({ name: restaurantData.name || '', menuColor: restaurantData.menuColor || '#000000', - phone: restaurantData.phone || '', + phones: + restaurantData.phones?.length + ? restaurantData.phones + : restaurantData.phone + ? [restaurantData.phone] + : [''], instagram: restaurantData.instagram || '', address: restaurantData.address || '', latitude: restaurantData.latitude || 0, @@ -155,16 +164,11 @@ const GeneralSettings: FC = () => { } -