diff --git a/app/(admin)/admin/booking/page.tsx b/app/(admin)/admin/booking/page.tsx
index b0b8cef..532ba43 100644
--- a/app/(admin)/admin/booking/page.tsx
+++ b/app/(admin)/admin/booking/page.tsx
@@ -607,7 +607,7 @@ export default function Booking() {
Status
- Preferred Dates
+ Preferred Availability
|
Created
@@ -678,25 +678,71 @@ export default function Booking() {
{formatStatus(appointment.status)}
- |
- {appointment.preferred_dates ? (
-
- {Array.isArray(appointment.preferred_dates) ? (
- <>
- {(appointment.preferred_dates as string[]).slice(0, 2).map((date, idx) => (
- {formatDate(date)}
- ))}
- {appointment.preferred_dates.length > 2 && (
- +{appointment.preferred_dates.length - 2} more
- )}
- >
- ) : (
- {appointment.preferred_dates_display || appointment.preferred_dates}
- )}
-
- ) : (
- "-"
- )}
+ |
+ {(() => {
+ // Handle preferred_dates
+ const dates = Array.isArray(appointment.preferred_dates)
+ ? appointment.preferred_dates
+ : appointment.preferred_dates
+ ? [appointment.preferred_dates]
+ : [];
+
+ // Handle preferred_time_slots
+ const timeSlots = Array.isArray(appointment.preferred_time_slots)
+ ? appointment.preferred_time_slots
+ : appointment.preferred_time_slots
+ ? [appointment.preferred_time_slots]
+ : [];
+
+ // Time slot labels
+ const timeSlotLabels: Record = {
+ morning: "Morning",
+ afternoon: "Lunchtime",
+ evening: "Evening",
+ };
+
+ if (dates.length === 0 && timeSlots.length === 0) {
+ return -;
+ }
+
+ return (
+
+ {dates.length > 0 && (
+
+ {dates.slice(0, 2).map((date, idx) => (
+
+ {formatDate(date)}
+
+ ))}
+ {dates.length > 2 && (
+
+ +{dates.length - 2} more date{dates.length - 2 > 1 ? 's' : ''}
+
+ )}
+
+ )}
+ {timeSlots.length > 0 && (
+
+ {timeSlots.map((slot, idx) => {
+ const normalizedSlot = String(slot).toLowerCase().trim();
+ return (
+
+ {timeSlotLabels[normalizedSlot] || slot}
+
+ );
+ })}
+
+ )}
+
+ );
+ })()}
|
{formatDate(appointment.created_at)}
diff --git a/lib/models/appointments.ts b/lib/models/appointments.ts
index 8b14b4b..14d68e2 100644
--- a/lib/models/appointments.ts
+++ b/lib/models/appointments.ts
@@ -7,8 +7,8 @@ export interface Appointment {
email: string;
phone?: string;
reason?: string;
- preferred_dates?: string; // YYYY-MM-DD format (legacy) - API returns as string, not array
- preferred_time_slots?: string; // "morning", "afternoon", "evening" (legacy) - API returns as string
+ preferred_dates?: string | string[]; // YYYY-MM-DD format - API can return as string or array
+ preferred_time_slots?: string | string[]; // "morning", "afternoon", "evening" - API can return as string or array
selected_slots?: SelectedSlot[]; // New format: day-time combinations
status: "pending_review" | "scheduled" | "rejected" | "completed" | "cancelled";
created_at: string;
|