Fix booking summary end time and enhance calendar event management
**Issue 1: Fix end time display in booking summary**
- Now correctly shows start_time + slot_duration instead of just start_time
- Example: 09:30 → 10:00 for 1 slot (30 mins)
**Issue 2: Confirm create-google-meet-event uses consulting_sessions**
- Verified: Function already updates consulting_sessions table
- The data shown is from OLD consulting_slots table (needs migration)
**Issue 3: Delete calendar events when order is deleted**
- Enhanced delete-order function to delete calendar events before removing order
- Calls delete-calendar-event for each session with calendar_event_id
**Issue 4: Admin can now edit session time and manage calendar events**
- Added time editing inputs (start/end time) in admin dialog
- Added "Delete Link & Calendar Event" button to remove meet link
- Shows calendar event connection status (✓ Event Kalender: Terhubung)
- "Regenerate Link" button creates new meet link + calendar event
- Recalculates session duration when time changes
**Issue 5: Enhanced calendar event description**
- Now includes: Kategori, Client email, Catatan, Session ID
- Format: "Kategori: {topic}\n\nClient: {email}\n\nCatatan: {notes}\n\nSession ID: {id}"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -235,7 +235,7 @@ serve(async (req: Request): Promise<Response> => {
|
||||
|
||||
const eventData = {
|
||||
summary: `Konsultasi: ${body.topic} - ${body.client_name}`,
|
||||
description: `Client: ${body.client_email}\n\nNotes: ${body.notes || '-'}\n\nSlot ID: ${body.slot_id}`,
|
||||
description: `Kategori: ${body.topic}\n\nClient: ${body.client_email}\n\nCatatan: ${body.notes || '-'}\n\nSession ID: ${body.slot_id}`,
|
||||
start: {
|
||||
dateTime: startDate.toISOString(),
|
||||
timeZone: "Asia/Jakarta",
|
||||
|
||||
@@ -32,6 +32,31 @@ serve(async (req: Request): Promise<Response> => {
|
||||
const supabaseServiceKey = Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!;
|
||||
const supabase = createClient(supabaseUrl, supabaseServiceKey);
|
||||
|
||||
// Get consulting sessions for this order to delete calendar events
|
||||
const { data: sessions } = await supabase
|
||||
.from("consulting_sessions")
|
||||
.select("id, calendar_event_id")
|
||||
.eq("order_id", order_id);
|
||||
|
||||
if (sessions && sessions.length > 0) {
|
||||
console.log("[DELETE-ORDER] Found consulting sessions:", sessions.length);
|
||||
|
||||
// Delete calendar events for each session
|
||||
for (const session of sessions) {
|
||||
if (session.calendar_event_id) {
|
||||
try {
|
||||
await supabase.functions.invoke('delete-calendar-event', {
|
||||
body: { session_id: session.id }
|
||||
});
|
||||
console.log("[DELETE-ORDER] Deleted calendar event for session:", session.id);
|
||||
} catch (err) {
|
||||
console.log("[DELETE-ORDER] Failed to delete calendar event:", err);
|
||||
// Continue with order deletion even if calendar deletion fails
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Call the database function to delete the order
|
||||
const { data, error } = await supabase
|
||||
.rpc("delete_order", { order_uuid: order_id });
|
||||
|
||||
Reference in New Issue
Block a user