Skip to content

Commit

Permalink
Merge pull request #133 from hack4impact-calpoly/129-fix-table-column…
Browse files Browse the repository at this point in the history
…-sorting

fix: hearing date and date accepted sorting
  • Loading branch information
ryanchansf authored May 14, 2024
2 parents 1d06793 + 6696ab9 commit 232c728
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions frontend/src/lib/tableColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ export const columns: ColumnDef<IProject>[] = [
</Button>
);
},
sortingFn: (row1: any, row2: any, columnId: any) => {
const datestr1 = row1.getValue(columnId);
const datestr2 = row2.getValue(columnId);

// dates are in "Month Day, Year - Time AM/PM" format
// remove '-' so string can be properly converted into date object
const date1 = new Date(String(datestr1).replace("-", ""));
const date2 = new Date(String(datestr2).replace("-", ""));

return date1 < date2 ? 1 : -1;
},
},
{
accessorKey: "reviewStatus",
Expand All @@ -69,6 +80,17 @@ export const columns: ColumnDef<IProject>[] = [
</Button>
);
},
sortingFn: (row1: any, row2: any, columnId: any) => {
const datestr1 = row1.getValue(columnId);
const datestr2 = row2.getValue(columnId);

// dates are in "Month Day, Year - Time AM/PM" format
// remove '-' so string can be properly converted into date object
const date1 = new Date(String(datestr1).replace("-", ""));
const date2 = new Date(String(datestr2).replace("-", ""));

return date1 < date2 ? 1 : -1;
},
},
{
accessorKey: "requestingParty",
Expand Down

0 comments on commit 232c728

Please sign in to comment.