Compare commits
No commits in common. "9aefe892cf6db96dd5f1eff06313c16df5f500ab" and "36014ca9540bd3594c6f44586961eba051b9149e" have entirely different histories.
9aefe892cf
...
36014ca954
@ -392,27 +392,13 @@ export async function scheduleAppointment(id: string, input: ScheduleAppointment
|
|||||||
throw new Error("Authentication required.");
|
throw new Error("Authentication required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build payload with defaults
|
|
||||||
const payload: any = {
|
|
||||||
...input,
|
|
||||||
// Default create_jitsi_meeting to true if not specified
|
|
||||||
create_jitsi_meeting: input.create_jitsi_meeting !== undefined ? input.create_jitsi_meeting : true,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Remove undefined fields
|
|
||||||
Object.keys(payload).forEach(key => {
|
|
||||||
if (payload[key] === undefined) {
|
|
||||||
delete payload[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const response = await fetch(`${API_ENDPOINTS.meetings.listAppointments}${id}/schedule/`, {
|
const response = await fetch(`${API_ENDPOINTS.meetings.listAppointments}${id}/schedule/`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${tokens.access}`,
|
Authorization: `Bearer ${tokens.access}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(input),
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await parseResponse(response);
|
const data = await parseResponse(response);
|
||||||
@ -429,19 +415,13 @@ export async function rejectAppointment(id: string, input: RejectAppointmentInpu
|
|||||||
throw new Error("Authentication required.");
|
throw new Error("Authentication required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build payload - only include rejection_reason if provided
|
|
||||||
const payload: any = {};
|
|
||||||
if (input.rejection_reason) {
|
|
||||||
payload.rejection_reason = input.rejection_reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(`${API_ENDPOINTS.meetings.listAppointments}${id}/reject/`, {
|
const response = await fetch(`${API_ENDPOINTS.meetings.listAppointments}${id}/reject/`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${tokens.access}`,
|
Authorization: `Bearer ${tokens.access}`,
|
||||||
},
|
},
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(input),
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await parseResponse(response);
|
const data = await parseResponse(response);
|
||||||
|
|||||||
@ -36,26 +36,10 @@ export const createAppointmentSchema = z.object({
|
|||||||
export type CreateAppointmentInput = z.infer<typeof createAppointmentSchema>;
|
export type CreateAppointmentInput = z.infer<typeof createAppointmentSchema>;
|
||||||
|
|
||||||
// Schedule Appointment Schema (Admin only)
|
// Schedule Appointment Schema (Admin only)
|
||||||
// Supports two scheduling methods:
|
|
||||||
// 1. Direct datetime: scheduled_datetime + 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"),
|
||||||
scheduled_duration: z.number().int().positive().optional(),
|
scheduled_duration: z.number().int().positive().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(),
|
|
||||||
create_jitsi_meeting: z.boolean().optional(),
|
|
||||||
jitsi_custom_config: z.string().optional(),
|
|
||||||
}).refine(
|
|
||||||
(data) => {
|
|
||||||
// Either scheduled_datetime OR (date_str + time_slot) must be provided
|
|
||||||
return data.scheduled_datetime || (data.date_str && data.time_slot);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Either scheduled_datetime or both date_str and time_slot must be provided",
|
|
||||||
path: ["scheduled_datetime"],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export type ScheduleAppointmentInput = z.infer<typeof scheduleAppointmentSchema>;
|
export type ScheduleAppointmentInput = z.infer<typeof scheduleAppointmentSchema>;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user