Files
calendar/packages/features/ee/dsync/components/GroupTeamMappingTable.tsx
T
1404581f78 feat: add text filter on org member list (#17632)
* feat: improve text filters (WIP)

* move function to bottom

* apply some styles

* fix selection of TextFilterOptions

* rename value to operand

* remove unused file

* merge filters/filters into filters/utils

* fix regression of not putting url params correctly

* move makeWhereClause to filters/utils

* fix negative, empty, and not empty operators

* fix initial filtering from search state (url)

* fix type errors

* do not send an empty array to query

* update yarn.lock

* i18n for text filter operators

* extract logic as useColumnFilters()

* add missing import

* fix type error

* revert yarn.lock

* use i18n

* insensitive text match

* move data-table to @calcom/features

* fix type errors

* fix type errors

* fix type errors

---------

Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2024-11-20 09:38:10 +00:00

69 lines
1.8 KiB
TypeScript

import type { ColumnDef } from "@tanstack/react-table";
import { useReactTable, getCoreRowModel } from "@tanstack/react-table";
import { useRef, useState } from "react";
import { DataTable, DataTableToolbar } from "@calcom/features/data-table";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import CreateTeamDialog from "./CreateTeamDialog";
import GroupNameCell from "./GroupNameCell";
interface TeamGroupMapping {
name: string;
id: number;
groupNames: string[];
directoryId: string;
}
const GroupTeamMappingTable = () => {
const { t } = useLocale();
const [createTeamDialogOpen, setCreateTeamDialogOpen] = useState(false);
const { data } = trpc.viewer.dsync.teamGroupMapping.get.useQuery();
const tableContainerRef = useRef<HTMLDivElement>(null);
const columns: ColumnDef<TeamGroupMapping>[] = [
{
id: "name",
header: t("team"),
cell: ({ row }) => {
const { name } = row.original;
return <p>{name}</p>;
},
},
{
id: "group",
header: t("group_name"),
cell: ({ row }) => {
const { id, groupNames, directoryId } = row.original;
return <GroupNameCell groupNames={groupNames} teamId={id} directoryId={directoryId} />;
},
},
];
const table = useReactTable({
data: data?.teamGroupMapping ?? [],
columns,
getCoreRowModel: getCoreRowModel(),
});
return (
<>
<DataTable table={table} tableContainerRef={tableContainerRef}>
<DataTableToolbar.Root>
<DataTableToolbar.CTA onClick={() => setCreateTeamDialogOpen(true)}>
Create team
</DataTableToolbar.CTA>
</DataTableToolbar.Root>
</DataTable>
<CreateTeamDialog open={createTeamDialogOpen} onOpenChange={setCreateTeamDialogOpen} />
</>
);
};
export default GroupTeamMappingTable;