Fix consulting slots ordering and add debug logging
Changes: - Sort consulting slots by start_time before processing - Ensures correct first/last slot selection for calendar events - Add debug logging to track time slot calculations - Fixes end time calculation for multi-slot consulting orders This ensures that when multiple slots are booked: - Slots are processed in chronological order - Calendar event uses first slot's start and last slot's end - Event duration correctly covers all booked slots 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,6 +99,9 @@ serve(async (req: Request): Promise<Response> => {
|
||||
if (isConsultingOrder) {
|
||||
console.log("[HANDLE-PAID] Consulting order detected, processing slots");
|
||||
|
||||
// Sort slots by start_time to ensure correct ordering
|
||||
consultingSlots.sort((a, b) => a.start_time.localeCompare(b.start_time));
|
||||
|
||||
// Update consulting slots status from pending_payment to confirmed
|
||||
const { error: updateError } = await supabase
|
||||
.from("consulting_slots")
|
||||
@@ -121,6 +124,9 @@ serve(async (req: Request): Promise<Response> => {
|
||||
const lastSlot = consultingSlots[consultingSlots.length - 1];
|
||||
const topic = "Konsultasi 1-on-1";
|
||||
|
||||
console.log("[HANDLE-PAID] Time slots:", consultingSlots.map(s => `${s.start_time}-${s.end_time}`).join(', '));
|
||||
console.log("[HANDLE-PAID] Event will be:", `${firstSlot.start_time} - ${lastSlot.end_time}`);
|
||||
|
||||
const meetResponse = await fetch(
|
||||
`${supabaseUrl}/functions/v1/create-google-meet-event`,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user