141 lines
4.0 KiB
TypeScript
141 lines
4.0 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 { formatDateToIndonesian } from "@/utils/globals";
|
|
import { Link, useRouter } from "@/i18n/routing";
|
|
|
|
import { setBanner } from "@/service/settings/settings";
|
|
import { error } from "@/config/swal";
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
|
|
const columns: ColumnDef<any>[] = [
|
|
{
|
|
accessorKey: "no",
|
|
header: "No",
|
|
cell: ({ row }) => <span>{row.getValue("no")}</span>,
|
|
},
|
|
|
|
{
|
|
accessorKey: "fullname",
|
|
header: "Nama",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("fullname")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "username",
|
|
header: "Username",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">
|
|
{row.original?.userKeycloak?.username || ""}
|
|
</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "phoneNumber",
|
|
header: "No. HP",
|
|
cell: ({ row }) => <span>{row.getValue("phoneNumber")}</span>,
|
|
},
|
|
{
|
|
accessorKey: "email",
|
|
header: "Email",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.getValue("email")}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "level",
|
|
header: "Level Pengguna",
|
|
cell: ({ row }) => (
|
|
<span className="normal-case">{row.original?.role?.name || ""}</span>
|
|
),
|
|
},
|
|
{
|
|
accessorKey: "createdAt",
|
|
header: "Tanggal Unggah",
|
|
cell: ({ row }) => (
|
|
<span>{formatDateToIndonesian(row.getValue("createdAt"))}</span>
|
|
),
|
|
},
|
|
|
|
{
|
|
accessorKey: "isActive",
|
|
header: "Status",
|
|
cell: ({ row }) => (
|
|
<span
|
|
className={
|
|
row.getValue("isActive") ? "text-success" : "text-destructive"
|
|
}
|
|
>
|
|
{row.getValue("isActive") ? "Aktif" : "Belum Aktif"}
|
|
</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">
|
|
<a>Aktivasi</a>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
|
|
<Link
|
|
href={`/admin/management-user/external/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">
|
|
<Link
|
|
href={`/admin/management-user/external/detail/${row.original.id}`}
|
|
>
|
|
Edit
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
color="red"
|
|
className="p-2 border-b text-red-500 group focus:bg-red-500 focus:text-white rounded-none"
|
|
>
|
|
<a onClick={() => {}}>Hapus</a>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
},
|
|
},
|
|
];
|
|
|
|
export default columns;
|