Files
Inventory/frontend/app/utils/documentPreview.js
Matthieu 974a4a0781 refactor : merge Inventory_frontend submodule into frontend/ directory
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>
2026-04-01 14:17:57 +02:00

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
}