import type { IconNames } from "@jobber/design"; import { getFileCategory } from "./getFileCategory"; interface FileTypeToIconNameParams { readonly fileName?: string; readonly fileType?: string; } /** * Pick the file-type icon name for a given file. Today the design system * exposes brand-named icons (`word`, `excel`) which double-duty as the * generic "document" / "spreadsheet" indicators; when generic icons land * in `@jobber/design`, the mapping below is the one place that needs to * change. * * The actual file-type detection lives in `getFileCategory` so consumers * that need a generic category name (e.g. for accessibility labels or * filter UI) do not have to thread brand vocabulary through their copy. */ export function mapFileTypeToIconName({ fileName, fileType, }: FileTypeToIconNameParams): IconNames { if (!fileName && !fileType) { return "alert"; } switch (getFileCategory({ fileName, fileType })) { case "pdf": return "pdf"; case "document": return "word"; case "spreadsheet": return "excel"; case "video": return "videoFile"; case "image": case "other": default: return "file"; } }