add: limit size

This commit is contained in:
2026-02-09 10:22:34 +03:30
parent 908a69ce0e
commit 03136f5f30

View File

@@ -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 = ({
) : (
<ArrowUpTrayIcon className="w-4 h-4" />
)}
<span>{uploadedFileName ? "آپلود شده" : "آپلود"}</span>
<span>آپلود</span>
</button>
</div>