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:
counterweight 2025-12-21 17:50:52 +01:00
parent 8cc2cfa2e4
commit 02212ba478
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 3 additions and 15 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}