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";

const columns: ColumnDef<any>[] = [
  {
    accessorKey: "no",
    header: "No",
    cell: ({ row }) => <span>{row.getValue("no")}</span>,
  },

  {
    accessorKey: "title",
    header: "Judul",
    cell: ({ row }) => (
      <span className="normal-case">{row.getValue("title")}</span>
    ),
  },
  {
    accessorKey: "sendTime",
    header: "Tanggal & Waktu",
    cell: ({ row }) => <span>{row.getValue("sendTime")}</span>,
  },

  {
    accessorKey: "status",
    header: "Status",
    cell: ({ row }) => (
      <Badge
        className={`text-center items-center text-white ${
          row.getValue("status") == "done"
            ? "bg-blue-500"
            : row.getValue("status") == "waiting"
            ? "bg-yellow-400"
            : "bg-red-600"
        }`}
      >
        {row.getValue("status") == "done"
          ? "Selesai"
          : row.getValue("status") == "waiting"
          ? "Proses"
          : "Gagal"}
      </Badge>
    ),
  },

  {
    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">
            <DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
              <Link
                href={`/admin/broadcast/campaign-list/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/broadcast/campaign-list/edit/${row.original.id}`}
              >
                Edit
              </Link>
            </DropdownMenuItem>
            <DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
              <a>Delete</a>
            </DropdownMenuItem>
          </DropdownMenuContent>
        </DropdownMenu>
      );
    },
  },
];

export default columns;
