From 03136f5f301febc2444a907e50369bdd4d1c0764 Mon Sep 17 00:00:00 2001 From: wixarm Date: Mon, 9 Feb 2026 10:22:34 +0330 Subject: [PATCH] add: limit size --- src/components/DocumentOperation/DocumentOperation.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/DocumentOperation/DocumentOperation.tsx b/src/components/DocumentOperation/DocumentOperation.tsx index 2e2d513..9fa3241 100644 --- a/src/components/DocumentOperation/DocumentOperation.tsx +++ b/src/components/DocumentOperation/DocumentOperation.tsx @@ -18,6 +18,7 @@ interface DocumentOperationProps { onUploadSuccess?: () => void; page?: string; access?: string; + limitSize?: number; } const buildAcceptString = (extensions: string[]): string => { @@ -44,6 +45,7 @@ export const DocumentOperation = ({ onUploadSuccess, page = "", access = "", + limitSize, }: DocumentOperationProps) => { const { openBackdrop, closeBackdrop } = useBackdropStore(); const showToast = useToast(); @@ -153,6 +155,11 @@ export const DocumentOperation = ({ fileInputRef.current.value = ""; } + if (limitSize && file.size > limitSize * 1024 * 1024) { + showToast(`حداکثر حجم فایل ${limitSize} مگابایت است`, "error"); + return; + } + openBackdrop(); try { const formData = new FormData(); @@ -212,7 +219,7 @@ export const DocumentOperation = ({ ) : ( )} - {uploadedFileName ? "آپلود شده" : "آپلود"} + آپلود