import z from 'zod';

export const LoyaltyCollectType = {
  Collect: 0,
  OutOfStock: 1,
  Cancel: 2,
} as const;

const ALL_FLAGS = Object.values(LoyaltyCollectType).reduce<number>(
  (a, b) => a | b,
  0,
);

export const LoyaltyCollectTypeSchema = z
  .nativeEnum(LoyaltyCollectType)
  .refine((val) => (val & ALL_FLAGS) === val, {
    message: 'Invalid loyalty collect type',
  })
  .describe('Loyalty collect type');

export type LoyaltyCollectType = z.infer<typeof LoyaltyCollectTypeSchema>;
