2024-06-20 09:39:35 +00:00
|
|
|
"use client"
|
|
|
|
import { ColumnDef, createColumnHelper } from "@tanstack/react-table"
|
|
|
|
import { ArrowUpDown, MoreHorizontal } from "lucide-react"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
|
|
import { Badge } from "@/components/ui/badge"
|
|
|
|
import { Trash2, Search } from "lucide-react"
|
|
|
|
import {
|
|
|
|
Dialog,
|
|
|
|
DialogClose,
|
|
|
|
DialogContent,
|
|
|
|
DialogDescription,
|
|
|
|
DialogFooter,
|
|
|
|
DialogHeader,
|
|
|
|
DialogTitle,
|
|
|
|
DialogTrigger,
|
|
|
|
} from "@/components/ui/dialog"
|
|
|
|
import { deleteStory, deleteSub } from "app/lib/del"
|
|
|
|
import Link from "next/link"
|
|
|
|
import { SubComplete } from "./page"
|
2024-06-22 18:12:05 +00:00
|
|
|
import { actions } from "app/ui/tables/actions"
|
2024-06-20 09:39:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
const columnHelper = createColumnHelper<SubComplete>()
|
|
|
|
|
|
|
|
export const columns: ColumnDef<SubComplete>[] = [
|
|
|
|
{
|
|
|
|
accessorFn: row => new Date(row.submitted),
|
|
|
|
id: "submitted",
|
|
|
|
header: ({ column }) => {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
variant="ghost"
|
|
|
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
|
|
|
>
|
|
|
|
Date Submitted
|
|
|
|
<ArrowUpDown className="ml-2 h-4 w-4" />
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
enableColumnFilter: false,
|
|
|
|
sortingFn: "datetime",
|
|
|
|
cell: props => { return props.getValue().toLocaleDateString() }
|
|
|
|
},
|
|
|
|
{
|
2024-06-25 10:20:41 +00:00
|
|
|
accessorFn: row => row.responded ? new Date(row.responded) : null,
|
2024-06-20 09:39:35 +00:00
|
|
|
id: "responded",
|
|
|
|
header: ({ column }) => {
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
variant="ghost"
|
|
|
|
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
|
|
|
|
>
|
|
|
|
Date Responded
|
|
|
|
<ArrowUpDown className="ml-2 h-4 w-4" />
|
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
enableColumnFilter: false,
|
|
|
|
sortingFn: "datetime",
|
2024-06-25 10:20:41 +00:00
|
|
|
cell: props => props.getValue() ? props.getValue().toLocaleDateString() : '-'
|
2024-06-20 09:39:35 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
accessorFn: row => {
|
|
|
|
if (row.response) {
|
|
|
|
return row.response.response
|
|
|
|
}
|
|
|
|
return "RECORD DELETED"
|
|
|
|
},
|
|
|
|
id: "response",
|
|
|
|
header: "Response"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
accessorFn: row => {
|
|
|
|
if (row.pub) {
|
|
|
|
return row.pub.title
|
|
|
|
}
|
|
|
|
return "RECORD DELETED"
|
|
|
|
},
|
|
|
|
id: "pub",
|
|
|
|
header: "Publication"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
accessorFn: row => {
|
|
|
|
if (row.story) {
|
|
|
|
return row.story.title
|
|
|
|
}
|
|
|
|
return "RECORD DELETED"
|
|
|
|
},
|
|
|
|
id: "story",
|
|
|
|
header: "Story"
|
|
|
|
},
|
2024-06-22 18:12:05 +00:00
|
|
|
actions({ pathname: "/submission", deleteFn: deleteSub })
|
2024-06-20 09:39:35 +00:00
|
|
|
|
|
|
|
]
|
|
|
|
|