import {
  Shield,
  DollarSign,
  ClipboardList,
  CalendarIcon,
  CheckSquare,
  User,
} from "lucide-react";

export const columns: ColumnDefinition[] = [
  {
    key: "id",
    title: "ID",
    type: "text",
    icon: Shield,
    sortable: true,
    searchable: true,
    filterable: true,
    description: "Unique reward identifier",
    priority: 3,
    expandedOnly: true, // less important
  },
  {
    key: "referrer",
    idKey: "id",
    labelKey: "name",
    title: "Referrer",
    type: "select",
    baseKey: "referrerId",
    sortKey: "referrer.firstName",
    expandedTitle: (row) => `Referrer: ${row.id}`,
    icon: User,
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "User who referred",
    apiEndpoint: {
      url: "/api/admin/crm/user/options",
      method: "GET",
    },
    render: {
      type: "compound",
      config: {
        image: {
          key: "avatar",
          fallback: "/img/placeholder.svg",
          type: "image",
          title: "Avatar",
          description: "User's profile picture",
          filterable: false,
          sortable: false,
        },
        primary: {
          key: ["firstName", "lastName"],
          title: ["First Name", "Last Name"],
          icon: User,
          editable: false,
          usedInCreate: false,
          sortable: true,
          searchable: true,
          filterable: true,
          sortKey: "firstName",
        },
        secondary: {
          key: "email",
          title: "Email",
          editable: false,
          usedInCreate: false,
          sortable: true,
          searchable: true,
          filterable: true,
          sortKey: "email",
        },
      },
    },
    priority: 1,
  },
  {
    key: "condition",
    title: "Condition",
    type: "custom",
    icon: ClipboardList,
    sortable: true,
    searchable: true,
    filterable: true,
    description: "Associated condition",
    render: (value: any, row: any) => {
      const condition = row?.condition || value;
      return condition ? condition.title : "N/A";
    },
    priority: 1,
  },
  {
    key: "reward",
    title: "Reward",
    type: "number",
    icon: DollarSign,
    sortable: true,
    searchable: false,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Reward amount",
    priority: 1,
  },
  {
    key: "isClaimed",
    title: "Claimed",
    type: "boolean",
    icon: CheckSquare,
    sortable: true,
    searchable: true,
    filterable: true,
    editable: true,
    usedInCreate: true,
    description: "Claim status",
    priority: 1,
  },
  {
    key: "createdAt",
    title: "Created At",
    type: "date",
    icon: CalendarIcon,
    sortable: true,
    searchable: true,
    filterable: true,
    description: "Reward creation date",
    render: { type: "date", format: "PPP" },
    priority: 2,
    expandedOnly: true, // less important
  },
];
