extrapolate actions column
This commit is contained in:
parent
c339aa5002
commit
1a7d439e30
|
@ -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<PubsWithGenres>()
|
||||
|
@ -57,38 +58,8 @@ export const columns: ColumnDef<PubsWithGenres>[] = [
|
|||
accessorKey: "query_after_days",
|
||||
header: "Query After (days)"
|
||||
},
|
||||
actions({ pathname: "/publication", deleteFn: deletePub })
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
// header: "Actions",
|
||||
cell: ({ row }) => {
|
||||
return <div className="flex items-center justify-around">
|
||||
<Link href={`/publication/${row.original.id}`}><Search /></Link>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost"><Trash2 color="red" /></Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Are you sure?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Deleting a publication cannot be undone!
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="destructive"
|
||||
onClick={() => {
|
||||
deletePub(row.original.id)
|
||||
}}>Yes, delete it!
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -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<StoryWithGenres>()
|
||||
|
@ -61,37 +62,7 @@ export const columns: ColumnDef<StoryWithGenres>[] = [
|
|||
filterFn: "arrIncludes"
|
||||
//TODO - write custom filter function, to account for an array of objects
|
||||
}),
|
||||
{
|
||||
id: "actions",
|
||||
// header: "Actions",
|
||||
cell: ({ row }) => {
|
||||
return <div className="flex items-center justify-around">
|
||||
<Link href={`/story/${row.original.id}`}><Search /></Link>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost"><Trash2 color="red" /></Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Are you sure?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Deleting a story cannot be undone!
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="destructive"
|
||||
onClick={() => {
|
||||
deleteStory(row.original.id)
|
||||
}}>Yes, delete it!
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
//this is a function so that the actions column can be uniform across tables
|
||||
actions({ pathname: "/story", deleteFn: deleteStory })
|
||||
]
|
||||
|
||||
|
|
|
@ -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<SubComplete>()
|
||||
|
@ -90,37 +91,7 @@ export const columns: ColumnDef<SubComplete>[] = [
|
|||
},
|
||||
|
||||
|
||||
{
|
||||
id: "actions",
|
||||
// header: "Actions",
|
||||
cell: ({ row }) => {
|
||||
return <div className="flex items-center justify-around">
|
||||
<Link href={`/submission/${row.original.id}`}><Search /></Link>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost"><Trash2 color="red" /></Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Are you sure?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Deleting a submission cannot be undone!
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="destructive"
|
||||
onClick={() => {
|
||||
deleteSub(row.original.id)
|
||||
}}>Yes, delete it!
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
actions({ pathname: "/submission", deleteFn: deleteSub })
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -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 <div className="flex items-center justify-around">
|
||||
<Link href={`${pathname}/${row.original.id}`}><Search /></Link>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="ghost"><Trash2 color="red" /></Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Are you sure?</DialogTitle>
|
||||
<DialogDescription>
|
||||
Deleting a {pathname.slice(1)} cannot be undone!
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button variant="destructive"
|
||||
onClick={() => {
|
||||
deleteFn(row.original.id)
|
||||
}}>Yes, delete it!
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue