"use client";

import Link from "next/link";
import { ColumnDef } from "@tanstack/react-table";
import { DataTable } from "@/components/admin/custom ui/DataTable";

const data: Inventories[] = [
  {
    id: "1",
    product: "Laptop Dell",
    quantity: 0,
    purchase_cost: 500,
    selling_price: 1000,
  },
  {
    id: "2",
    product: "PlayStation",
    quantity: 5,
    purchase_cost: 200,
    selling_price: 500,
  },
  {
    id: "3",
    product: "Mobile Samsung Galaxy S23",
    quantity: 2,
    purchase_cost: 300,
    selling_price: 700,
  },
  {
    id: "4",
    product: "Gaming PC",
    quantity: 2,
    purchase_cost: 1000,
    selling_price: 2000,
  },
  {
    id: "5",
    product: "Mac",
    quantity: 2,
    purchase_cost: 1500,
    selling_price: 3000,
  },
  {
    id: "6",
    product: "Smart Watch",
    quantity: 4,
    purchase_cost: 100,
    selling_price: 200,
  },
  {
    id: "7",
    product: "XBox",
    quantity: 12,
    purchase_cost: 200,
    selling_price: 500,  
  },
  {
    id: "8",
    product: "IPad",
    quantity: 8,
    purchase_cost: 500,
    selling_price: 1000,
  },
];

type Inventories = {
  id: string;
  product: string;
  quantity: number;
  purchase_cost: number;
  selling_price: number;
};

export const columns: ColumnDef<Inventories>[] = [
  {
    accessorKey: "id",
    header: "ID",
  },
  {
    accessorKey: "product",
    header: "Product",
    cell: ({ row }) => (
      <Link
        href={`/admin/inventory/${row.original.id}`}
        className="text-primary"
      >
        <p>{row.original.product}</p>
      </Link>
    ),
  },
  {
    accessorKey: "quantity",
    header: "Quantity",
  },
  {
    accessorKey: "purchase_cost",
    header: "Purchase Cost",
  },
  {
    accessorKey: "selling_price",
    header: "Selling Price",
  },
];

const LowInventories = () => {
  return (
    <div className="w-full">
      <DataTable
        data={data}
        columns={columns}
        searchKey="product"
        pagination={4}
      ></DataTable>
    </div>
  );
}

export default LowInventories;
