import mongoose, { Document } from 'mongoose';

import { MODEL_NAMES } from './_models';

export interface ICalendarDay {
  date: string;
  workingDay: boolean;
  publicHoliday: boolean;
  publicHolidayDescription: string;
  weekendDay: boolean;
  customDate: boolean;
  customDateDescription: string;
}

export interface ICalendarDayDoc extends Document, ICalendarDay {
}

export const CalendarDaySchema = new mongoose.Schema(
  {
    date: {
      type: String,
      required: true,
    },
    calendarType: {
      type: String,
      required: true,
      default: 'US'
    },
    workingDay: {
      type: Boolean,
      default: false,
    },
    publicHoliday: {
      type: Boolean,
      default: false,
    },
    publicHolidayDescription: {
      type: String,
      default: '',
    },
    weekendDay: {
      type: Boolean,
      default: false,
    },
    customDate: {
      type: Boolean,
      default: false,
    },
    customDateDescription: {
      type: String,
      default: '',
    },
    __v: {
      type: Number,
      select: false
    },
  },
  { timestamps: false }
);

export default mongoose.model<ICalendarDayDoc>(MODEL_NAMES.calendarDays, CalendarDaySchema);
