-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tech] refactor useTable and useVirtualizer hooks
- Loading branch information
1 parent
51b3298
commit 0360d31
Showing
9 changed files
with
138 additions
and
141 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
frontend/src/components/TableWithSelectableRows/Header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Icon, TableWithSelectableRows, THEME } from '@mtes-mct/monitor-ui' | ||
import { flexRender } from '@tanstack/react-table' | ||
|
||
export function TableWithSelectableRowsHeader({ headerGroup }) { | ||
return ( | ||
<tr key={headerGroup.id}> | ||
{headerGroup.headers.map(header => ( | ||
<TableWithSelectableRows.Th key={header.id} $width={header.column.getSize()}> | ||
{header.id === 'select' && flexRender(header.column.columnDef.header, header.getContext())} | ||
{header.id !== 'select' && !header.isPlaceholder && ( | ||
<TableWithSelectableRows.SortContainer | ||
className={header.column.getCanSort() ? 'cursor-pointer select-none' : ''} | ||
onClick={header.column.getToggleSortingHandler()} | ||
> | ||
{flexRender(header.column.columnDef.header, header.getContext())} | ||
|
||
{header.column.getCanSort() && | ||
({ | ||
asc: <Icon.SortSelectedUp size={14} />, | ||
desc: <Icon.SortSelectedDown size={14} /> | ||
}[header.column.getIsSorted() as string] ?? ( | ||
<Icon.SortingChevrons color={THEME.color.lightGray} size={14} /> | ||
))} | ||
</TableWithSelectableRows.SortContainer> | ||
)} | ||
</TableWithSelectableRows.Th> | ||
))} | ||
</tr> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const TableWithSelectableRows = () => {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.