"use client"; import { ColumnDef } from "@tanstack/react-table"; import { Eye, MoreVertical, MoveDownRight, SquarePen, Trash2, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { format } from "date-fns"; import { Link } from "@/components/navigation"; import { useTranslations } from "next-intl"; import withReactContent from "sweetalert2-react-content"; import Swal from "sweetalert2"; const useTableColumns = () => { const t = useTranslations("Table"); // Panggil di dalam hook const MySwal = withReactContent(Swal); const columns: ColumnDef[] = [ { accessorKey: "no", header: t("no"), cell: ({ row }) => (

{row.getValue("no")}

), }, { accessorKey: "contentTitle", header: t("title"), cell: ({ row }: { row: { getValue: (key: string) => string } }) => { const title: string = row.getValue("contentTitle"); return ( {title.length > 50 ? `${title.slice(0, 30)}...` : title} ); }, }, { accessorKey: "contentTag", header: t("tag"), cell: ({ row }) => ( {row.getValue("contentTag")} ), }, { accessorKey: "contentType", header: t("type-content"), cell: ({ row }) => ( {row.getValue("contentType")} ), }, { accessorKey: "contentCreatedGroupBy", header: t("source"), cell: ({ row }) => ( {row.getValue("contentCreatedGroupBy")} ), }, { accessorKey: "isPublish", header: "Status", cell: ({ row }) => { const isPublish = row.getValue("isPublish"); return (
); }, }, { accessorKey: "contentCreatedDate", header: t("upload-date"), cell: ({ row }) => { const createdAt = row.getValue("contentCreatedDate") as | string | number | undefined; const formattedDate = createdAt && !isNaN(new Date(createdAt).getTime()) ? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss") : "-"; return {formattedDate}; }, }, { id: "actions", accessorKey: "action", header: "Actions", enableHiding: false, cell: ({ row }) => { const isDisabled = row.original.isPublish; // Check the isPublish value return ( Pindah Ke Mediahub ); }, }, ]; return columns; }; export default useTableColumns;