summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)/(tabs)/reservations
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/(protected)/(tabs)/reservations')
-rw-r--r--src/app/(protected)/(tabs)/reservations/index.tsx85
1 files changed, 83 insertions, 2 deletions
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 }) => (
<View style={styles.card}>
- <Text style={styles.cardTitle}>{item.officeName}</Text>
+ <View style={styles.cardHeader}>
+ <Text style={styles.cardTitle}>{item.officeName}</Text>
+ <View
+ style={[
+ styles.statusBadge,
+ item.status === 'active' ? styles.statusActive : styles.statusCancelled,
+ ]}
+ >
+ <Text style={styles.statusText}>
+ {item.status === 'active' ? 'Activa' : 'Cancelada'}
+ </Text>
+ </View>
+ </View>
<Text>Fecha: {item.date}</Text>
<Text>Inicio: {item.startTime}</Text>
<Text>Fin: {item.endTime}</Text>
+
+ {item.status === 'active' ? (
+ <Pressable
+ style={styles.cancelButton}
+ onPress={() => handleCancelReservation(item.id)}
+ disabled={cancelingReservationId === item.id}
+ >
+ <Text style={styles.buttonText}>
+ {cancelingReservationId === item.id
+ ? 'Cancelando...'
+ : 'Cancelar reserva'}
+ </Text>
+ </Pressable>
+ ) : null}
</View>
)}
/>
@@ -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',
},