From b946955f49998cdff1af392fef5cb16d2ec5820b Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Wed, 17 Dec 2025 02:36:22 -0800 Subject: [PATCH] fix: Documents page - remove category field references, align with backend schema - Removed category field usage (doesn't exist in Prisma schema) - Changed grouping from category to type - Removed GUIDE type (not in backend) - Updated filter dropdown with correct types --- frontend/src/lib/documentsApi.ts | 2 +- frontend/src/pages/DocumentsPage.tsx | 32 ++++++++-------------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/frontend/src/lib/documentsApi.ts b/frontend/src/lib/documentsApi.ts index 5ebb804..d3c2ff9 100644 --- a/frontend/src/lib/documentsApi.ts +++ b/frontend/src/lib/documentsApi.ts @@ -1,6 +1,6 @@ import api from './api'; -export type DocumentType = 'SOP' | 'POLICY' | 'FORM' | 'CHECKLIST' | 'GUIDE' | 'TRAINING' | 'OTHER'; +export type DocumentType = 'SOP' | 'POLICY' | 'FORM' | 'CHECKLIST' | 'TRAINING' | 'OTHER'; export type DocumentStatus = 'DRAFT' | 'PENDING_APPROVAL' | 'APPROVED' | 'ARCHIVED'; export interface Document { diff --git a/frontend/src/pages/DocumentsPage.tsx b/frontend/src/pages/DocumentsPage.tsx index 9a82531..1079bb8 100644 --- a/frontend/src/pages/DocumentsPage.tsx +++ b/frontend/src/pages/DocumentsPage.tsx @@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'; import { FileText, Search, Plus, Clock, User, Check, X, AlertCircle, Eye, Edit, FolderOpen, Book, - ClipboardList, FileCheck, HelpCircle, History, Download, Loader2, + ClipboardList, FileCheck, History, Download, Loader2, LucideIcon } from 'lucide-react'; import { documentsApi, Document, DocumentType, DocumentStatus, DocumentVersion } from '../lib/documentsApi'; @@ -13,7 +13,6 @@ const TYPE_CONFIG: Record(''); const [filterStatus, setFilterStatus] = useState(''); - const [filterCategory, setFilterCategory] = useState(''); const [selectedDoc, setSelectedDoc] = useState(null); const [versions, setVersions] = useState([]); const [showVersions, setShowVersions] = useState(false); @@ -41,7 +39,7 @@ export default function DocumentsPage() { useEffect(() => { loadDocuments(); loadPendingAcks(); - }, [filterType, filterStatus, filterCategory]); + }, [filterType, filterStatus]); async function loadDocuments() { setLoading(true); @@ -49,7 +47,6 @@ export default function DocumentsPage() { const docs = await documentsApi.getDocuments({ type: filterType || undefined, status: filterStatus || undefined, - category: filterCategory || undefined, search: searchTerm || undefined }); setDocuments(docs); @@ -92,8 +89,7 @@ export default function DocumentsPage() { } } - const categories = [...new Set(documents.map(d => d.category).filter(Boolean))]; - + // Filter documents by search term const filteredDocs = documents.filter(doc => { if (searchTerm && !doc.title.toLowerCase().includes(searchTerm.toLowerCase())) { return false; @@ -101,10 +97,11 @@ export default function DocumentsPage() { return true; }); + // Group by type for display const groupedDocs = filteredDocs.reduce((acc, doc) => { - const cat = doc.category || 'Uncategorized'; - if (!acc[cat]) acc[cat] = []; - acc[cat].push(doc); + const typeLabel = TYPE_CONFIG[doc.type]?.label || doc.type; + if (!acc[typeLabel]) acc[typeLabel] = []; + acc[typeLabel].push(doc); return acc; }, {} as Record); @@ -162,9 +159,10 @@ export default function DocumentsPage() { + - + - {categories.length > 0 && ( - - )} {/* Documents Grid */}