import { objectId } from '@jig-software/zod-bson';
import { z } from 'zod';
import { LeaveInit } from './Leave';

export const LeaveCancellationStatus = z.enum([
  'pending',
  'approved',
  'rejected',
  'canceled',
]);

export type LeaveCancellationStatus = z.infer<typeof LeaveCancellationStatus>;

export const LeaveCancellation = z.object({
  _id: objectId(),
  leaves: z.array(LeaveInit.extend({ _id: objectId() })).min(1),
  status: LeaveCancellationStatus,
  applyRemarks: z.string().nullish(),
  approveRemarks: z.string().nullish(),
  rejectRemarks: z.string().nullish(),
  cancelRemarks: z.string().nullish(),
  appliedBy: objectId(),
  canceledAt: z.date().nullish(), // TODO: Implement cancel
  canceledBy: objectId().nullish(), // TODO: Implement cancel
  rejectedAt: z.date().nullish(),
  rejectedBy: objectId().nullish(),
  approvedAt: z.date().nullish(),
  approvedBy: objectId().nullish(),
  createdAt: z.date(),
  updatedAt: z.date(),
});

export type LeaveCancellation = z.infer<typeof LeaveCancellation>;
