diff --git a/frontend/src/components/file/DocumentCard.vue b/frontend/src/components/file/DocumentCard.vue index 12a717c6..7b093f8d 100644 --- a/frontend/src/components/file/DocumentCard.vue +++ b/frontend/src/components/file/DocumentCard.vue @@ -3,8 +3,9 @@ import { filesize } from 'filesize'; import { Button, Card, useConfirm, useToast } from '@/lib/primevue'; import { documentService } from '@/services'; +import { FILE_CATEGORIES } from '@/utils/constants'; import { formatDateLong } from '@/utils/formatters'; -import { isFileCategory } from '@/utils/utils'; +import { getFileCategory } from '@/utils/utils'; import compressed from '@/assets/images/compressed.svg'; import doc from '@/assets/images/doc.svg'; @@ -55,22 +56,22 @@ const confirmDelete = (documentId: string, filename: string) => { }; const displayIcon = (mimeType = '') => { - const icon = isFileCategory(mimeType); + const icon = getFileCategory(mimeType); switch (icon) { - case 'doc': + case FILE_CATEGORIES.DOC: return doc; - case 'shape': + case FILE_CATEGORIES.SHAPE: return shape; - case 'pdf': + case FILE_CATEGORIES.PDF: return pdf; - case 'spreadsheet': + case FILE_CATEGORIES.SPREADSHEET: return spreadsheet; - case 'image': + case FILE_CATEGORIES.IMAGE: return image; - case 'email': + case FILE_CATEGORIES.EMAIL: return email; - case 'compressed': + case FILE_CATEGORIES.COMPRESSED: return compressed; default: return file; diff --git a/frontend/src/utils/constants.ts b/frontend/src/utils/constants.ts index 9aef4e73..0e1999df 100644 --- a/frontend/src/utils/constants.ts +++ b/frontend/src/utils/constants.ts @@ -66,3 +66,17 @@ export const QueuePriority = [0, 1, 2, 3, 4, 5]; * Default System User ID */ export const SYSTEM_USER = '00000000-0000-0000-0000-000000000000'; + +/** + * File category definitions + */ +export const FILE_CATEGORIES = { + COMPRESSED: 'compressed', + DOC: 'doc', + EMAIL: 'email', + FILE: 'file', + IMAGE: 'image', + PDF: 'pdf', + SHAPE: 'shape', + SPREADSHEET: 'spreadsheet' +}; diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index 2b11a454..f9449f50 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -1,4 +1,4 @@ -import { DELIMITER } from '@/utils/constants'; +import { DELIMITER, FILE_CATEGORIES } from '@/utils/constants'; /** * @function differential @@ -12,47 +12,47 @@ export function differential(source: any, comparer: any): any { } /** - * @function isFileCategory + * @function getFileCategory * Compares mimeType to a list and returns a string category for that mimetype * @param {string} mimeType mimeType to be categorized * @returns {string} Category of file the mimeType falls under */ -export function isFileCategory(mimeType: string): string { +export function getFileCategory(mimeType: string): string { // Checks for commonly used and likely used mimetypes switch (true) { case mimeType.includes('/vnd.shp'): case mimeType.includes('/vnd.shx'): case mimeType.includes('/dbase'): case mimeType.includes('/dbf'): - return 'shape'; + return FILE_CATEGORIES.SHAPE; case mimeType.includes('/msword'): case mimeType.includes('/vnd.ms-word'): case mimeType.includes('/vnd.oasis.opendocument.text'): case mimeType.includes('/vnd.openxmlformats-officedocument.wordprocessingml'): - return 'doc'; + return FILE_CATEGORIES.DOC; case mimeType.includes('/vnd.pdf'): case mimeType.includes('/pdf'): case mimeType.includes('/x-pdf'): - return 'pdf'; + return FILE_CATEGORIES.PDF; case mimeType.includes('/vnd.ms-excel'): case mimeType.includes('/vnd.openxmlformats-officedocument.spreadsheetml'): case mimeType.includes('/vnd.oasis.opendocument.spreadsheet'): - return 'spreadsheet'; + return FILE_CATEGORIES.SPREADSHEET; case mimeType.includes('image/'): - return 'image'; + return FILE_CATEGORIES.IMAGE; case mimeType.includes('/vnd.seemail'): case mimeType.includes('/vnd.omads-email+xml'): case mimeType.includes('message/'): - return 'email'; + return FILE_CATEGORIES.EMAIL; case mimeType.includes('/gzip'): case mimeType.includes('/zip'): case mimeType.includes('/x-gzip'): case mimeType.includes('/x-zip'): case mimeType.includes('/x-7z'): case mimeType.includes('/x-rar'): - return 'compressed'; + return FILE_CATEGORIES.COMPRESSED; default: - return 'file'; + return FILE_CATEGORIES.FILE; } }