import {
  AddressSchema,
  EntityContainerSchema,
  LabelSchema,
} from '@isa/common/data-access';
import { z } from 'zod';
import { BranchType } from '../models';

export const BranchSchema = z.object({
  id: z.number().describe('Unique identifier').optional(),
  createdAt: z.string().describe('Creation timestamp').optional(),
  modifiedAt: z.string().describe('Modified at').optional(),
  address: AddressSchema.describe('Branch physical address').optional(),
  branchNumber: z.string().describe('Branch number identifier').optional(),
  branchType: z.nativeEnum(BranchType).describe('Branch type classification').optional(),
  isDefault: z.string().describe('Whether this is the default branch').optional(),
  isOnline: z.boolean().describe('Whether branch is online').optional(),
  isOrderingEnabled: z.boolean().describe('Whether ordering is enabled for this branch').optional(),
  isShippingEnabled: z.boolean().describe('Whether shipping is enabled for this branch').optional(),
  key: z.string().describe('Unique branch key identifier').optional(),
  label: EntityContainerSchema(LabelSchema).describe('Branch label information'),
  name: z.string().describe('Branch name').optional(),
  parent: EntityContainerSchema(
    z.lazy((): z.ZodType<any> => BranchSchema),
  ).describe('Parent branch entity').optional(),
  shortName: z.string().describe('Branch short name').optional(),
});

export type Branch = z.infer<typeof BranchSchema>;
