diff --git a/client/src/components/Minutes.tsx b/client/src/components/Minutes.tsx index 3d279aa..a7c58f8 100644 --- a/client/src/components/Minutes.tsx +++ b/client/src/components/Minutes.tsx @@ -53,9 +53,16 @@ const Minutes: React.FC = () => { }, []); const sortedMinutes = [...minutesData].sort((a, b) => { - if (a[sortColumn] < b[sortColumn]) return sortDirection === 'asc' ? -1 : 1; - if (a[sortColumn] > b[sortColumn]) return sortDirection === 'asc' ? 1 : -1; - return 0; + if (sortColumn === 'date') { + // Convert date strings to Date objects for proper comparison + const dateA = new Date(a.date.split('/').map((part, i) => i === 0 ? part : i === 1 ? part : part).join('/')); + const dateB = new Date(b.date.split('/').map((part, i) => i === 0 ? part : i === 1 ? part : part).join('/')); + return sortDirection === 'asc' ? dateA.getTime() - dateB.getTime() : dateB.getTime() - dateA.getTime(); + } else { + if (a[sortColumn] < b[sortColumn]) return sortDirection === 'asc' ? -1 : 1; + if (a[sortColumn] > b[sortColumn]) return sortDirection === 'asc' ? 1 : -1; + return 0; + } }); const handleSort = (column: keyof MinuteEntry) => { diff --git a/cline_docs/activeContext.md b/cline_docs/activeContext.md index 121ffc0..7573f7a 100644 --- a/cline_docs/activeContext.md +++ b/cline_docs/activeContext.md @@ -9,7 +9,10 @@ Adding new meeting minutes to the website: ## Recent Changes 1. Modified Minutes.tsx to include new meeting entry -2. File structure: +2. Fixed date sorting issue: + - Updated sorting logic to convert date strings to Date objects + - Ensures proper chronological sorting regardless of date format +3. File structure: - PDF file location: client/public/minutes/minutes-02082025.pdf - Component location: client/src/components/Minutes.tsx diff --git a/cline_docs/progress.md b/cline_docs/progress.md index 191a9bb..4c53900 100644 --- a/cline_docs/progress.md +++ b/cline_docs/progress.md @@ -17,6 +17,7 @@ - PDF file added to public/minutes/ - Updated Minutes.tsx component - Reordered minutes data from newest (top) to oldest (bottom) in the source array + - Fixed date sorting issue by converting strings to Date objects for comparison 2. Deployment (in progress): - Changes pushed to git repository