fix bug
This commit is contained in:
@@ -7,7 +7,6 @@ import Error from '../../components/Error';
|
|||||||
import PaginationUi from '../../components/PaginationUi';
|
import PaginationUi from '../../components/PaginationUi';
|
||||||
import StatusWithText from '../../components/StatusWithText';
|
import StatusWithText from '../../components/StatusWithText';
|
||||||
import Td from '../../components/Td';
|
import Td from '../../components/Td';
|
||||||
import TrashWithConfrim from '../../components/TrashWithConfrim';
|
|
||||||
import PageTitle from '../../components/PageTitle';
|
import PageTitle from '../../components/PageTitle';
|
||||||
import { Edit } from 'iconsax-react';
|
import { Edit } from 'iconsax-react';
|
||||||
import Button from '@/components/Button';
|
import Button from '@/components/Button';
|
||||||
@@ -144,12 +143,12 @@ const List: FC = () => {
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<TrashWithConfrim
|
{/* <TrashWithConfrim
|
||||||
onDelete={() => {
|
onDelete={() => {
|
||||||
// TODO: Implement delete product
|
// TODO: Implement delete product
|
||||||
console.log('Delete product:', product._id);
|
console.log('Delete product:', product._id);
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ const Step1Form: FC<Step1FormProps> = ({ onSubmit, brands, categories, loading,
|
|||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<Select
|
<Select
|
||||||
label="دستهبندی"
|
label="دستهبندی"
|
||||||
|
placeholder="انتخاب دستهبندی"
|
||||||
value={formData.category}
|
value={formData.category}
|
||||||
onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))}
|
onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))}
|
||||||
items={categoryItems}
|
items={categoryItems}
|
||||||
@@ -88,6 +89,7 @@ const Step1Form: FC<Step1FormProps> = ({ onSubmit, brands, categories, loading,
|
|||||||
|
|
||||||
<Select
|
<Select
|
||||||
label="برند"
|
label="برند"
|
||||||
|
placeholder="انتخاب برند"
|
||||||
value={formData.brand}
|
value={formData.brand}
|
||||||
onChange={(e) => setFormData(prev => ({ ...prev, brand: e.target.value }))}
|
onChange={(e) => setFormData(prev => ({ ...prev, brand: e.target.value }))}
|
||||||
items={brands.map(brand => ({ value: brand._id, label: brand.title_fa }))}
|
items={brands.map(brand => ({ value: brand._id, label: brand.title_fa }))}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import UploadBox from '../../components/UploadBox'
|
|||||||
import { TickCircle } from 'iconsax-react'
|
import { TickCircle } from 'iconsax-react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { extractErrorMessage } from '@/helpers/utils'
|
import { extractErrorMessage } from '@/helpers/utils'
|
||||||
|
import { useSingleUpload } from '../category'
|
||||||
|
|
||||||
// Validation schema برای UpdateShopType
|
// Validation schema برای UpdateShopType
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
@@ -18,13 +19,12 @@ const validationSchema = Yup.object().shape({
|
|||||||
shopDescription: Yup.string().required('توضیحات شاپ الزامی است'),
|
shopDescription: Yup.string().required('توضیحات شاپ الزامی است'),
|
||||||
telephoneNumber: Yup.string().required('شماره تلفن الزامی است'),
|
telephoneNumber: Yup.string().required('شماره تلفن الزامی است'),
|
||||||
shopPostalCode: Yup.string().required('کد پستی الزامی است'),
|
shopPostalCode: Yup.string().required('کد پستی الزامی است'),
|
||||||
logo: Yup.string().required('لوگو الزامی است')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const Shop: FC = () => {
|
const Shop: FC = () => {
|
||||||
const { data: shopDetail, isLoading: shopDetailLoading, error: shopDetailError } = useGetShop()
|
const { data: shopDetail, isLoading: shopDetailLoading, error: shopDetailError } = useGetShop()
|
||||||
const updateShopMutation = useUpdateShop()
|
const updateShopMutation = useUpdateShop()
|
||||||
|
const uploadSingle = useSingleUpload()
|
||||||
const [logoFile, setLogoFile] = useState<File[]>([])
|
const [logoFile, setLogoFile] = useState<File[]>([])
|
||||||
|
|
||||||
const formik = useFormik<UpdateShopType>({
|
const formik = useFormik<UpdateShopType>({
|
||||||
@@ -33,21 +33,20 @@ const Shop: FC = () => {
|
|||||||
shopDescription: '',
|
shopDescription: '',
|
||||||
telephoneNumber: '',
|
telephoneNumber: '',
|
||||||
shopPostalCode: '',
|
shopPostalCode: '',
|
||||||
logo: ''
|
logo: undefined
|
||||||
},
|
},
|
||||||
validationSchema,
|
validationSchema,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
const logoUrl = values.logo
|
|
||||||
|
|
||||||
if (logoFile.length > 0) {
|
if (logoFile.length > 0) {
|
||||||
// TODO: اینجا باید API آپلود فایل اضافه شود
|
const logoResponse = await uploadSingle.mutateAsync(logoFile[0])
|
||||||
// const logoResponse = await uploadSingle.mutateAsync(logoFile[0])
|
values.logo = logoResponse.results?.url?.url || undefined
|
||||||
// logoUrl = logoResponse.results?.url?.url || values.logo
|
} else {
|
||||||
|
values.logo = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...values,
|
...values,
|
||||||
logo: logoUrl
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateShopMutation.mutate(submitData, {
|
updateShopMutation.mutate(submitData, {
|
||||||
@@ -61,6 +60,7 @@ const Shop: FC = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shopDetail?.results?.shop) {
|
if (shopDetail?.results?.shop) {
|
||||||
const shop = shopDetail.results.shop
|
const shop = shopDetail.results.shop
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ export interface UpdateShopType {
|
|||||||
shopDescription: string;
|
shopDescription: string;
|
||||||
telephoneNumber: string;
|
telephoneNumber: string;
|
||||||
shopPostalCode: string;
|
shopPostalCode: string;
|
||||||
logo: string;
|
logo?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BannerItem {
|
export interface BannerItem {
|
||||||
|
|||||||
Reference in New Issue
Block a user