Make error handling consistent across frontend
- Standardized all error handling to use ternary pattern - Changed if/else blocks to ternary operators for consistency - Updated booking, appointments, and admin appointments pages
This commit is contained in:
parent
8cc2cfa2e4
commit
02212ba478
3 changed files with 3 additions and 15 deletions
|
|
@ -202,11 +202,7 @@ export default function AdminAppointmentsPage() {
|
|||
await fetchAppointments();
|
||||
setConfirmCancelId(null);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
setError(err.message);
|
||||
} else {
|
||||
setError("Failed to cancel appointment");
|
||||
}
|
||||
setError(err instanceof Error ? err.message : "Failed to cancel appointment");
|
||||
} finally {
|
||||
setCancellingId(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,11 +194,7 @@ export default function AppointmentsPage() {
|
|||
await fetchAppointments();
|
||||
setConfirmCancelId(null);
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
setError(err.message);
|
||||
} else {
|
||||
setError("Failed to cancel appointment");
|
||||
}
|
||||
setError(err instanceof Error ? err.message : "Failed to cancel appointment");
|
||||
} finally {
|
||||
setCancellingId(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,11 +302,7 @@ export default function BookingPage() {
|
|||
await fetchSlots(selectedDate);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
setError(err.message);
|
||||
} else {
|
||||
setError("Failed to book appointment");
|
||||
}
|
||||
setError(err instanceof Error ? err.message : "Failed to book appointment");
|
||||
} finally {
|
||||
setIsBooking(false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue