From bd4a70dab890153617cad4e0be1364941993d51d Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Wed, 1 Apr 2026 00:56:41 +0100 Subject: firestore rules y logica de cancelación de reservas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(protected)/(tabs)/reservations/index.tsx | 85 ++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) (limited to 'src/app/(protected)/(tabs)') diff --git a/src/app/(protected)/(tabs)/reservations/index.tsx b/src/app/(protected)/(tabs)/reservations/index.tsx index 56f7832..a2a0d9d 100644 --- a/src/app/(protected)/(tabs)/reservations/index.tsx +++ b/src/app/(protected)/(tabs)/reservations/index.tsx @@ -1,5 +1,6 @@ import { ActivityIndicator, + Alert, FlatList, Pressable, StyleSheet, @@ -9,7 +10,31 @@ import { import { useReservations } from '@/features/reservations/hooks/useReservations'; export default function ReservationsScreen() { - const { reservations, loading, error, reload } = useReservations(); + const { + reservations, + loading, + error, + reload, + cancelReservation, + cancelingReservationId, + } = useReservations(); + + const handleCancelReservation = (reservationId: string) => { + Alert.alert( + 'Cancelar reserva', + 'Esta acción marcará la reserva como cancelada.', + [ + { text: 'Volver', style: 'cancel' }, + { + text: 'Cancelar reserva', + style: 'destructive', + onPress: () => { + void cancelReservation(reservationId); + }, + }, + ] + ); + }; if (loading) { return ( @@ -43,10 +68,36 @@ export default function ReservationsScreen() { } renderItem={({ item }) => ( - {item.officeName} + + {item.officeName} + + + {item.status === 'active' ? 'Activa' : 'Cancelada'} + + + Fecha: {item.date} Inicio: {item.startTime} Fin: {item.endTime} + + {item.status === 'active' ? ( + handleCancelReservation(item.id)} + disabled={cancelingReservationId === item.id} + > + + {cancelingReservationId === item.id + ? 'Cancelando...' + : 'Cancelar reserva'} + + + ) : null} )} /> @@ -80,9 +131,32 @@ const styles = StyleSheet.create({ padding: 16, gap: 6, }, + cardHeader: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + gap: 12, + }, cardTitle: { fontSize: 18, fontWeight: '600', + flex: 1, + }, + statusBadge: { + borderRadius: 999, + paddingHorizontal: 10, + paddingVertical: 4, + }, + statusActive: { + backgroundColor: '#d7f5df', + }, + statusCancelled: { + backgroundColor: '#f3d8d8', + }, + statusText: { + fontSize: 12, + fontWeight: '700', + color: '#333', }, error: { color: 'red', @@ -98,6 +172,13 @@ const styles = StyleSheet.create({ color: '#fff', fontWeight: '600', }, + cancelButton: { + backgroundColor: '#c62828', + paddingVertical: 12, + borderRadius: 10, + alignItems: 'center', + marginTop: 8, + }, empty: { color: '#666', }, -- cgit v1.2.3-54-g00ecf