import type { FileCategory, MediaCategory, MediaFile, } from "@/domain/work-orders/types/work-order-media"; let mediaIdCounter = 0; export function classifyUpload(f: File): { fileType: FileCategory; category: MediaCategory; } { const t = f.type; if (t.startsWith("image/")) return { fileType: "image", category: "Photo" }; if (t.startsWith("video/")) return { fileType: "video", category: "Video" }; if (t === "application/pdf" || /\.pdf$/i.test(f.name)) { return { fileType: "pdf", category: "Report" }; } return { fileType: "other", category: "Other" }; } export function makeMediaFile(f: File): MediaFile { const { fileType, category } = classifyUpload(f); return { id: `m-${Date.now()}-${mediaIdCounter++}`, name: f.name, fileType, url: URL.createObjectURL(f), category, }; }