diff --git a/src/pages/products/List.tsx b/src/pages/products/List.tsx index f65b83e..1088f41 100644 --- a/src/pages/products/List.tsx +++ b/src/pages/products/List.tsx @@ -7,7 +7,6 @@ import Error from '../../components/Error'; import PaginationUi from '../../components/PaginationUi'; import StatusWithText from '../../components/StatusWithText'; import Td from '../../components/Td'; -import TrashWithConfrim from '../../components/TrashWithConfrim'; import PageTitle from '../../components/PageTitle'; import { Edit } from 'iconsax-react'; import Button from '@/components/Button'; @@ -144,12 +143,12 @@ const List: FC = () => { )} - { // TODO: Implement delete product console.log('Delete product:', product._id); }} - /> + /> */} diff --git a/src/pages/products/components/Step1Form.tsx b/src/pages/products/components/Step1Form.tsx index a29dbc0..1e5ea3a 100644 --- a/src/pages/products/components/Step1Form.tsx +++ b/src/pages/products/components/Step1Form.tsx @@ -80,6 +80,7 @@ const Step1Form: FC = ({ onSubmit, brands, categories, loading,
setFormData(prev => ({ ...prev, brand: e.target.value }))} items={brands.map(brand => ({ value: brand._id, label: brand.title_fa }))} diff --git a/src/pages/setting/Shop.tsx b/src/pages/setting/Shop.tsx index eee0d16..9b13b20 100644 --- a/src/pages/setting/Shop.tsx +++ b/src/pages/setting/Shop.tsx @@ -11,6 +11,7 @@ import UploadBox from '../../components/UploadBox' import { TickCircle } from 'iconsax-react' import { toast } from 'react-toastify' import { extractErrorMessage } from '@/helpers/utils' +import { useSingleUpload } from '../category' // Validation schema برای UpdateShopType const validationSchema = Yup.object().shape({ @@ -18,13 +19,12 @@ const validationSchema = Yup.object().shape({ shopDescription: Yup.string().required('توضیحات شاپ الزامی است'), telephoneNumber: Yup.string().required('شماره تلفن الزامی است'), shopPostalCode: Yup.string().required('کد پستی الزامی است'), - logo: Yup.string().required('لوگو الزامی است') }) const Shop: FC = () => { const { data: shopDetail, isLoading: shopDetailLoading, error: shopDetailError } = useGetShop() const updateShopMutation = useUpdateShop() - + const uploadSingle = useSingleUpload() const [logoFile, setLogoFile] = useState([]) const formik = useFormik({ @@ -33,21 +33,20 @@ const Shop: FC = () => { shopDescription: '', telephoneNumber: '', shopPostalCode: '', - logo: '' + logo: undefined }, validationSchema, onSubmit: async (values) => { - const logoUrl = values.logo if (logoFile.length > 0) { - // TODO: اینجا باید API آپلود فایل اضافه شود - // const logoResponse = await uploadSingle.mutateAsync(logoFile[0]) - // logoUrl = logoResponse.results?.url?.url || values.logo + const logoResponse = await uploadSingle.mutateAsync(logoFile[0]) + values.logo = logoResponse.results?.url?.url || undefined + } else { + values.logo = undefined } const submitData = { ...values, - logo: logoUrl } updateShopMutation.mutate(submitData, { @@ -61,6 +60,7 @@ const Shop: FC = () => { } }) + useEffect(() => { if (shopDetail?.results?.shop) { const shop = shopDetail.results.shop diff --git a/src/pages/setting/types/Types.ts b/src/pages/setting/types/Types.ts index 41466fa..7b5bf56 100644 --- a/src/pages/setting/types/Types.ts +++ b/src/pages/setting/types/Types.ts @@ -209,7 +209,7 @@ export interface UpdateShopType { shopDescription: string; telephoneNumber: string; shopPostalCode: string; - logo: string; + logo?: string; } export interface BannerItem {