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>
This commit is contained in:
29
frontend/app/utils/documentPreview.js
Normal file
29
frontend/app/utils/documentPreview.js
Normal file
@@ -0,0 +1,29 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user