Merges the full git history of Inventory_frontend into the monorepo under frontend/. Removes the submodule in favor of a unified repo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
import { getFileIcon } from './fileIcons'
|
|
|
|
export const getPreviewType = (document) => {
|
|
if (!document) { return null }
|
|
const mime = (document.mimeType || '').toLowerCase()
|
|
|
|
if (mime.startsWith('image/')) { return 'image' }
|
|
if (mime === 'application/pdf') { return 'pdf' }
|
|
if (mime.startsWith('audio/')) { return 'audio' }
|
|
if (mime.startsWith('video/')) { return 'video' }
|
|
if (mime.startsWith('text/') || mime.includes('json') || mime.includes('xml')) { return 'text' }
|
|
return null
|
|
}
|
|
|
|
export const canPreviewDocument = (document = {}) => {
|
|
if (!getPreviewType(document)) return false
|
|
return !!(document.fileUrl || document.path)
|
|
}
|
|
|
|
export const isImageDocument = (document = {}) => getPreviewType(document) === 'image'
|
|
|
|
export const isPdfDocument = (document = {}) => getPreviewType(document) === 'pdf'
|
|
|
|
export const describeDocument = (document) => {
|
|
if (!document) { return '' }
|
|
const name = document.filename || document.name || ''
|
|
const icon = getFileIcon({ name, mime: document.mimeType })
|
|
return icon.label
|
|
}
|