diff --git a/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx b/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx index 8188430f..36960b28 100644 --- a/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx @@ -15,7 +15,7 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; -import { format } from "date-fns"; +import { format, parseISO } from "date-fns"; import { Link } from "@/components/navigation"; import { useTranslations } from "next-intl"; import withReactContent from "sweetalert2-react-content"; @@ -118,21 +118,43 @@ const useTableColumns = () => { ); }, }, + // { + // accessorKey: "contentCreatedDate", + // header: t("upload-date", { defaultValue: "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}; + // }, + // }, { accessorKey: "contentCreatedDate", header: t("upload-date", { defaultValue: "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") - : "-"; + const createdAt = row.getValue("contentCreatedDate") as string | null; + + if (!createdAt) return -; + + // parse ISO string dari API (UTC) + const date = parseISO(createdAt); + + // geser balik dengan timezoneOffset supaya yang tampil = UTC + const utcDate = new Date( + date.getTime() + date.getTimezoneOffset() * 60000 + ); + + const formattedDate = format(utcDate, "dd-MM-yyyy HH:mm:ss"); + return {formattedDate}; }, }, + { id: "actions", accessorKey: "action",