Fix
This commit is contained in:
parent
5cb4f76d11
commit
dd1d0b02b9
|
|
@ -102,6 +102,17 @@ const validateMediaFile = async (file: File, options?: { requireSquare?: boolean
|
|||
}
|
||||
};
|
||||
|
||||
const validateExplorerFile = async (file: File) => {
|
||||
if (isImageFile(file)) {
|
||||
await ensureSquareImage(file);
|
||||
return;
|
||||
}
|
||||
if (isVideoFile(file)) {
|
||||
return;
|
||||
}
|
||||
throw new Error('فقط تصاویر یا ویدیو مجاز است');
|
||||
};
|
||||
|
||||
const mapExplorerFiles = (entries: any[]): ProductImage[] => {
|
||||
if (!entries || !Array.isArray(entries)) {
|
||||
return [];
|
||||
|
|
@ -302,7 +313,7 @@ const ProductFormPage = () => {
|
|||
|
||||
const handleExplorerUpload = async (file: File) => {
|
||||
try {
|
||||
await validateMediaFile(file, { requireSquare: isImageFile(file) });
|
||||
await validateExplorerFile(file);
|
||||
const result = await uploadFile(file);
|
||||
setExplorerFiles(prev => {
|
||||
const newImage: ProductImage = {
|
||||
|
|
@ -656,11 +667,11 @@ const ProductFormPage = () => {
|
|||
onUpload={handleExplorerUpload}
|
||||
onRemove={handleExplorerRemove}
|
||||
acceptedTypes={['image/*', 'video/*']}
|
||||
maxFileSize={25 * 1024 * 1024}
|
||||
maxFileSize={0}
|
||||
maxFiles={5}
|
||||
mode="multi"
|
||||
label=""
|
||||
description="فایلهای Explorer را آپلود کنید (تصاویر مربعی با حداکثر ۲ مگ و ویدیوهای حداکثر ۲۵ مگ)"
|
||||
description="فایلهای Explorer را آپلود کنید (تصاویر باید مربعی باشند)"
|
||||
onUploadStart={() => setIsExplorerUploading(true)}
|
||||
onUploadComplete={() => setIsExplorerUploading(false)}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue