117 lines
3.3 KiB
TypeScript
117 lines
3.3 KiB
TypeScript
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 { Link, useRouter } from "@/i18n/routing";
|
|
import { format } from "date-fns";
|
|
import header from "@/components/partials/header";
|
|
import { date } from "zod";
|
|
|
|
const columns: ColumnDef<any>[] = [
|
|
{
|
|
accessorKey: "no",
|
|
header: "No",
|
|
cell: ({ row }) => <span>{row.getValue("no")}</span>,
|
|
},
|
|
{
|
|
accessorKey: "createdAt",
|
|
header: "Tanggal",
|
|
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>;
|
|
},
|
|
},
|
|
{
|
|
accessorKey: "createdByCategory",
|
|
header: "Jenis Akun",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("createdByCategory")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "createdByUsername",
|
|
header: "UserName",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("createdByUsername")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "accessFrequency",
|
|
header: "Akses Mediahub",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("accessFrequency")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "uiExperienceDesign",
|
|
header: "Tampilan Desain Web",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("uiExperienceDesign")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "uiExperienceNavigation",
|
|
header: "Kemudahan Navigasi",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">
|
|
{row.getValue("uiExperienceNavigation")}
|
|
</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "uiExperienceSpeed",
|
|
header: "Kecepatan Akses",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("uiExperienceSpeed")}</span>
|
|
),
|
|
},
|
|
{
|
|
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"
|
|
>
|
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent className="p-0" align="end">
|
|
<Link href={`/admin/survey/detail/${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 mt-1" />
|
|
View
|
|
</DropdownMenuItem>
|
|
</Link>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
},
|
|
},
|
|
];
|
|
|
|
export default columns;
|