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

// 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 notifyColumns: ColumnDef<Adjustmnets>[] = [
    {
        accessorKey: "name",
        header: () => <div className="text-left">Name</div>,
    },
    {
        accessorKey: "description",
        header: "Description",
        cell: ({ row }) => {
            return (
                <div className="text-left font-medium">
                    <p className="max-w-48 text-pretty">
                        {row.getValue("description")}
                    </p>
                </div>
            );
        },
    },

    {
        accessorKey: "checkInterval",
        header: "Check Interval",
    },
    {
        accessorKey: "timeType",
        header: "Time tpye",
    },
    {
        accessorKey: "emails",
        header: "Emails",
    },
    {
        accessorKey: "active",
        header: "Active",
    },
    {
        accessorKey: "lastRan",
        header: "Last Ran",
        cell: ({ row }) => {
            if (row.getValue("lastRan")) {
                const correctDate = format(
                    row.getValue("lastRan"),
                    "M/d/yyyy hh:mm"
                );
                return (
                    <div className="text-left font-medium">{correctDate}</div>
                );
            }
        },
    },
];
