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();
|
await fetchAppointments();
|
||||||
setConfirmCancelId(null);
|
setConfirmCancelId(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error) {
|
setError(err instanceof Error ? err.message : "Failed to cancel appointment");
|
||||||
setError(err.message);
|
|
||||||
} else {
|
|
||||||
setError("Failed to cancel appointment");
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setCancellingId(null);
|
setCancellingId(null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,7 @@ export default function AppointmentsPage() {
|
||||||
await fetchAppointments();
|
await fetchAppointments();
|
||||||
setConfirmCancelId(null);
|
setConfirmCancelId(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error) {
|
setError(err instanceof Error ? err.message : "Failed to cancel appointment");
|
||||||
setError(err.message);
|
|
||||||
} else {
|
|
||||||
setError("Failed to cancel appointment");
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setCancellingId(null);
|
setCancellingId(null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -302,11 +302,7 @@ export default function BookingPage() {
|
||||||
await fetchSlots(selectedDate);
|
await fetchSlots(selectedDate);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof Error) {
|
setError(err instanceof Error ? err.message : "Failed to book appointment");
|
||||||
setError(err.message);
|
|
||||||
} else {
|
|
||||||
setError("Failed to book appointment");
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsBooking(false);
|
setIsBooking(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue