diff --git a/src/components/upload-purchase-order-button.tsx b/src/components/upload-purchase-order-button.tsx index fba2438..9397320 100644 --- a/src/components/upload-purchase-order-button.tsx +++ b/src/components/upload-purchase-order-button.tsx @@ -10,6 +10,7 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; +import { ALLOWED_MIME, MAX_FILE_BYTES } from "@/lib/purchase-order-schema"; type Phase = "idle" | "uploading" | "done" | "error"; @@ -18,14 +19,7 @@ interface UploadAck { filename: string; } -const ALLOWED_MIMES = [ - "image/jpeg", - "image/png", - "image/webp", - "application/pdf", -]; -const ACCEPT_ATTR = ".jpg,.jpeg,.png,.webp,.pdf"; -const MAX_FILE_BYTES = 20 * 1024 * 1024; +const ACCEPT_ATTR = [...ALLOWED_MIME].join(","); export function UploadPurchaseOrderButton() { const [open, setOpen] = React.useState(false); @@ -76,7 +70,7 @@ export function UploadPurchaseOrderButton() { const onPickFile: React.ChangeEventHandler = (e) => { const f = e.target.files?.[0]; if (!f) return; - if (!ALLOWED_MIMES.includes(f.type)) { + if (!ALLOWED_MIME.has(f.type)) { setErrorMsg("Unsupported file type: " + (f.type || "unknown")); setFile(null); return;