import { Badge } from "@repo/shadcn/badge";

import { ColumnDef } from '@tanstack/react-table';
import { CellAction } from './cell-action';
import { InventoryTable } from '../../../schemas/inventory';

export const columns: ColumnDef<InventoryTable>[] = [
  {
    accessorKey: 'urlImg',
    header: 'img',
    cell: ({ row }) => {
      return (
        <img src={`/uploads/inventory/${row.original.userId}/${row.original.id}/${row.original.urlImg}`} alt="" width={64} height={64} className="rounded" />
      )
    },
  },
  {
    accessorKey: 'title',
    header: 'Producto',
  },
  {
    accessorKey: "description",
    header: "Descripcion",
    cell: ({ row }) => row.original.description.length > 40 ?
      `${row.original.description.slice(0, 40)}...` : row.original.description
  },
  {
    accessorKey: 'price',
    header: 'Precio',
    cell: ({ row }) => `${row.original.price} Bs.`
  },
  {
    accessorKey: 'stock',
    header: 'Stock',
  },
  {
    accessorKey: 'status',
    header: 'Estado',
  },
  {
    id: 'actions',
    header: 'Acciones',
    cell: ({ row }) => <CellAction data={row.original} />,
  },
];
