Refactoring 2
This commit is contained in:
parent
dd14dfe72e
commit
e4b78ceec2
76 changed files with 870 additions and 734 deletions
35
packages/bridge-ui/components/List.tsx
Normal file
35
packages/bridge-ui/components/List.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use client";
|
||||
|
||||
import { FC } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { List as InternalList, Button } from "ui";
|
||||
import { type Selectable } from "kysely";
|
||||
import { type Database } from "bridge-common";
|
||||
import { serviceConfig } from "../config/config";
|
||||
|
||||
type ListProps = {
|
||||
service: string;
|
||||
rows: Selectable<keyof Database>[];
|
||||
};
|
||||
|
||||
export const List: FC<ListProps> = ({ service, rows }) => {
|
||||
const { displayName, entity, listColumns } = serviceConfig[service];
|
||||
const title = `${displayName}s`;
|
||||
const router = useRouter();
|
||||
|
||||
const onRowClick = (id: string) => {
|
||||
router.push(`/${entity}/${id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<InternalList
|
||||
title={title}
|
||||
rows={rows}
|
||||
columns={listColumns}
|
||||
onRowClick={onRowClick}
|
||||
buttons={
|
||||
<Button text="Create" kind="primary" href={`/${entity}/create`} />
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue