115 lines
2.5 KiB
TypeScript
115 lines
2.5 KiB
TypeScript
import { InputType, Int, Field, ArgsType, ObjectType } from 'type-graphql';
|
|
import { IsDate, IsMilitaryTime } from 'class-validator';
|
|
import { DateTime } from 'luxon';
|
|
|
|
@ObjectType()
|
|
@InputType('ScheduleInput')
|
|
export class ScheduleComponent {
|
|
@Field(() => [[String]], { nullable: true })
|
|
mon?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
tue?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
wed?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
thu?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
fri?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
sat?: string[][];
|
|
@Field(() => [[String]], { nullable: true })
|
|
sun?: string[][];
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('HoursInput')
|
|
export class HourComponent {
|
|
@Field()
|
|
from: string;
|
|
@Field()
|
|
to: string;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('DateRangeComponentInput')
|
|
@ArgsType()
|
|
export class DateRangeComponent {
|
|
@Field()
|
|
@IsDate()
|
|
startDate: Date;
|
|
@Field()
|
|
@IsDate()
|
|
endDate: Date;
|
|
}
|
|
|
|
export class DateTimeRangeComponent {
|
|
startDate: DateTime;
|
|
endDate: DateTime;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('SlotAvailablityInput')
|
|
export class SlotAvailablity {
|
|
@Field()
|
|
@IsDate()
|
|
date: Date;
|
|
|
|
@Field(() => [String])
|
|
slots: string[];
|
|
}
|
|
|
|
@ArgsType()
|
|
export class SlotAvailablityRequest extends DateRangeComponent {
|
|
@Field(() => Int)
|
|
interval: number;
|
|
|
|
@Field(() => Int)
|
|
duration: number;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('SlotComponentInput')
|
|
export class SlotComponent {
|
|
@Field()
|
|
@IsDate()
|
|
startDate: Date;
|
|
|
|
@Field()
|
|
@IsDate()
|
|
endDate: Date;
|
|
|
|
@Field()
|
|
@IsMilitaryTime()
|
|
startTime: string;
|
|
|
|
@Field()
|
|
@IsMilitaryTime()
|
|
endTime: string;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('BaseAvailabilityComponentInput')
|
|
export class BaseAvailabilityComponent {
|
|
@Field(() => DateRangeComponent)
|
|
dates: DateRangeComponent;
|
|
@Field(() => [HourComponent], { nullable: true })
|
|
hours?: HourComponent[];
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('DateExceptionComponentInput')
|
|
export class DateExceptionComponent extends BaseAvailabilityComponent {
|
|
@Field({ nullable: true })
|
|
allDay?: boolean;
|
|
}
|
|
|
|
@ObjectType()
|
|
@InputType('AvailabilityInput')
|
|
export class AvailabilityComponent extends BaseAvailabilityComponent {
|
|
@Field(() => [DateExceptionComponent], { nullable: true })
|
|
exceptions?: DateExceptionComponent[];
|
|
|
|
@Field({ nullable: true })
|
|
noWeekend?: boolean;
|
|
}
|