link-stack/apps/bridge-frontend/app/_components/List.tsx

36 lines
780 B
TypeScript
Raw Normal View History

2024-03-04 13:52:20 +01:00
"use client";
import { FC } from "react";
2024-04-23 13:36:51 +02:00
import { GridColDef } from "@mui/x-data-grid-pro";
2024-03-04 13:52:20 +01:00
import { useRouter } from "next/navigation";
2024-04-24 21:44:05 +02:00
import { List as InternalList, Button } from "ui";
import { colors } from "ui";
2024-03-04 13:52:20 +01:00
interface ListProps {
title: string;
entity: string;
rows: any;
columns: GridColDef<any>[];
}
export const List: FC<ListProps> = ({ title, entity, rows, columns }) => {
const router = useRouter();
2024-04-24 21:44:05 +02:00
const { mediumBlue } = colors;
2024-03-04 13:52:20 +01:00
const onRowClick = (id: string) => {
router.push(`/${entity}/${id}`);
};
return (
2024-04-23 13:36:51 +02:00
<InternalList
title={title}
rows={rows}
columns={columns}
onRowClick={onRowClick}
2024-04-24 21:44:05 +02:00
buttons={
<Button text="New" color={mediumBlue} href={`/${entity}/create`} />
}
2024-04-23 13:36:51 +02:00
/>
2024-03-04 13:52:20 +01:00
);
};