import { Shield, ClipboardList, CheckSquare, ImageIcon } from "lucide-react";
import { format } from "date-fns";

export const columns: ColumnDefinition[] = [
  // Hidden by default
  {
    key: "id",
    title: "ID",
    type: "text",
    icon: Shield,
    sortable: true,
    searchable: true,
    filterable: true,
    description: "Unique discount identifier",
    priority: 3,
    expandedOnly: true,
  },
  {
    key: "product",
    idKey: "id",
    labelKey: "name",
    title: "Product",
    baseKey: "productId",
    sortKey: "product.name",
    disablePrefixSort: true,
    type: "select",
    apiEndpoint: {
      url: "/api/admin/ecommerce/product/options",
      method: "GET",
    },
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Product details",
    render: {
      type: "compound",
      config: {
        image: {
          key: "image",
          title: "Image",
          type: "image",
          fallback: "/img/placeholder.svg",
          icon: ImageIcon,
          sortable: false,
          searchable: false,
          filterable: false,
          description: "Product image URL",
        },
        primary: {
          key: "name",
          title: "Name",
          type: "text",
          sortable: true,
          searchable: true,
          filterable: true,
          description: "Product name",
        },
        secondary: {
          key: "slug",
          title: "Slug",
          type: "text",
          sortable: true,
          searchable: true,
          filterable: true,
          description: "URL-friendly slug",
        },
      },
    },
  },
  {
    key: "code",
    title: "Code",
    type: "text",
    icon: ClipboardList,
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Discount code",
    priority: 1,
  },
  {
    key: "percentage",
    title: "Percentage",
    type: "number",
    icon: ClipboardList,
    sortable: true,
    searchable: false,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Discount percentage",
    priority: 1,
  },
  {
    key: "validUntil",
    title: "Valid Until",
    type: "date",
    icon: ClipboardList,
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Expiration date",
    render: { type: "date", format: "PPP" },
    priority: 1,
  },
  {
    key: "status",
    title: "Status",
    type: "boolean",
    icon: CheckSquare,
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Discount status",
    priority: 1,
  },
];
