Skip to content

Commit

Permalink
docs: improve documentation for dateFilterFn
Browse files Browse the repository at this point in the history
  • Loading branch information
matalex412 committed Aug 23, 2024
1 parent 48337b4 commit 3de0173
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 0 additions & 5 deletions app/opportunities/OpportunityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ const OpportunityTable = ({
},
deadline: {
cell: info => <time suppressHydrationWarning={true}>{format(info.getValue(), "EEEE do MMMM yyyy")}</time>,
// cell: info => (
// <time suppressHydrationWarning={true}>
// {formatDistanceToNowStrict(info.getValue(), { addSuffix: true })}{" "}
// </time>
// ),
header: "Application Deadline",
sortingFn: "datetime",
id: "deadline",
Expand Down
10 changes: 9 additions & 1 deletion components/TanstackTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ const formatDateRange = (dates: [string, string]): string => {
return ""
}

export const dateFilterFn = <T,>(row: Row<T>, id: string, filterValue: any[]): boolean =>
/**
* Filter function for columns with type date. Keeps rows which are after the start date (if set) and before the end date (if set).
* @template T The type of the row
* @param row The row to filter
* @param id The column id to filter
* @param filterValue The filter value to be applied of the form [start, end]
* @returns Whether the row should be displayed
*/
export const dateFilterFn = <T,>(row: Row<T>, id: string, filterValue: [string, string]): boolean =>
(!filterValue[0] || isAfter(row.getValue(id), filterValue[0] + "T00:00")) &&
(!filterValue[1] || isAfter(filterValue[1] + "T23:59", row.getValue(id)))

Expand Down

0 comments on commit 3de0173

Please sign in to comment.