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"; import { format } from "date-fns"; import { Link } from "@/components/navigation"; import { useTranslations } from "next-intl"; const useTableColumns = () => { const t = useTranslations("Table"); // Panggil di dalam hook const columns: ColumnDef[] = [ { accessorKey: "no", header: t("no", { defaultValue: "No" }), cell: ({ row }) => (

{row.getValue("no")}

), }, { accessorKey: "title", header: t("title", { defaultValue: "Title" }), cell: ({ row }) => (

{row.getValue("title")}

), }, { accessorKey: "createdAt", header: t("upload-date", { defaultValue: "Upload Date" }), 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 {formattedDate}; }, }, { accessorKey: "isActive", header: "Status", cell: ({ row }) => { const isActive = row.getValue("isActive"); console.log("isActive value:", isActive); // TypeScript type is inferred correctly return (
{isActive ? ( Terkirim ) : ( Belum Terkirim )}
); }, }, { id: "actions", accessorKey: "action", header: t("action", { defaultValue: "Action" }), enableHiding: false, cell: ({ row }) => { return ( Publish Delete ); }, }, ]; return columns; }; export default useTableColumns;