import { addDays } from 'date-fns';

import { type PolicyTypes } from 'src/types/vacations';

export const handleMinDate = (policy: PolicyTypes) => {
  const today = new Date();

  return policy?.minimumAdvanceDays
    ? addDays(today, policy.minimumAdvanceDays)
    : today;
};

export const shouldUpdateToDate = (fromDate: Date, toDate: Date) => {
  return (fromDate && !toDate) || fromDate > toDate;
};
