Add CRUD for other entities

This commit is contained in:
Darren Clarke 2024-04-25 13:36:50 +02:00
parent f87bcc43a5
commit a3e8b89128
64 changed files with 949 additions and 62 deletions

View file

@ -0,0 +1,35 @@
"use client";
import { FC } from "react";
import { Grid } from "@mui/material";
import { DisplayTextField } from "ui";
import { VoiceLine } from "@/app/_lib/database";
import { Detail as InternalDetail } from "@/app/_components/Detail";
import { deleteVoiceLineAction } from "../../_actions/voice";
type DetailProps = {
row: VoiceLine;
};
export const Detail: FC<DetailProps> = ({ row }) => (
<InternalDetail
title={`Voice Line: ${row.name}`}
entity="voice"
id={row.id}
deleteAction={deleteVoiceLineAction}
>
<Grid container direction="row" rowSpacing={3} columnSpacing={2}>
<Grid item xs={12}>
<DisplayTextField name="name" label="Name" value={row.name} />
</Grid>
<Grid item xs={12}>
<DisplayTextField
name="description"
label="Description"
lines={3}
value={row.description}
/>
</Grid>
</Grid>
</InternalDetail>
);

View file

@ -0,0 +1,24 @@
import { db } from "@/app/_lib/database";
import { Detail } from "./_components/Detail";
export const dynamic = "force-dynamic";
type Props = {
params: { segment: string[] };
};
export default async function Page({ params: { segment } }: Props) {
const id = segment?.[0];
if (!id) return null;
const row = await db
.selectFrom("VoiceLine")
.selectAll()
.where("id", "=", id)
.executeTakeFirst();
if (!row) return null;
return <Detail row={row} />;
}