Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

Feature: Upgrade Attendees table to Tanstack (#903)

Dave Earleye28aea73888c
diff --git a/frontend/package.json b/frontend/package.json
index 19d8b2a8f..9433f342f 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -42,6 +42,7 @@
"@stripe/stripe-js": "^1.54.1",
"@tabler/icons-react": "^2.44.0",
"@tanstack/react-query": "5.76.1",
+ "@tanstack/react-table": "^8.21.3",
"@tiptap/core": "^2.7.0",
"@tiptap/extension-color": "^2.11.7",
"@tiptap/extension-image": "^2.11.5",
diff --git a/frontend/src/components/common/AttendeeTable/AttendeeTable.module.scss b/frontend/src/components/common/AttendeeTable/AttendeeTable.module.scss
index aabacfe59..9e5880f54 100644
--- a/frontend/src/components/common/AttendeeTable/AttendeeTable.module.scss
+++ b/frontend/src/components/common/AttendeeTable/AttendeeTable.module.scss
@@ -1,29 +1,122 @@
-.tableContainer {
- overflow-x: auto;
+.attendeeDetails {
+ min-width: 0;
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
}
-.table {
- width: 100%;
- position: relative;
+.nameRow {
+ display: flex;
+ align-items: center;
+ gap: 8px;
}
-.stickyActionColumn {
- position: sticky;
- right: 0;
- background: white;
- box-shadow: -4px 0 6px rgba(0, 0, 0, 0.1);
- z-index: 2;
+.attendeeName {
+ font-size: 15px;
+ font-weight: 600;
+ line-height: 1.3;
+ text-decoration: none;
+ color: var(--mantine-color-text);
+
+ &:hover {
+ text-decoration: underline;
+ }
+}
+
+.attendeeId {
+ font-size: 12px;
+ color: var(--mantine-color-dimmed);
+ font-family: 'Courier New', monospace;
+ line-height: 1.3;
+}
+
+.emailRow {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.attendeeEmail {
+ font-size: 13px;
+ line-height: 1.3;
+ color: var(--mantine-color-dimmed);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ max-width: 250px;
+}
+
+.emailActions {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ flex-shrink: 0;
+}
+
+.actionIcon {
+ flex-shrink: 0;
+}
+
+.orderTicketContainer {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+}
+
+.ticketName {
+ font-size: 14px;
+ font-weight: 500;
+ color: var(--mantine-color-text);
+ line-height: 1.3;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
-.tableContainer::-webkit-scrollbar {
- height: 10px;
+.orderId {
+ font-size: 11px;
+ color: var(--mantine-color-dimmed);
+ font-family: 'Courier New', monospace;
+ line-height: 1.3;
+
+ :hover {
+ text-decoration: underline;
+ }
+}
+
+.registrationDate {
+ font-size: 12px;
+ color: var(--mantine-color-dimmed);
+ line-height: 1.3;
}
-.tableContainer::-webkit-scrollbar-thumb {
- background: rgba(0, 0, 0, 0.2);
- border-radius: 5px;
+.checkInButton {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ padding: 8px 14px;
+ border: 1.5px solid var(--mantine-color-default-border);
+ border-radius: 8px;
+ background: var(--mantine-color-body);
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ white-space: nowrap;
+
+ &.checkedIn {
+ border-color: var(--mantine-color-green-6);
+ background: var(--mantine-color-green-0);
+ color: var(--mantine-color-green-9);
+ }
+
+ &.notCheckedIn {
+ color: var(--mantine-color-dimmed);
+ }
}
-.tableContainer::-webkit-scrollbar-track {
- background: rgba(0, 0, 0, 0.05);
+.actionsMenu {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
}
diff --git a/frontend/src/components/common/AttendeeTable/index.tsx b/frontend/src/components/common/AttendeeTable/index.tsx
index be6d4119c..b4ace849b 100644
--- a/frontend/src/components/common/AttendeeTable/index.tsx
+++ b/frontend/src/components/common/AttendeeTable/index.tsx
@@ -1,24 +1,24 @@
-import {ActionIcon, Anchor, Avatar, Badge, Button, Group, Popover, Table as MantineTable, Tooltip} from '@mantine/core';
+import {ActionIcon, Anchor, Avatar, Button, Group, Popover, Tooltip} from '@mantine/core';
import {Attendee, IdParam, MessageType} from "../../../types.ts";
import {
+ IconCheck,
+ IconClipboardList,
IconCopy,
IconMailForward,
IconNote,
IconPlus,
- IconQrcode,
- IconQrcodeOff,
IconSend,
IconTrash,
IconUserCog
} from "@tabler/icons-react";
import {getInitials, getProductFromEvent} from "../../../utilites/helpers.ts";
-import {Table, TableHead} from "../Table";
import {useClipboard, useDisclosure} from "@mantine/hooks";
import {SendMessageModal} from "../../modals/SendMessageModal";
-import {useState} from "react";
+import {useMemo, useState} from "react";
import {NoResultsSplash} from "../NoResultsSplash";
import {useParams} from "react-router";
import {useGetEvent} from "../../../queries/useGetEvent.ts";
+import {useGetEventCheckInLists} from "../../../queries/useGetCheckInLists.ts";
import Truncate from "../Truncate";
import {notifications} from "@mantine/notifications";
import {useModifyAttendee} from "../../../mutations/useModifyAttendee.ts";
@@ -32,6 +32,10 @@ import {ActionMenu} from '../ActionMenu';
import {AttendeeStatusBadge} from "../AttendeeStatusBadge";
import {CheckInStatusModal} from "../CheckInStatusModal";
import {prettyDate} from "../../../utilites/dates.ts";
+import {TanStackTable, TanStackTableColumn} from "../TanStackTable";
+import {ColumnVisibilityToggle} from "../ColumnVisibilityToggle";
+import {CellContext} from "@tanstack/react-table";
+import classes from './AttendeeTable.module.scss';
interface AttendeeTableProps {
attendees: Attendee[];
@@ -48,10 +52,13 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
const [selectedAttendee, setSelectedAttendee] = useState<Attendee>();
const [selectedOrderId, setSelectedOrderId] = useState<IdParam>();
const {data: event} = useGetEvent(eventId);
+ const {data: checkInLists} = useGetEventCheckInLists(eventId);
const modifyMutation = useModifyAttendee();
const resendTicketMutation = useResendAttendeeTicket();
const clipboard = useClipboard({timeout: 2000});
+ const hasCheckInLists = checkInLists?.data && checkInLists.data.length > 0;
+
const handleModalClick = (attendee: Attendee, modal: {
open: () => void
}) => {
@@ -141,45 +148,37 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
orderModal.open();
};
- return (
- <>
- <Table>
- <TableHead>
- <MantineTable.Tr>
- <MantineTable.Th></MantineTable.Th>
- <MantineTable.Th>{t`Name`}</MantineTable.Th>
- <MantineTable.Th>{t`Email`}</MantineTable.Th>
- <MantineTable.Th miw={140}>{t`Order`}</MantineTable.Th>
- <MantineTable.Th>{t`Ticket`}</MantineTable.Th>
- <MantineTable.Th miw={120}>{t`Status`}</MantineTable.Th>
- <MantineTable.Th w={60} style={{textAlign: 'center'}}>{t`Check-In Status`}</MantineTable.Th>
- <MantineTable.Th w={60}></MantineTable.Th>
- <MantineTable.Th></MantineTable.Th>
- </MantineTable.Tr>
- </TableHead>
- <MantineTable.Tbody>
- {attendees.map((attendee) => {
- const checkInCount = getCheckInCount(attendee);
- const hasChecked = hasCheckIns(attendee);
-
- return (
- <MantineTable.Tr key={attendee.id}>
- <MantineTable.Td>
- <Avatar
- size={40}>{getInitials(attendee.first_name + ' ' + attendee.last_name)}</Avatar>
- </MantineTable.Td>
- <MantineTable.Td>
- <b>
- <Truncate length={20}
- text={attendee.first_name + ' ' + attendee.last_name}/>
- </b>
- <div>
- {attendee.public_id}
+ const columns = useMemo<TanStackTableColumn<Attendee>[]>(
+ () => {
+ const allColumns: TanStackTableColumn<Attendee>[] = [
+ {
+ id: 'attendeeDetails',
+ header: t`Attendee Details`,
+ enableHiding: false,
+ cell: (info: CellContext<Attendee, unknown>) => (
+ <Group gap="sm" wrap="nowrap">
+ <Avatar size={44} radius={10} color="primary" variant="light">
+ {getInitials(info.row.original.first_name + ' ' + info.row.original.last_name)}
+ </Avatar>
+ <div className={classes.attendeeDetails}>
+ <div className={classes.nameRow}>
+ <Anchor
+ className={classes.attendeeName}
+ onClick={() => handleModalClick(info.row.original, viewModalOpen)}
+ style={{cursor: 'pointer'}}
+ >
+ <Truncate
+ length={30}
+ text={info.row.original.first_name + ' ' + info.row.original.last_name}
+ />
+ </Anchor>
+ <div className={classes.attendeeId}>
+ {info.row.original.public_id}
</div>
- </MantineTable.Td>
- <MantineTable.Td>
+ </div>
+ <div className={classes.emailRow}>
<Popover
- opened={emailPopoverId === attendee.id}
+ opened={emailPopoverId === info.row.original.id}
onChange={(opened) => {
if (!opened) setEmailPopoverId(null);
}}
@@ -190,10 +189,11 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
>
<Popover.Target>
<Anchor
- onClick={() => setEmailPopoverId(attendee.id || null)}
+ onClick={() => setEmailPopoverId(info.row.original.id || null)}
+ className={classes.attendeeEmail}
style={{cursor: 'pointer'}}
>
- <Truncate length={25} text={attendee.email}/>
+ {info.row.original.email}
</Anchor>
</Popover.Target>
<Popover.Dropdown>
@@ -202,7 +202,7 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
fullWidth
variant="light"
leftSection={<IconSend size={16}/>}
- onClick={() => handleMessageFromEmail(attendee)}
+ onClick={() => handleMessageFromEmail(info.row.original)}
>
{t`Message`}
</Button>
@@ -211,147 +211,193 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)
variant="light"
color="gray"
leftSection={<IconCopy size={16}/>}
- onClick={() => handleCopyEmail(attendee.email)}
+ onClick={() => handleCopyEmail(info.row.original.email)}
>
{t`Copy Email`}
</Button>
</Group>
</Popover.Dropdown>
</Popover>
- </MantineTable.Td>
- <MantineTable.Td>
- <Tooltip
- label={
- attendee.order?.created_at && event?.timezone
- ? t`Registered: ${prettyDate(attendee.order.created_at, event.timezone)}`
- : t`Order details`
- }
- withArrow
- >
- <Anchor
- onClick={() => handleOrderClick(attendee.order_id)}
- style={{cursor: 'pointer'}}
- >
- <Badge variant={'outline'} style={{cursor: 'pointer'}}>
- {attendee.order?.public_id}
- </Badge>
- </Anchor>
- </Tooltip>
- </MantineTable.Td>
- <MantineTable.Td>
- <Truncate
- text={getProductFromEvent(attendee.product_id, event)?.title}
- length={25}
- />
- </MantineTable.Td>
- <MantineTable.Td>
- <AttendeeStatusBadge attendee={attendee}/>
- </MantineTable.Td>
- <MantineTable.Td style={{textAlign: 'center'}}>
- <Tooltip
- label={
- hasChecked
- ? t`Checked into ${checkInCount} list(s)`
- : t`Not checked in`
- }
- withArrow
- >
- <ActionIcon
- variant="subtle"
- color={hasChecked ? 'green' : 'gray'}
- onClick={() => handleModalClick(attendee, checkInModal)}
- aria-label={t`View check-in status`}
- >
- {!hasChecked && <IconQrcodeOff size={18}/>}
- {hasChecked && <IconQrcode size={18}/>}
- {hasChecked && (
- <Badge
+ <div className={classes.emailActions}>
+ {info.row.original.notes && (
+ <Tooltip
+ label={
+ info.row.original.notes.length > 100
+ ? t`Click to view notes`
+ : info.row.original.notes
+ }
+ multiline
+ w={info.row.original.notes.length > 100 ? 'auto' : 300}
+ withArrow
+ >
+ <ActionIcon
+ className={classes.actionIcon}
size="xs"
- circle
- variant="filled"
+ variant="subtle"
color="green"
- style={{
- position: 'absolute',
- top: -2,
- right: -2,
- minWidth: 16,
- height: 16,
- padding: '0 4px'
+ onClick={() => {
+ if (info.row.original.notes && info.row.original.notes.length > 100) {
+ handleModalClick(info.row.original, viewModalOpen);
+ }
}}
>
- {checkInCount}
- </Badge>
- )}
- </ActionIcon>
- </Tooltip>
- </MantineTable.Td>
- <MantineTable.Td style={{textAlign: 'center'}}>
- {attendee.notes && (
- <Tooltip
- label={
- attendee.notes.length > 100
- ? t`Click to view notes`
- : attendee.notes
- }
- multiline
- w={attendee.notes.length > 100 ? 'auto' : 300}
- withArrow
- >
- <ActionIcon
- variant="subtle"
- onClick={() => {
- if (attendee.notes && attendee.notes.length > 100) {
- handleModalClick(attendee, viewModalOpen);
- }
- }}
- aria-label={t`View notes`}
- >
- <IconNote size={18}/>
- </ActionIcon>
- </Tooltip>
- )}
- </MantineTable.Td>
- <MantineTable.Td style={{paddingRight: 0}}>
- <ActionMenu itemsGroups={[
+ <IconNote size={16}/>
+ </ActionIcon>
+ </Tooltip>
+ )}
+ </div>
+ </div>
+ </div>
+ </Group>
+ ),
+ meta: {
+ headerStyle: {minWidth: 300},
+ },
+ },
+ {
+ id: 'orderAndTicket',
+ header: t`Order & Ticket`,
+ enableHiding: true,
+ cell: (info: CellContext<Attendee, unknown>) => {
+ const ticketTitle = getProductFromEvent(info.row.original.product_id, event)?.title;
+ return (
+ <div className={classes.orderTicketContainer}>
+ <div className={classes.ticketName}>
+ <Truncate
+ text={ticketTitle}
+ length={25}
+ />
+ </div>
+ <div className={classes.orderId}>
+ <Anchor
+ onClick={() => handleOrderClick(info.row.original.order_id)}
+ style={{cursor: 'pointer', color: 'inherit', textDecoration: 'none'}}
+ >
+ {info.row.original.order?.public_id}
+ </Anchor>
+ </div>
+ {info.row.original.order?.created_at && event?.timezone && (
+ <div className={classes.registrationDate}>
+ {prettyDate(info.row.original.order.created_at, event.timezone)}
+ </div>
+ )}
+ </div>
+ );
+ },
+ meta: {
+ headerStyle: {minWidth: 160},
+ },
+ },
+ {
+ id: 'status',
+ header: t`Status`,
+ enableHiding: true,
+ cell: (info: CellContext<Attendee, unknown>) => <AttendeeStatusBadge attendee={info.row.original}/>,
+ meta: {
+ headerStyle: {minWidth: 120},
+ },
+ },
+ {
+ id: 'checkIn',
+ header: t`Check-In Status`,
+ enableHiding: true,
+ cell: (info: CellContext<Attendee, unknown>) => {
+ const checkInCount = getCheckInCount(info.row.original);
+ const hasChecked = hasCheckIns(info.row.original);
+ const totalLists = checkInLists?.data?.length || 0;
+
+ return (
+ <button
+ className={`${classes.checkInButton} ${hasChecked ? classes.checkedIn : classes.notCheckedIn}`}
+ onClick={() => handleModalClick(info.row.original, checkInModal)}
+ >
+ {hasChecked ? (
+ <>
+ <IconCheck size={16}/>
+ {t`Checked In`} ({checkInCount}/{totalLists})
+ </>
+ ) : (
+ <>
+ <IconClipboardList size={16}/>
+ {t`Not Checked In`}
+ </>
+ )}
+ </button>
+ );
+ },
+ meta: {
+ headerStyle: {width: 80, textAlign: 'center'},
+ cellStyle: {textAlign: 'center'},
+ },
+ },
+ {
+ id: 'actions',
+ header: '',
+ enableHiding: false,
+ cell: (info: CellContext<Attendee, unknown>) => (
+ <div className={classes.actionsMenu}>
+ <ActionMenu itemsGroups={[
+ {
+ label: t`Actions`,
+ items: [
{
- label: t`Actions`,
- items: [
- {
- label: t`Manage attendee`,
- icon: <IconUserCog size={14}/>,
- onClick: () => handleModalClick(attendee, viewModalOpen),
- },
- {
- label: t`Message attendee`,
- icon: <IconSend size={14}/>,
- onClick: () => handleModalClick(attendee, messageModal),
- },
- {
- label: t`Resend ticket email`,
- icon: <IconMailForward size={14}/>,
- onClick: () => handleResendTicket(attendee),
- visible: attendee.status === 'ACTIVE',
- },
- ],
+ label: t`Manage attendee`,
+ icon: <IconUserCog size={14}/>,
+ onClick: () => handleModalClick(info.row.original, viewModalOpen),
},
{
- label: t`Danger Zone`,
- items: [
- {
- label: attendee.status === 'CANCELLED' ? t`Activate` : t`Cancel` + ` ` + t`ticket`,
- icon: <IconTrash size={14}/>,
- onClick: () => handleCancel(attendee),
- color: attendee.status === 'CANCELLED' ? 'green' : 'red',
- },
- ],
+ label: t`Message attendee`,
+ icon: <IconSend size={14}/>,
+ onClick: () => handleModalClick(info.row.original, messageModal),
},
- ]}/>
- </MantineTable.Td>
- </MantineTable.Tr>
- );
- })}
- </MantineTable.Tbody>
- </Table>
+ {
+ label: t`Resend ticket email`,
+ icon: <IconMailForward size={14}/>,
+ onClick: () => handleResendTicket(info.row.original),
+ visible: info.row.original.status === 'ACTIVE',
+ },
+ ],
+ },
+ {
+ label: t`Danger Zone`,
+ items: [
+ {
+ label: info.row.original.status === 'CANCELLED' ? t`Activate` : t`Cancel` + ` ` + t`ticket`,
+ icon: <IconTrash size={14}/>,
+ onClick: () => handleCancel(info.row.original),
+ color: info.row.original.status === 'CANCELLED' ? 'green' : 'red',
+ },
+ ],
+ },
+ ]}/>
+ </div>
+ ),
+ meta: {
+ sticky: 'right',
+ cellStyle: {paddingRight: 0},
+ },
+ },
+ ];
+
+ return allColumns.filter(column => {
+ if (column.id === 'checkIn' && !hasCheckInLists) {
+ return false;
+ }
+ return true;
+ });
+ },
+ [emailPopoverId, event, hasCheckInLists]
+ );
+
+ return (
+ <>
+ <TanStackTable
+ data={attendees}
+ columns={columns}
+ storageKey="attendee-table"
+ enableColumnVisibility={true}
+ renderColumnVisibilityToggle={(table) => <ColumnVisibilityToggle table={table}/>}
+ />
{(selectedAttendee && isMessageModalOpen) && <SendMessageModal
onClose={messageModal.close}
orderId={selectedAttendee.order_id}
diff --git a/frontend/src/components/common/ColumnVisibilityToggle/index.tsx b/frontend/src/components/common/ColumnVisibilityToggle/index.tsx
new file mode 100644
index 000000000..b94dc3f5f
--- /dev/null
+++ b/frontend/src/components/common/ColumnVisibilityToggle/index.tsx
@@ -0,0 +1,46 @@
+import {Button, Checkbox, Menu} from '@mantine/core';
+import {IconColumns} from '@tabler/icons-react';
+import {Table} from '@tanstack/react-table';
+import {t} from '@lingui/macro';
+
+interface ColumnVisibilityToggleProps<TData> {
+ table: Table<TData>;
+}
+
+export function ColumnVisibilityToggle<TData>({table}: ColumnVisibilityToggleProps<TData>) {
+ const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
+
+ if (columns.length === 0) {
+ return null;
+ }
+
+ return (
+ <Menu shadow="md" width={200} closeOnItemClick={false}>
+ <Menu.Target>
+ <Button size="xs" variant="light" leftSection={<IconColumns size={16}/>}>
+ {t`Columns`}
+ </Button>
+ </Menu.Target>
+
+ <Menu.Dropdown>
+ <Menu.Label>{t`Toggle columns`}</Menu.Label>
+ {columns.map((column) => {
+ const columnDef = column.columnDef;
+ const label = typeof columnDef.header === 'string'
+ ? columnDef.header
+ : (columnDef.id || column.id);
+
+ return (
+ <Menu.Item key={column.id}>
+ <Checkbox
+ checked={column.getIsVisible()}
+ onChange={column.getToggleVisibilityHandler()}
+ label={label}
+ />
+ </Menu.Item>
+ );
+ })}
+ </Menu.Dropdown>
+ </Menu>
+ );
+}
diff --git a/frontend/src/components/common/TanStackTable/TanStackTable.module.scss b/frontend/src/components/common/TanStackTable/TanStackTable.module.scss
new file mode 100644
index 000000000..154729a1f
--- /dev/null
+++ b/frontend/src/components/common/TanStackTable/TanStackTable.module.scss
@@ -0,0 +1,122 @@
+@use "../../../styles/mixins";
+
+.tableWrapper {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+}
+
+.toolbar {
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+ gap: 0.5rem;
+}
+
+.tableHead {
+ white-space: nowrap;
+
+ th {
+ background-color: #f2f0f5;
+ color: var(--hi-secondary-text) !important;
+ padding: 0.75rem 0.625rem !important;
+ }
+}
+
+.card {
+ padding: 0 !important;
+ overflow: hidden;
+
+ :global(.mantine-ScrollArea-viewport) {
+ padding-bottom: 0;
+ }
+}
+
+.table {
+ th {
+ white-space: nowrap;
+ }
+
+ tbody tr {
+
+ td {
+ padding: 20px !important;
+ white-space: nowrap;
+ }
+ }
+
+ position: relative;
+}
+
+.stickyLeft {
+ position: sticky;
+ left: 0;
+ z-index: 10;
+ background: var(--mantine-color-body);
+
+ &::after {
+ content: '';
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ width: 1px;
+ background: linear-gradient(
+ to right,
+ rgba(0, 0, 0, 0.1),
+ rgba(0, 0, 0, 0)
+ );
+ pointer-events: none;
+ }
+
+ @media (prefers-color-scheme: dark) {
+ &::after {
+ background: linear-gradient(
+ to right,
+ rgba(255, 255, 255, 0.1),
+ rgba(255, 255, 255, 0)
+ );
+ }
+ }
+}
+
+.stickyRight {
+ position: sticky;
+ right: 0;
+ z-index: 10;
+ background: var(--mantine-color-body);
+
+ &::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ width: 1px;
+ background: linear-gradient(
+ to left,
+ rgba(0, 0, 0, 0.1),
+ rgba(0, 0, 0, 0)
+ );
+ pointer-events: none;
+ }
+
+ @media (prefers-color-scheme: dark) {
+ &::before {
+ background: linear-gradient(
+ to left,
+ rgba(255, 255, 255, 0.1),
+ rgba(255, 255, 255, 0)
+ );
+ }
+ }
+}
+
+.tableHead .stickyLeft,
+.tableHead .stickyRight {
+ background-color: #462e7812;
+
+ @media (prefers-color-scheme: dark) {
+ background-color: #f2f0f5;
+ }
+}
diff --git a/frontend/src/components/common/TanStackTable/index.tsx b/frontend/src/components/common/TanStackTable/index.tsx
new file mode 100644
index 000000000..07d3e617e
--- /dev/null
+++ b/frontend/src/components/common/TanStackTable/index.tsx
@@ -0,0 +1,141 @@
+import {
+ ColumnDef,
+ flexRender,
+ getCoreRowModel,
+ useReactTable,
+ VisibilityState,
+} from '@tanstack/react-table';
+import {Table as MantineTable} from '@mantine/core';
+import React, {useEffect, useState} from 'react';
+import {Card} from '../Card';
+import classes from './TanStackTable.module.scss';
+
+export interface TanStackTableColumnMeta {
+ sticky?: 'left' | 'right';
+ headerStyle?: React.CSSProperties;
+ cellStyle?: React.CSSProperties;
+}
+
+export type TanStackTableColumn<TData> = ColumnDef<TData> & {
+ meta?: TanStackTableColumnMeta;
+};
+
+interface TanStackTableProps<TData> {
+ data: TData[];
+ columns: TanStackTableColumn<TData>[];
+ storageKey?: string;
+ enableColumnVisibility?: boolean;
+ renderColumnVisibilityToggle?: (table: ReturnType<typeof useReactTable<TData>>) => React.ReactNode;
+}
+
+export function TanStackTable<TData>({
+ data,
+ columns,
+ storageKey,
+ enableColumnVisibility = false,
+ renderColumnVisibilityToggle,
+}: TanStackTableProps<TData>) {
+ const [columnVisibility, setColumnVisibility] = useState<VisibilityState>(() => {
+ if (storageKey && enableColumnVisibility) {
+ const stored = localStorage.getItem(`${storageKey}-column-visibility`);
+ if (stored) {
+ try {
+ return JSON.parse(stored);
+ } catch {
+ return {};
+ }
+ }
+ }
+ return {};
+ });
+
+ const table = useReactTable({
+ data,
+ columns,
+ getCoreRowModel: getCoreRowModel(),
+ state: {
+ columnVisibility,
+ },
+ onColumnVisibilityChange: setColumnVisibility,
+ enableHiding: enableColumnVisibility,
+ });
+
+ useEffect(() => {
+ if (storageKey && enableColumnVisibility) {
+ localStorage.setItem(`${storageKey}-column-visibility`, JSON.stringify(columnVisibility));
+ }
+ }, [columnVisibility, storageKey, enableColumnVisibility]);
+
+ return (
+ <div className={classes.tableWrapper}>
+ {enableColumnVisibility && renderColumnVisibilityToggle && (
+ <div className={classes.toolbar}>
+ {renderColumnVisibilityToggle(table)}
+ </div>
+ )}
+ <Card className={classes.card}>
+ <MantineTable.ScrollContainer minWidth={200}>
+ <MantineTable className={classes.table}>
+ <MantineTable.Thead className={classes.tableHead}>
+ {table.getHeaderGroups().map((headerGroup) => (
+ <MantineTable.Tr key={headerGroup.id}>
+ {headerGroup.headers.map((header) => {
+ const columnMeta = header.column.columnDef.meta as TanStackTableColumnMeta | undefined;
+ const stickyClass = columnMeta?.sticky === 'left'
+ ? classes.stickyLeft
+ : columnMeta?.sticky === 'right'
+ ? classes.stickyRight
+ : '';
+
+ return (
+ <MantineTable.Th
+ key={header.id}
+ className={stickyClass}
+ style={{
+ ...columnMeta?.headerStyle,
+ }}
+ >
+ {header.isPlaceholder
+ ? null
+ : flexRender(
+ header.column.columnDef.header,
+ header.getContext()
+ )}
+ </MantineTable.Th>
+ );
+ })}
+ </MantineTable.Tr>
+ ))}
+ </MantineTable.Thead>
+ <MantineTable.Tbody>
+ {table.getRowModel().rows.map((row) => (
+ <MantineTable.Tr key={row.id}>
+ {row.getVisibleCells().map((cell) => {
+ const columnMeta = cell.column.columnDef.meta as TanStackTableColumnMeta | undefined;
+ const stickyClass = columnMeta?.sticky === 'left'
+ ? classes.stickyLeft
+ : columnMeta?.sticky === 'right'
+ ? classes.stickyRight
+ : '';
+
+ return (
+ <MantineTable.Td
+ key={cell.id}
+ className={stickyClass}
+ style={{
+ ...columnMeta?.cellStyle,
+ }}
+ >
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ </MantineTable.Td>
+ );
+ })}
+ </MantineTable.Tr>
+ ))}
+ </MantineTable.Tbody>
+ </MantineTable>
+ </MantineTable.ScrollContainer>
+ </Card>
+ </div>
+ );
+}
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index c4e32b9bd..1a6f66efa 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -1474,6 +1474,18 @@
dependencies:
"@tanstack/query-core" "5.76.0"
+"@tanstack/react-table@^8.21.3":
+ version "8.21.3"
+ resolved "https://registry.yarnpkg.com/@tanstack/react-table/-/react-table-8.21.3.tgz#2c38c747a5731c1a07174fda764b9c2b1fb5e91b"
+ integrity sha512-5nNMTSETP4ykGegmVkhjcS8tTLW6Vl4axfEGQN3v0zdHYbK4UfoqfPChclTrJ4EoK9QynqAu9oUf8VEmrpZ5Ww==
+ dependencies:
+ "@tanstack/table-core" "8.21.3"
+
+"@tanstack/[email protected]":
+ version "8.21.3"
+ resolved "https://registry.yarnpkg.com/@tanstack/table-core/-/table-core-8.21.3.tgz#2977727d8fc8dfa079112d9f4d4c019110f1732c"
+ integrity sha512-ldZXEhOBb8Is7xLs01fR3YEc3DERiz5silj8tnGkFZytt1abEvl/GhUmCE0PMLaMPTa3Jk4HbKmRlHmu+gCftg==
+
"@tiptap/core@^2.26.3", "@tiptap/core@^2.7.0":
version "2.26.3"
resolved "https://registry.yarnpkg.com/@tiptap/core/-/core-2.26.3.tgz#dadae7fbc9aa3a1e89e93f2f0a36262cb252e564"