oralify-common
Version:
Public shared repository for Oralify
134 lines (122 loc) • 3.47 kB
text/typescript
import { ServiceType } from './serviceType';
import { UserConciseType } from './userTypes';
import { palette } from '../utils/design';
export enum RecurrenceKey {
Daily = 'Daily',
Weekly = 'Weekly',
Monthly = 'Monthly',
Yearly = 'Yearly'
}
export enum TimeslotStatus {
'booked' = 'booked',
'pending' = 'pending',
'confirmed' = 'confirmed',
'cancelled' = 'cancelled', //cancelled already
'unavailable' = 'unavailable', //set manually to unavailable
'available' = 'available'
}
export enum DayKey {
Monday = 'Monday',
Tuesday = 'Tuesday',
Wednesday = 'Wednesday',
Thursday = 'Thursday',
Friday = 'Friday',
Saturday = 'Saturday',
Sunday = 'Sunday'
}
/** Used to generate Timeslots*/
export type AvailabilitySettingsType = {
id?: string;
expertId?: string;
startTime: string; //09:30 or 9 or Date
endTime: string; //15:30 or 14 or Date
dayOfWeek: DayKey[];
recurrence?: RecurrenceKey; //defautlts to RecurrenceKey.weekly
repeatEvery?: number; // defaults to 1
breakTime?: number; //min, defaults to 0 (max 60min)
isAvailable?: boolean; //Make profile visible or not
name?: string; //further customization
color?: string; //further customization
};
export type TimeSlotType = {
id?: string;
availabilityId?: string;
creationDate: Date;
serviceId: string;
expertId: string;
price: number; // from service
startTime: Date;
endTime?: Date; // get from @startTime+ Service duration + 30 default
status?: TimeslotStatus; //defaults to TimeslotStatus.available
};
export type ShownTimeSlotType = TimeSlotType & {
expertUser: UserConciseType;
service: ServiceType;
};
interface StatusInfo {
color: string;
icon: string;
nameEs: string;
}
export const statusInfoMapping: Record<TimeslotStatus, StatusInfo> = {
[TimeslotStatus.booked]: {
color: palette.orangeSec,
icon: 'check',
nameEs: 'Reservado'
},
[TimeslotStatus.pending]: {
color: palette.yellowSec,
icon: 'hour-glass',
nameEs: 'Pendiente'
},
[TimeslotStatus.confirmed]: {
color: palette.greenPrim,
icon: 'schedule',
nameEs: 'Confirmado'
},
[TimeslotStatus.cancelled]: {
color: palette.redSec,
icon: 'cancel',
nameEs: 'Cancelado'
},
[TimeslotStatus.unavailable]: {
color: palette.greyish,
icon: 'event-busy',
nameEs: 'No disponible'
},
[TimeslotStatus.available]: {
color: palette.purpleSec,
icon: 'event',
nameEs: 'Disponible'
}
};
/** History */
export type AppointmentType = {
id?: string;
timeSlotId?: string; // Relation with TimeSlot which status != TimeslotStatus.available
price: number;
meetURL?: string;
transactionId: string;
expertId: string;
curiousId: string;
requestTime: Date;
description?: string; //ex: Do we need to pay IRPF In spain?
startTime: Date;
endTime: Date; // get from @startTime+ Service duration
status?: TimeslotStatus; //defaults to TimeslotStatus.available
};
export type ShownAppointmentType = AppointmentType & {
curiousUser: UserConciseType;
expertUser: UserConciseType;
serviceInfo: {
service: ServiceType;
};
};
/** Unused on the meantime*/
/*export type AppointmentType = {
id: string;
serviceId: string;
userId: string;
timeSlotId: string;
status: TimeslotStatus; // For example: "pending", "confirmed", "cancelled"
};*/