change category ids to category id
This commit is contained in:
@@ -36,7 +36,7 @@ const CreateFood: FC = () => {
|
||||
title: '',
|
||||
desc: '',
|
||||
content: [],
|
||||
categoryIds: [],
|
||||
categoryId: '',
|
||||
price: 0,
|
||||
discount: 0,
|
||||
points: 0,
|
||||
@@ -61,7 +61,7 @@ const CreateFood: FC = () => {
|
||||
validationSchema: Yup.object().shape({
|
||||
title: Yup.string().required('نام غذا الزامی است'),
|
||||
desc: Yup.string().required('توضیحات غذا الزامی است'),
|
||||
categoryIds: Yup.array().min(1, 'حداقل یک دستهبندی الزامی است'),
|
||||
categoryId: Yup.string().required('دستهبندی الزامی است'),
|
||||
price: Yup.number().required('قیمت الزامی است').min(0, 'قیمت باید مثبت باشد'),
|
||||
prepareTime: Yup.number().required('زمان آمادهسازی الزامی است').min(0, 'زمان آمادهسازی باید مثبت باشد'),
|
||||
stock: Yup.number().required('موجودی الزامی است').min(0, 'موجودی باید مثبت باشد'),
|
||||
@@ -143,13 +143,13 @@ const CreateFood: FC = () => {
|
||||
items={categories}
|
||||
label='دسته بندی'
|
||||
placeholder='انتخاب کنید'
|
||||
name='categoryIds'
|
||||
value={formik.values.categoryIds[0] || ''}
|
||||
name='categoryId'
|
||||
value={formik.values.categoryId}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value
|
||||
formik.setFieldValue('categoryIds', value ? [value] : [])
|
||||
formik.setFieldValue('categoryId', value)
|
||||
}}
|
||||
error_text={formik.touched.categoryIds && formik.errors.categoryIds ? String(formik.errors.categoryIds) : ''}
|
||||
error_text={formik.touched.categoryId && formik.errors.categoryId ? String(formik.errors.categoryId) : ''}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user