feat: implement file acceptance validation in utils and integrate with Dropzone component

This commit is contained in:
dswbx
2025-10-01 09:46:16 +02:00
parent b974fe7ec7
commit d6dcfe3acc
3 changed files with 78 additions and 4 deletions

View File

@@ -9,8 +9,8 @@ import {
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { isFileAccepted } from "bknd/utils";
import { type FileWithPath, useDropzone } from "./use-dropzone";
import { checkMaxReached } from "./helper";
import { DropzoneInner } from "./DropzoneInner";
@@ -173,12 +173,14 @@ export function Dropzone({
return specs.every((spec) => {
if (spec.kind !== "file") {
console.log("not a file", spec.kind);
console.warn("file not accepted: not a file", spec.kind);
return false;
}
if (allowedMimeTypes && allowedMimeTypes.length > 0) {
console.log("not allowed mimetype", spec.type);
return allowedMimeTypes.includes(spec.type);
if (!isFileAccepted(i, allowedMimeTypes)) {
console.warn("file not accepted: not allowed mimetype", spec.type);
return false;
}
}
return true;
});