summaryrefslogtreecommitdiffstats
path: root/src/features/reservations/hooks/useReservations.ts
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 17:29:30 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 17:29:30 +0100
commit47538e50cbad770ddeb998904253afcdd51e20f6 (patch)
tree996350fba5c88744458faa7a969b3136d189bfa3 /src/features/reservations/hooks/useReservations.ts
parente22992e29801e04ca4352045c5bd2f36eac1c31c (diff)
disponibilidad de reservas, home mejorado y check-in
Diffstat (limited to 'src/features/reservations/hooks/useReservations.ts')
-rw-r--r--src/features/reservations/hooks/useReservations.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/features/reservations/hooks/useReservations.ts b/src/features/reservations/hooks/useReservations.ts
index cf58811..bb67a84 100644
--- a/src/features/reservations/hooks/useReservations.ts
+++ b/src/features/reservations/hooks/useReservations.ts
@@ -11,6 +11,7 @@ export function useReservations() {
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
const [cancelingReservationId, setCancelingReservationId] = useState<string | null>(null);
+ const [checkingInReservationId, setCheckingInReservationId] = useState<string | null>(null);
const loadReservations = async () => {
if (!user?.uid) {
@@ -50,6 +51,20 @@ export function useReservations() {
}
};
+ const checkInReservation = async (reservationId: string) => {
+ try {
+ setError(null);
+ setCheckingInReservationId(reservationId);
+
+ await reservationsService.checkIn(reservationId);
+ await loadReservations();
+ } catch (err) {
+ setError(getErrorMessage(err, 'No se pudo registrar la llegada'));
+ } finally {
+ setCheckingInReservationId(null);
+ }
+ };
+
return {
reservations,
activeReservations: reservations.filter((reservation) => reservation.status === 'active'),
@@ -57,7 +72,9 @@ export function useReservations() {
loading,
error,
cancelingReservationId,
+ checkingInReservationId,
cancelReservation,
+ checkInReservation,
reload: loadReservations,
};
}