diff --git a/app/(admin)/admin/booking/[id]/page.tsx b/app/(admin)/admin/booking/[id]/page.tsx index ee6f68c..3ec4ccb 100644 --- a/app/(admin)/admin/booking/[id]/page.tsx +++ b/app/(admin)/admin/booking/[id]/page.tsx @@ -367,13 +367,18 @@ export default function AppointmentDetailPage() { )} - {/* Selected Slots */} + {/* Selected Slots (replacing Matching Slots) */} {appointment.selected_slots && Array.isArray(appointment.selected_slots) && appointment.selected_slots.length > 0 && (

- + Selected Time Slots + {appointment.are_preferences_available !== undefined && ( + + {appointment.are_preferences_available ? "All Available" : "Partially Available"} + + )}

@@ -400,14 +405,19 @@ export default function AppointmentDetailPage() { return (
-

+

{dayName}

-

+

{timeLabel}

+ {slot.date && ( +

+ {formatShortDate(slot.date)} +

+ )}
); })} @@ -416,128 +426,6 @@ export default function AppointmentDetailPage() {
)} - {/* Matching Slots */} - {(() => { - // Check if matching_availability is a MatchingAvailability object with matching_slots - const matchingAvailability = appointment.matching_availability as any; - const hasMatchingSlots = matchingAvailability && matchingAvailability.matching_slots && Array.isArray(matchingAvailability.matching_slots) && matchingAvailability.matching_slots.length > 0; - const isArrayFormat = Array.isArray(matchingAvailability) && matchingAvailability.length > 0; - - if (!hasMatchingSlots && !isArrayFormat) return null; - - const dayNames: Record = { - 0: "Monday", - 1: "Tuesday", - 2: "Wednesday", - 3: "Thursday", - 4: "Friday", - 5: "Saturday", - 6: "Sunday", - }; - const timeSlotLabels: Record = { - morning: "Morning", - afternoon: "Lunchtime", - evening: "Evening", - }; - - // Get matching slots from MatchingAvailability object - const matchingSlots = hasMatchingSlots ? matchingAvailability.matching_slots : null; - const totalMatchingSlots = hasMatchingSlots ? matchingAvailability.total_matching_slots : null; - const preferencesMatch = hasMatchingSlots ? matchingAvailability.preferences_match_availability : appointment.are_preferences_available; - - return ( -
-
-

- - Matching Slots - {preferencesMatch !== undefined && ( - - {preferencesMatch ? "All Available" : "Partially Available"} - - )} -

-
-
- {hasMatchingSlots && totalMatchingSlots && ( -

- Found {totalMatchingSlots} matching time slot{totalMatchingSlots !== 1 ? 's' : ''} that match your selected preferences: -

- )} - {!hasMatchingSlots && ( -

- These are the available time slots that match your selected preferences: -

- )} - - {hasMatchingSlots ? ( - // Display matching_slots from MatchingAvailability object -
- {matchingSlots.map((slot: any, idx: number) => { - const dayName = dayNames[slot.day] || `Day ${slot.day}`; - const timeSlot = String(slot.time_slot).toLowerCase().trim(); - const timeLabel = timeSlotLabels[timeSlot] || slot.time_slot; - - return ( -
-

- {dayName} -

-

- {timeLabel} -

-

- {formatShortDate(slot.date)} -

-
- ); - })} -
- ) : ( - // Display array format (legacy) -
- {(matchingAvailability as any[]).map((match: any, idx: number) => ( -
-
-
-

- {match.day_name || "Unknown Day"} -

-

- {formatShortDate(match.date || match.date_obj || "")} -

-
-
- {match.available_slots && Array.isArray(match.available_slots) && match.available_slots.length > 0 && ( -
- {match.available_slots.map((slot: string, slotIdx: number) => { - const normalizedSlot = String(slot).toLowerCase().trim(); - return ( - - {timeSlotLabels[normalizedSlot] || slot} - - ); - })} -
- )} -
- ))} -
- )} -
-
- ); - })()} - {/* Reason */} {appointment.reason && (
diff --git a/app/(user)/user/appointments/[id]/page.tsx b/app/(user)/user/appointments/[id]/page.tsx index 5a19bcb..1330fdd 100644 --- a/app/(user)/user/appointments/[id]/page.tsx +++ b/app/(user)/user/appointments/[id]/page.tsx @@ -306,13 +306,18 @@ export default function UserAppointmentDetailPage() {
)} - {/* Selected Slots */} + {/* Selected Slots (replacing Matching Slots) */} {appointment.selected_slots && Array.isArray(appointment.selected_slots) && appointment.selected_slots.length > 0 && (

- + Selected Time Slots + {appointment.are_preferences_available !== undefined && ( + + {appointment.are_preferences_available ? "All Available" : "Partially Available"} + + )}

@@ -339,14 +344,19 @@ export default function UserAppointmentDetailPage() { return (
-

+

{dayName}

-

+

{timeLabel}

+ {slot.date && ( +

+ {formatShortDate(slot.date)} +

+ )}
); })} @@ -355,128 +365,6 @@ export default function UserAppointmentDetailPage() {
)} - {/* Matching Slots */} - {(() => { - // Check if matching_availability is a MatchingAvailability object with matching_slots - const matchingAvailability = appointment.matching_availability as any; - const hasMatchingSlots = matchingAvailability && matchingAvailability.matching_slots && Array.isArray(matchingAvailability.matching_slots) && matchingAvailability.matching_slots.length > 0; - const isArrayFormat = Array.isArray(matchingAvailability) && matchingAvailability.length > 0; - - if (!hasMatchingSlots && !isArrayFormat) return null; - - const dayNames: Record = { - 0: "Monday", - 1: "Tuesday", - 2: "Wednesday", - 3: "Thursday", - 4: "Friday", - 5: "Saturday", - 6: "Sunday", - }; - const timeSlotLabels: Record = { - morning: "Morning", - afternoon: "Lunchtime", - evening: "Evening", - }; - - // Get matching slots from MatchingAvailability object - const matchingSlots = hasMatchingSlots ? matchingAvailability.matching_slots : null; - const totalMatchingSlots = hasMatchingSlots ? matchingAvailability.total_matching_slots : null; - const preferencesMatch = hasMatchingSlots ? matchingAvailability.preferences_match_availability : appointment.are_preferences_available; - - return ( -
-
-

- - Matching Slots - {preferencesMatch !== undefined && ( - - {preferencesMatch ? "All Available" : "Partially Available"} - - )} -

-
-
- {hasMatchingSlots && totalMatchingSlots && ( -

- Found {totalMatchingSlots} matching time slot{totalMatchingSlots !== 1 ? 's' : ''} that match your selected preferences: -

- )} - {!hasMatchingSlots && ( -

- These are the available time slots that match your selected preferences: -

- )} - - {hasMatchingSlots ? ( - // Display matching_slots from MatchingAvailability object -
- {matchingSlots.map((slot: any, idx: number) => { - const dayName = dayNames[slot.day] || `Day ${slot.day}`; - const timeSlot = String(slot.time_slot).toLowerCase().trim(); - const timeLabel = timeSlotLabels[timeSlot] || slot.time_slot; - - return ( -
-

- {dayName} -

-

- {timeLabel} -

-

- {formatShortDate(slot.date)} -

-
- ); - })} -
- ) : ( - // Display array format (legacy) -
- {(matchingAvailability as any[]).map((match: any, idx: number) => ( -
-
-
-

- {match.day_name || "Unknown Day"} -

-

- {formatShortDate(match.date || match.date_obj || "")} -

-
-
- {match.available_slots && Array.isArray(match.available_slots) && match.available_slots.length > 0 && ( -
- {match.available_slots.map((slot: string, slotIdx: number) => { - const normalizedSlot = String(slot).toLowerCase().trim(); - return ( - - {timeSlotLabels[normalizedSlot] || slot} - - ); - })} -
- )} -
- ))} -
- )} -
-
- ); - })()} - {/* Reason */} {appointment.reason && (