import { pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema } from "drizzle-zod";
import type { z } from "zod";

export const dockDoorScans = pgTable("dock_door_scans", {
	id: uuid("id").defaultRandom().primaryKey(),
	dockId: text("dock_id").notNull(),
	loadingOrder: text("loading_order").notNull(),
	loadingUnit: text("loading_Unit"), // can be running number or sscc depending on where it came from
	loadingUnitStatus: text("loading_unit_status").default("loaded"), // TODO: add enums on the status of each load.
	message: text("message"), // the response it gave when scanning
	status: text("status").default("active"), // TODO: add in enums for this
	add_date: timestamp("add_date", { withTimezone: true }).defaultNow(),
	add_user: text("add_user").default("lst-system"),
	upd_date: timestamp("upd_date", { withTimezone: true }).defaultNow(),
	upd_user: text("upd_user").default("lst-system"),
});

export const dockDoorScansSchema = createSelectSchema(dockDoorScans);
export const newDockDoorScansSchema = createInsertSchema(dockDoorScans);

export type DockDoorScans = z.infer<typeof dockDoorScansSchema>;
export type NewDockDoorScans = z.infer<typeof newDockDoorScansSchema>;
