Skip to content

Commit

Permalink
refactor: move sorting variables to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlo-skumenko committed Aug 12, 2024
1 parent 85373e9 commit e15465a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button } from '@/components/ui/button';
import { SORTING_TYPE } from '@/constants';
import { Column } from '@tanstack/react-table';
import { ArrowUpDown } from 'lucide-react';

Expand All @@ -12,7 +13,7 @@ export const DataTableColumnWithSorting = <TData, TValue>({
title,
}: DataTableColumnWithSortingProps<TData, TValue>) => {
return (
<Button variant="ghost" onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}>
<Button variant="ghost" onClick={() => column.toggleSorting(column.getIsSorted() === SORTING_TYPE.ASC)}>
{title}
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
Expand Down
5 changes: 5 additions & 0 deletions src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ export const COMPLETED = [
];

export const DATE_FORMAT = 'MMM dd, yyyy';

export const SORTING_TYPE = {
ASC: 'asc',
DESC: 'desc'
};

0 comments on commit e15465a

Please sign in to comment.