Merge pull request 'Enhance appointment scheduling by including timezone support in the schema and payload. Update the scheduleAppointment function to automatically use the user's timezone if not specified, improving accuracy in appointment scheduling.' (#60) from feat/booking-panel into master
Reviewed-on: http://35.207.46.142/ATTUNE-HEART-THERAPY/website/pulls/60
This commit is contained in:
commit
e139244cc5
@ -392,9 +392,14 @@ export async function scheduleAppointment(id: string, input: ScheduleAppointment
|
|||||||
throw new Error("Authentication required.");
|
throw new Error("Authentication required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get user's timezone
|
||||||
|
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||||
|
|
||||||
// Build payload with defaults
|
// Build payload with defaults
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
...input,
|
...input,
|
||||||
|
// Always include timezone when scheduling with datetime
|
||||||
|
...(input.scheduled_datetime && { timezone: input.timezone || userTimezone }),
|
||||||
// Default create_jitsi_meeting to true if not specified
|
// Default create_jitsi_meeting to true if not specified
|
||||||
create_jitsi_meeting: input.create_jitsi_meeting !== undefined ? input.create_jitsi_meeting : true,
|
create_jitsi_meeting: input.create_jitsi_meeting !== undefined ? input.create_jitsi_meeting : true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,11 +37,12 @@ export type CreateAppointmentInput = z.infer<typeof createAppointmentSchema>;
|
|||||||
|
|
||||||
// Schedule Appointment Schema (Admin only)
|
// Schedule Appointment Schema (Admin only)
|
||||||
// Supports two scheduling methods:
|
// Supports two scheduling methods:
|
||||||
// 1. Direct datetime: scheduled_datetime + scheduled_duration
|
// 1. Direct datetime: scheduled_datetime + scheduled_duration + timezone
|
||||||
// 2. Date and slot: date_str + time_slot + scheduled_duration
|
// 2. Date and slot: date_str + time_slot + scheduled_duration
|
||||||
export const scheduleAppointmentSchema = z.object({
|
export const scheduleAppointmentSchema = z.object({
|
||||||
scheduled_datetime: z.string().datetime("Invalid datetime format").optional(),
|
scheduled_datetime: z.string().datetime("Invalid datetime format").optional(),
|
||||||
scheduled_duration: z.number().int().positive().optional(),
|
scheduled_duration: z.number().int().positive().optional(),
|
||||||
|
timezone: z.string().optional(),
|
||||||
date_str: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format").optional(),
|
date_str: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Date must be in YYYY-MM-DD format").optional(),
|
||||||
time_slot: z.enum(["morning", "afternoon", "evening"]).optional(),
|
time_slot: z.enum(["morning", "afternoon", "evening"]).optional(),
|
||||||
create_jitsi_meeting: z.boolean().optional(),
|
create_jitsi_meeting: z.boolean().optional(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user