2024-12-11 18:28:57 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
import { ColumnDef } from "@tanstack/react-table";
|
|
|
|
|
|
|
|
|
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
|
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import {
|
|
|
|
|
DropdownMenu,
|
|
|
|
|
DropdownMenuContent,
|
|
|
|
|
DropdownMenuTrigger,
|
|
|
|
|
DropdownMenuItem,
|
|
|
|
|
} from "@/components/ui/dropdown-menu";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Badge } from "@/components/ui/badge";
|
2024-12-16 14:05:10 +00:00
|
|
|
import { format } from "date-fns";
|
2024-12-17 14:27:47 +00:00
|
|
|
import { Link } from "@/components/navigation";
|
2024-12-11 18:28:57 +00:00
|
|
|
|
|
|
|
|
const columns: ColumnDef<any>[] = [
|
|
|
|
|
{
|
|
|
|
|
accessorKey: "no",
|
|
|
|
|
header: "No",
|
|
|
|
|
cell: ({ row }) => (
|
|
|
|
|
<div className="flex items-center gap-5">
|
|
|
|
|
<div className="flex-1 text-start">
|
|
|
|
|
<h4 className="text-sm font-medium text-default-600 whitespace-nowrap mb-1">
|
|
|
|
|
{row.getValue("no")}
|
|
|
|
|
</h4>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
accessorKey: "title",
|
|
|
|
|
header: "Judul",
|
|
|
|
|
cell: ({ row }) => (
|
|
|
|
|
<div className="flex items-center gap-5">
|
|
|
|
|
<div className="flex-1 text-start">
|
|
|
|
|
<h4 className="text-sm font-medium text-default-600 whitespace-nowrap mb-1">
|
|
|
|
|
{row.getValue("title")}
|
|
|
|
|
</h4>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
accessorKey: "createdAt",
|
|
|
|
|
header: "Tanggal Unggah ",
|
2024-12-16 14:05:10 +00:00
|
|
|
cell: ({ row }) => {
|
|
|
|
|
const createdAt = row.getValue("createdAt") as
|
|
|
|
|
| string
|
|
|
|
|
| number
|
|
|
|
|
| undefined;
|
|
|
|
|
|
|
|
|
|
const formattedDate =
|
|
|
|
|
createdAt && !isNaN(new Date(createdAt).getTime())
|
|
|
|
|
? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss")
|
|
|
|
|
: "-";
|
|
|
|
|
return <span className="whitespace-nowrap">{formattedDate}</span>;
|
|
|
|
|
},
|
2024-12-11 18:28:57 +00:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
accessorKey: "isActive",
|
|
|
|
|
header: "Status",
|
|
|
|
|
cell: ({ row }) => {
|
|
|
|
|
const isActive = row.getValue<boolean>("isActive");
|
|
|
|
|
console.log("isActive value:", isActive); // TypeScript type is inferred correctly
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
{isActive ? (
|
2025-01-06 14:06:02 +00:00
|
|
|
<b className="text-blue-500">Terkirim</b>
|
2024-12-11 18:28:57 +00:00
|
|
|
) : (
|
|
|
|
|
<b className="text-danger">Belum Terkirim</b>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "actions",
|
|
|
|
|
accessorKey: "action",
|
|
|
|
|
header: "Actions",
|
|
|
|
|
enableHiding: false,
|
|
|
|
|
cell: ({ row }) => {
|
|
|
|
|
return (
|
|
|
|
|
<DropdownMenu>
|
|
|
|
|
<DropdownMenuTrigger asChild>
|
|
|
|
|
<Button
|
|
|
|
|
size="icon"
|
|
|
|
|
className="bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent"
|
|
|
|
|
>
|
|
|
|
|
<span className="sr-only">Open menu</span>
|
|
|
|
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
|
|
|
|
</Button>
|
|
|
|
|
</DropdownMenuTrigger>
|
|
|
|
|
<DropdownMenuContent className="p-0" align="end">
|
2024-12-17 14:27:47 +00:00
|
|
|
<Link
|
|
|
|
|
href={`/contributor/planning/medsos-mediahub/publish/${row.original.id}`}
|
|
|
|
|
>
|
|
|
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
|
|
|
|
<Eye className="w-4 h-4 me-1.5" />
|
|
|
|
|
Publish
|
|
|
|
|
</DropdownMenuItem>
|
|
|
|
|
</Link>
|
|
|
|
|
|
2024-12-11 18:28:57 +00:00
|
|
|
<DropdownMenuItem className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none">
|
|
|
|
|
<Trash2 className="w-4 h-4 me-1.5" />
|
|
|
|
|
Delete
|
|
|
|
|
</DropdownMenuItem>
|
|
|
|
|
</DropdownMenuContent>
|
|
|
|
|
</DropdownMenu>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export default columns;
|