Styles, API calls, and more
This commit is contained in:
87
src/DataTable/columns/BookmarkColumns.tsx
Normal file
87
src/DataTable/columns/BookmarkColumns.tsx
Normal file
@@ -0,0 +1,87 @@
|
||||
import { MRT_ColumnDef } from "mantine-react-table";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export default function ApplicationColumns(groups: any, groupData: any) {
|
||||
const columns = useMemo<MRT_ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
if (row.id) {
|
||||
return `${row.id}`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
enableEditing: false,
|
||||
id: "id",
|
||||
header: "ID",
|
||||
size: 50,
|
||||
mantineCopyButtonProps: ({ cell, row }) => ({
|
||||
className: "id",
|
||||
id: `${cell.getValue()}-id`,
|
||||
}),
|
||||
Cell: ({ renderedCellValue, row }) => renderedCellValue,
|
||||
Header: ({ column }) => column.columnDef.header,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
if (row.name) {
|
||||
return `${row.name}`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
id: "name",
|
||||
header: "Name",
|
||||
mantineCopyButtonProps: ({ cell, row }) => ({
|
||||
className: "name",
|
||||
id: `${cell.getValue()}-name`,
|
||||
}),
|
||||
Cell: ({ renderedCellValue, row }) => renderedCellValue,
|
||||
Header: ({ column }) => column.columnDef.header,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
if (row.url) {
|
||||
return `${row.url}`;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
id: "url",
|
||||
header: "Url",
|
||||
mantineCopyButtonProps: ({ cell, row }) => ({
|
||||
className: "url",
|
||||
id: `${cell.getValue()}-url`,
|
||||
}),
|
||||
Cell: ({ renderedCellValue, row }) => renderedCellValue,
|
||||
Header: ({ column }) => column.columnDef.header,
|
||||
},
|
||||
{
|
||||
accessorFn: (row) => {
|
||||
const index: number = row.category;
|
||||
if (index !== null && index !== undefined) {
|
||||
return `${index}`;
|
||||
} else {
|
||||
return "N/A";
|
||||
}
|
||||
},
|
||||
id: "category",
|
||||
header: "Category",
|
||||
editVariant: "select",
|
||||
mantineEditSelectProps: { data: groups },
|
||||
mantineCopyButtonProps: ({ cell, row }) => ({
|
||||
className: "category",
|
||||
id: `${cell.getValue()}-category`,
|
||||
}),
|
||||
Cell: ({ renderedCellValue, row }) =>
|
||||
groupData[row?.original.category].category_name,
|
||||
Header: ({ column }) => column.columnDef.header,
|
||||
},
|
||||
],
|
||||
[groups],
|
||||
);
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user