diff --git a/prisma/dev.db b/prisma/dev.db index 77e4e7b..f064208 100644 Binary files a/prisma/dev.db and b/prisma/dev.db differ diff --git a/src/app/lib/del.ts b/src/app/lib/del.ts index f30819a..0589b04 100644 --- a/src/app/lib/del.ts +++ b/src/app/lib/del.ts @@ -2,6 +2,7 @@ import { revalidatePath } from "next/cache"; import prisma from "./db"; import { redirect } from "next/navigation"; +import { Pathname } from "app/types"; const tableMap = { "/story": "story", @@ -9,7 +10,7 @@ const tableMap = { "/submission": "sub" } -export async function deleteRecord(id: number, pathname: "/story" | "/publication" | "/submission") { +export async function deleteRecord(id: number, pathname: Pathname) { const table = tableMap[pathname] const res = await prisma[table].delete({ where: { id } }) console.log(`deleted from ${table}: ${res.id}`) diff --git a/src/app/submission/page.tsx b/src/app/submission/page.tsx index 09896d6..473f642 100644 --- a/src/app/submission/page.tsx +++ b/src/app/submission/page.tsx @@ -3,6 +3,7 @@ import { DataTable } from "app/ui/tables/data-table" import { columns } from "./columns" import { Pub, Response, Story, Sub } from "@prisma/client" import CreateSubmissionDialog from "./create" +import { Trash2 } from "lucide-react" export type SubComplete = Sub & { pub: Pub, diff --git a/src/app/tailwind.css b/src/app/tailwind.css index 891070a..985ae03 100644 --- a/src/app/tailwind.css +++ b/src/app/tailwind.css @@ -1055,6 +1055,10 @@ video { align-items: baseline; } +.justify-start { + justify-content: flex-start; +} + .justify-end { justify-content: flex-end; } diff --git a/src/app/types.ts b/src/app/types.ts new file mode 100644 index 0000000..c3e65d5 --- /dev/null +++ b/src/app/types.ts @@ -0,0 +1 @@ +export type Pathname = "/story" | "/publication" | "/submission" diff --git a/src/app/ui/tables/data-table.tsx b/src/app/ui/tables/data-table.tsx index 215030e..505cf31 100644 --- a/src/app/ui/tables/data-table.tsx +++ b/src/app/ui/tables/data-table.tsx @@ -37,9 +37,11 @@ import { TableHeader, TableRow, } from "@/components/ui/table" -import { EyeIcon } from "lucide-react" +import { EyeIcon, Trash2 } from "lucide-react" import { usePathname } from "next/navigation" import FormContextMenu from "./contextMenu" +import { deleteRecords } from "app/lib/del" +import { Pathname } from "app/types" interface DataTableProps { columns: ColumnDef[] @@ -78,10 +80,10 @@ export function DataTable({ columnVisibility, } }) - const pathname = usePathname() + const pathname: Pathname = usePathname() const [filterBy, setFilterBy] = useState(table.getAllColumns()[0]) return (<> -
+
@@ -116,6 +118,17 @@ export function DataTable({ {children} +