diff --git a/src/pages/products/product-form/ProductFormPage.tsx b/src/pages/products/product-form/ProductFormPage.tsx index 5c44323..83f7f66 100644 --- a/src/pages/products/product-form/ProductFormPage.tsx +++ b/src/pages/products/product-form/ProductFormPage.tsx @@ -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)} />