Mager updated

This commit is contained in:
Simon Pocrnjič
2025-09-27 17:45:55 +02:00
parent d17e34941b
commit 7227c888d4
74 changed files with 6339 additions and 342 deletions
+25
View File
@@ -0,0 +1,25 @@
export type DocLike = { uuid: string; original_name?: string; name?: string; extension?: string; mime_type?: string }
const PREVIEW_EXTS = ['pdf', 'txt', 'jpeg', 'jpg', 'png', 'doc', 'docx']
const DOWNLOAD_ONLY_EXTS = ['xls', 'xlsx', 'csv']
export function getExtension(doc: DocLike): string {
const ext = doc.extension || (doc.original_name || doc.name || '').split('.').pop() || ''
return ext.toLowerCase()
}
export function isPreviewableExt(ext?: string): boolean {
if (!ext) return false
return PREVIEW_EXTS.includes(ext.toLowerCase())
}
export function isDownloadOnlyExt(ext?: string): boolean {
if (!ext) return false
return DOWNLOAD_ONLY_EXTS.includes(ext.toLowerCase())
}
export function classifyDocument(doc: DocLike): 'preview' | 'download' {
const ext = getExtension(doc)
if (isPreviewableExt(ext)) return 'preview'
return 'download'
}