import {
  EntityContainerSchema,
  PriceSchema,
  TouchBaseSchema,
} from '@isa/common/data-access';
import { z } from 'zod';
import { AvailabilityTypeSchema } from './availability-type.schema';
import { DateRangeSchema } from './data-range.schema';
import { LogisticianSchema } from './logistician.schema';
import { SupplierSchema } from './supplier.schema';

export const AvailabilitySchema = z
  .object({
    availabilityType: AvailabilityTypeSchema.describe('Availability type').optional(),
    estimatedDelivery: DateRangeSchema.describe('Estimated delivery').optional(),
    estimatedShippingDate: z.string().describe('EstimatedShipping date').optional(),
    inStock: z.number().describe('Whether item is in stock').optional(),
    isPrebooked: z.boolean().describe('Whether prebooked').optional(),
    lastRequest: z.string().describe('Last request').optional(),
    logistician: EntityContainerSchema(LogisticianSchema).describe('Logistician information').optional(),
    price: PriceSchema.describe('Price information').optional(),
    requestReference: z.string().describe('Request reference').optional(),
    shopItem: EntityContainerSchema(z.any()).describe('Shop item information').optional(),
    ssc: z.string().describe('Ssc').optional(),
    sscText: z.string().describe('Ssc text').optional(),
    supplier: EntityContainerSchema(SupplierSchema).describe('Supplier information').optional(),
    supplierInfo: z.string().describe('Supplier info').optional(),
    supplierProductNumber: z.string().describe('SupplierProduct number').optional(),
    supplierSSC: z.string().describe('Supplier s s c').optional(),
    supplierSSCText: z.string().describe('Supplier s s c text').optional(),
    supplyChannel: z.string().describe('Supply channel').optional(),
  })
  .extend(TouchBaseSchema.shape);

export type Availability = z.infer<typeof AvailabilitySchema>;
