import { ColumnDef } from "@tanstack/react-table";
import { format } from "date-fns-tz";

// This type is used to define the shape of our data.
// You can use a Zod schema here if you want.
export type Adjustmnets = {
    siloAdjust_id: string;
    currentStockLevel: string;
    newLevel: number;
    dateAdjusted: string;
    lastDateAdjusted: string;
    comment: string;
    commentAddedBy: string;
    commentDate: string;
    add_user: string;
};

export const columns: ColumnDef<Adjustmnets>[] = [
    {
        accessorKey: "MachineLocation",
        header: () => <div className="text-left">Line</div>,
    },
    {
        accessorKey: "ArticleHumanReadableId",
        header: "AV",
    },
    {
        accessorKey: "RunningNumber",
        header: "Label",
    },
    {
        accessorKey: "ProductionDate",
        header: "Booked in",
        cell: ({ row }) => {
            if (row.getValue("ProductionDate")) {
                const correctDate = format(
                    row.getValue("ProductionDate"),
                    "M/d/yyyy HH:mm"
                );
                return (
                    <div className="text-left font-medium">{correctDate}</div>
                );
            }
        },
    },
];
