import { z } from "zod";

const productSchema = z.object({
  upc: z.string(),
  name: z.string(),
});

const homeLocationSchema = z.object({
  name: z.string(), // location/placement, eg: "A1", "G2", etc
  products: z.array(productSchema),
});

const planogramSchema = z.object({
  pk: z.number(),
  name: z.string(),
  date_start: z.string(),
  date_end: z.string().nullable(),
  horizontal_section_thresholds: z.array(z.string()), // row letters after which a horizontal gap occurs, eg: ["C", "G"]
});

export const planogramLocationsResponseSchema = z.object({
  planogram: planogramSchema,
  home_locations: z.array(homeLocationSchema),
});

export type IProduct = z.infer<typeof productSchema>;
export type IHomeLocation = z.infer<typeof homeLocationSchema>;
export type IPlanogram = z.infer<typeof planogramSchema>;
export type IPlanogramLocationsResponse = z.infer<typeof planogramLocationsResponseSchema>;

export interface RestructuredLocationData {
  [locationName: string]: IProduct[];
}

export interface GridCell {
  locationName: string;
  isDisabled: boolean;
  hasSectionGapRight: boolean;
  hasSectionGapBottom: boolean;
  upcs: string[];
}

export interface MintedUpcPickerKwargs {
  pog_name: string;
}
