fix bug
This commit is contained in:
@@ -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 = () => {
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<TrashWithConfrim
|
||||
{/* <TrashWithConfrim
|
||||
onDelete={() => {
|
||||
// TODO: Implement delete product
|
||||
console.log('Delete product:', product._id);
|
||||
}}
|
||||
/>
|
||||
/> */}
|
||||
</div>
|
||||
</Td>
|
||||
</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">
|
||||
<Select
|
||||
label="دستهبندی"
|
||||
placeholder="انتخاب دستهبندی"
|
||||
value={formData.category}
|
||||
onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))}
|
||||
items={categoryItems}
|
||||
@@ -88,6 +89,7 @@ const Step1Form: FC<Step1FormProps> = ({ onSubmit, brands, categories, loading,
|
||||
|
||||
<Select
|
||||
label="برند"
|
||||
placeholder="انتخاب برند"
|
||||
value={formData.brand}
|
||||
onChange={(e) => setFormData(prev => ({ ...prev, brand: e.target.value }))}
|
||||
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 { 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<File[]>([])
|
||||
|
||||
const formik = useFormik<UpdateShopType>({
|
||||
@@ -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
|
||||
|
||||
@@ -209,7 +209,7 @@ export interface UpdateShopType {
|
||||
shopDescription: string;
|
||||
telephoneNumber: string;
|
||||
shopPostalCode: string;
|
||||
logo: string;
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
export interface BannerItem {
|
||||
|
||||
Reference in New Issue
Block a user