From c8f374f75457cf72ad09110e91d64073d33d1e22 Mon Sep 17 00:00:00 2001 From: andrzej Date: Sat, 22 Jun 2024 20:12:05 +0200 Subject: [PATCH] extrapolate actions column --- src/app/publication/columns.tsx | 33 ++-------------------------- src/app/story/columns.tsx | 35 +++-------------------------- src/app/submission/columns.tsx | 33 ++-------------------------- src/app/ui/tables/actions.tsx | 39 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 94 deletions(-) create mode 100644 src/app/ui/tables/actions.tsx diff --git a/src/app/publication/columns.tsx b/src/app/publication/columns.tsx index 7db47a4..eff3b87 100644 --- a/src/app/publication/columns.tsx +++ b/src/app/publication/columns.tsx @@ -17,6 +17,7 @@ import { deletePub } from "app/lib/del" import Link from "next/link" import { PubsWithGenres } from "./page" import { DialogClose } from "@radix-ui/react-dialog" +import { actions } from "app/ui/tables/actions" const columnHelper = createColumnHelper() @@ -57,38 +58,8 @@ export const columns: ColumnDef[] = [ accessorKey: "query_after_days", header: "Query After (days)" }, + actions({ pathname: "/publication", deleteFn: deletePub }) - { - id: "actions", - // header: "Actions", - cell: ({ row }) => { - return
- - - - - - - - Are you sure? - - Deleting a publication cannot be undone! - - - - - - - - - -
- } - } ] diff --git a/src/app/story/columns.tsx b/src/app/story/columns.tsx index 67d7674..11485cd 100644 --- a/src/app/story/columns.tsx +++ b/src/app/story/columns.tsx @@ -18,6 +18,7 @@ import { deleteStory } from "app/lib/del" import Link from "next/link" import { DialogClose } from "@radix-ui/react-dialog" import GenreBadges from "app/ui/genreBadges" +import { actions } from "app/ui/tables/actions" const columnHelper = createColumnHelper() @@ -61,37 +62,7 @@ export const columns: ColumnDef[] = [ filterFn: "arrIncludes" //TODO - write custom filter function, to account for an array of objects }), - { - id: "actions", - // header: "Actions", - cell: ({ row }) => { - return
- - - - - - - - Are you sure? - - Deleting a story cannot be undone! - - - - - - - - - -
- } - } - + //this is a function so that the actions column can be uniform across tables + actions({ pathname: "/story", deleteFn: deleteStory }) ] diff --git a/src/app/submission/columns.tsx b/src/app/submission/columns.tsx index 85158c1..b79115f 100644 --- a/src/app/submission/columns.tsx +++ b/src/app/submission/columns.tsx @@ -17,6 +17,7 @@ import { import { deleteStory, deleteSub } from "app/lib/del" import Link from "next/link" import { SubComplete } from "./page" +import { actions } from "app/ui/tables/actions" const columnHelper = createColumnHelper() @@ -90,37 +91,7 @@ export const columns: ColumnDef[] = [ }, - { - id: "actions", - // header: "Actions", - cell: ({ row }) => { - return
- - - - - - - - Are you sure? - - Deleting a submission cannot be undone! - - - - - - - - - -
- } - } + actions({ pathname: "/submission", deleteFn: deleteSub }) ] diff --git a/src/app/ui/tables/actions.tsx b/src/app/ui/tables/actions.tsx new file mode 100644 index 0000000..5331fb6 --- /dev/null +++ b/src/app/ui/tables/actions.tsx @@ -0,0 +1,39 @@ +import { Dialog, DialogTrigger, DialogClose, DialogDescription, DialogContent, DialogTitle, DialogHeader, DialogFooter } from "@/components/ui/dialog" +import Link from "next/link" +import { Trash2, Search } from "lucide-react" +import { Button } from "@/components/ui/button" + +export function actions({ pathname, deleteFn }: { pathname: string, deleteFn: (id: number) => void }) { + return { + id: "actions", + // header: "Actions", + cell: ({ row }) => { + return
+ + + + + + + + Are you sure? + + Deleting a {pathname.slice(1)} cannot be undone! + + + + + + + + + +
+ } + } +} +