96 lines
2.7 KiB
TypeScript
96 lines
2.7 KiB
TypeScript
import * as React from "react";
|
|
import { ColumnDef } from "@tanstack/react-table";
|
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuTrigger,
|
|
DropdownMenuItem,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
formatDateToIndonesian,
|
|
getOnlyDate,
|
|
htmlToString,
|
|
} from "@/utils/globals";
|
|
import { Link, useRouter } from "@/i18n/routing";
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
import { setBanner } from "@/service/service/settings/settings";
|
|
|
|
const columns: ColumnDef<any>[] = [
|
|
{
|
|
accessorKey: "no",
|
|
header: "No",
|
|
cell: ({ row }) => <span>{row.getValue("no")}</span>,
|
|
},
|
|
|
|
{
|
|
accessorKey: "title",
|
|
header: "Judul",
|
|
cell: ({ row }) => <span>{row.getValue("title")}</span>,
|
|
},
|
|
{
|
|
accessorKey: "categoryName",
|
|
header: "Kategori",
|
|
cell: ({ row }) => <span>{row.getValue("categoryName")}</span>,
|
|
},
|
|
{
|
|
accessorKey: "createdAt",
|
|
header: "Tanggal Unggah",
|
|
cell: ({ row }) => (
|
|
<span>{formatDateToIndonesian(row.getValue("createdAt"))}</span>
|
|
),
|
|
},
|
|
|
|
{
|
|
accessorKey: "statusName",
|
|
header: "Status",
|
|
cell: ({ row }) => <span>{row.getValue("statusName")}</span>,
|
|
},
|
|
|
|
{
|
|
id: "actions",
|
|
accessorKey: "action",
|
|
header: "Actions",
|
|
enableHiding: false,
|
|
cell: ({ row }) => {
|
|
const { toast } = useToast();
|
|
|
|
const handleBanner = async (id: number) => {
|
|
const response = setBanner(id, true);
|
|
toast({
|
|
title: "Success",
|
|
});
|
|
};
|
|
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">
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
|
<Link
|
|
href={`/contributor/content/image/detail/${row.original.id}`}
|
|
>
|
|
Detail
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
|
<a onClick={() => handleBanner(row.original.id)}>
|
|
Jadikan Banner
|
|
</a>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
},
|
|
},
|
|
];
|
|
|
|
export default columns;
|