Tanggal: {format(parseISO(selectedSlot.date), 'd MMMM yyyy', { locale: id })}
Waktu: {selectedSlot.start_time.substring(0, 5)} - {selectedSlot.end_time.substring(0, 5)}
Klien: {selectedSlot.profiles?.name}
Topik: {selectedSlot.topic_category}
{selectedSlot.notes &&
Catatan: {selectedSlot.notes}
}
)}
// CHANGE TO:
{selectedSession && (
Tanggal: {format(parseISO(selectedSession.session_date), 'd MMMM yyyy', { locale: id })}
Waktu: {selectedSession.start_time.substring(0, 5)} - {selectedSession.end_time.substring(0, 5)}
Klien: {selectedSession.profiles?.name}
Topik: {selectedSession.topic_category}
{selectedSession.notes &&
Catatan: {selectedSession.notes}
}
)}
```
## 📋 Remaining Files to Update
### 4. src/components/reviews/ConsultingHistory.tsx
**Changes needed:**
- Change query from `consulting_slots` to `consulting_sessions`
- Remove grouping logic (no longer needed)
- Update interface to use `ConsultingSession` with fields:
- `session_date` (instead of `date`)
- `total_duration_minutes`
- `total_blocks`
- `total_price`
- Update all field references in rendering
### 5. src/pages/member/OrderDetail.tsx
**Changes needed:**
- Find consulting_slots query and change to consulting_sessions
- Update join to include session data
- Update field names in rendering (date → session_date, etc.)
### 6. supabase/functions/handle-order-paid/index.ts
**Changes needed:**
- Change status update from `consulting_slots` to `consulting_sessions`
- Update logic to set `status = 'confirmed'` for session
---
## Quick Reference: Field Name Changes
| Old (consulting_slots) | New (consulting_sessions) |
|------------------------|---------------------------|
| `date` | `session_date` |
| `slots` array | Single `session` object |
| `slots[0]` / `firstSlot` | `session` |
| `slots[length-1]` / `lastSlot` | `session` |
| `order_id` (for grouping) | `id` (session ID) |
| `meet_link` (per slot) | `meet_link` (per session) |
| Row count × 45min | `total_duration_minutes` |
| Row count | `total_blocks` |
---
## Testing Checklist
After migration:
- [ ] Test booking flow - creates session + time slots
- [ ] Test availability checking - uses sessions table
- [ ] Test meet link creation - updates session
- [ ] Test admin consulting page - displays sessions
- [ ] Test user consulting history - displays sessions
- [ ] Test order detail - shows consulting session info
- [ ] Test payment confirmation - updates session status
---
## Rollback Plan (if needed)
If issues arise:
1. Restore old table: `ALTER TABLE consulting_slots RENAME TO consulting_slots_backup;`
2. Create view: `CREATE VIEW consulting_slots AS SELECT ... FROM consulting_sessions JOIN consulting_time_slots;`
3. Revert code changes from git
---
**Note:** All SQL tables should already be created. This document covers code changes only.