From 174f1acd46c4ffbde88c04465e8fa6b6810ce113 Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Mon, 30 Mar 2026 17:37:42 +0100 Subject: logica de reservas --- src/app/(protected)/(tabs)/reservations/index.tsx | 92 +++++++++++++-- src/app/(protected)/offices/[officeId].tsx | 18 ++- "src/app/(protected)/offices/\\" | 129 ++++++++++++++++++++++ src/app/(protected)/reservations/create.tsx | 110 +++++++++++++++++- 4 files changed, 331 insertions(+), 18 deletions(-) create mode 100644 "src/app/(protected)/offices/\\" (limited to 'src/app/(protected)') diff --git a/src/app/(protected)/(tabs)/reservations/index.tsx b/src/app/(protected)/(tabs)/reservations/index.tsx index 817ec6e..56f7832 100644 --- a/src/app/(protected)/(tabs)/reservations/index.tsx +++ b/src/app/(protected)/(tabs)/reservations/index.tsx @@ -1,10 +1,55 @@ -import { StyleSheet, Text, View } from 'react-native'; +import { + ActivityIndicator, + FlatList, + Pressable, + StyleSheet, + Text, + View, +} from 'react-native'; +import { useReservations } from '@/features/reservations/hooks/useReservations'; export default function ReservationsScreen() { + const { reservations, loading, error, reload } = useReservations(); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + Reintentar + + + ); + } + return ( - Reservas - Pantalla en construcción. + Mis reservas + + item.id} + contentContainerStyle={styles.list} + ListEmptyComponent={ + No tienes reservas todavía + } + renderItem={({ item }) => ( + + {item.officeName} + Fecha: {item.date} + Inicio: {item.startTime} + Fin: {item.endTime} + + )} + /> ); } @@ -13,16 +58,47 @@ const styles = StyleSheet.create({ container: { flex: 1, padding: 16, - justifyContent: 'center', + }, + center: { + flex: 1, alignItems: 'center', - gap: 12, + justifyContent: 'center', + padding: 24, }, title: { fontSize: 28, fontWeight: '700', + marginBottom: 16, + }, + list: { + gap: 12, + }, + card: { + borderWidth: 1, + borderColor: '#ddd', + borderRadius: 12, + padding: 16, + gap: 6, + }, + cardTitle: { + fontSize: 18, + fontWeight: '600', + }, + error: { + color: 'red', + marginBottom: 12, + }, + button: { + backgroundColor: '#1f6feb', + paddingHorizontal: 16, + paddingVertical: 12, + borderRadius: 10, + }, + buttonText: { + color: '#fff', + fontWeight: '600', }, - text: { - fontSize: 16, - color: '#555', + empty: { + color: '#666', }, }); diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx index 77fd610..34095c5 100644 --- a/src/app/(protected)/offices/[officeId].tsx +++ b/src/app/(protected)/offices/[officeId].tsx @@ -53,11 +53,21 @@ export default function OfficeDetailScreen() { ) : null} - - - Reservar este espacio - + + + Reservar este espacio + + ); } diff --git "a/src/app/(protected)/offices/\\" "b/src/app/(protected)/offices/\\" new file mode 100644 index 0000000..34095c5 --- /dev/null +++ "b/src/app/(protected)/offices/\\" @@ -0,0 +1,129 @@ +import { Link, useLocalSearchParams } from 'expo-router'; +import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; +import { useOffice } from '@/features/offices/hooks/useOffice'; + +export default function OfficeDetailScreen() { + const params = useLocalSearchParams<{ officeId: string }>(); + const officeId = typeof params.officeId === 'string' ? params.officeId : undefined; + + const { office, loading, error, reload } = useOffice(officeId); + + if (loading) { + return ( + + + + ); + } + + if (error || !office) { + return ( + + {error ?? 'No se pudo cargar la oficina'} + + + Reintentar + + + + + Volver a espacios + + + + ); + } + + return ( + + {office.name} + + + Ubicación + {office.location} + + Capacidad + {office.capacity} personas + + {office.description ? ( + <> + Descripción + {office.description} + + ) : null} + + + + + Reservar este espacio + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + gap: 16, + }, + center: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + padding: 24, + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + card: { + borderWidth: 1, + borderColor: '#ddd', + borderRadius: 12, + padding: 16, + gap: 10, + }, + label: { + fontSize: 14, + fontWeight: '700', + color: '#444', + }, + value: { + fontSize: 16, + color: '#111', + }, + button: { + backgroundColor: '#1f6feb', + paddingVertical: 14, + borderRadius: 10, + alignItems: 'center', + }, + secondaryButton: { + backgroundColor: '#555', + paddingVertical: 14, + paddingHorizontal: 16, + borderRadius: 10, + alignItems: 'center', + }, + buttonText: { + color: '#fff', + fontWeight: '600', + }, + error: { + color: 'red', + textAlign: 'center', + }, +}); diff --git a/src/app/(protected)/reservations/create.tsx b/src/app/(protected)/reservations/create.tsx index c1c88b3..138f0ee 100644 --- a/src/app/(protected)/reservations/create.tsx +++ b/src/app/(protected)/reservations/create.tsx @@ -1,10 +1,72 @@ -import { StyleSheet, Text, View } from 'react-native'; +import { useLocalSearchParams } from 'expo-router'; +import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; +import { useCreateReservation } from '@/features/reservations/hooks/useCreateReservation'; export default function CreateReservationScreen() { + const params = useLocalSearchParams<{ + officeId?: string; + officeName?: string; + }>(); + + const officeId = + typeof params.officeId === 'string' ? params.officeId : undefined; + const officeName = + typeof params.officeName === 'string' ? params.officeName : undefined; + + const { + date, + startTime, + endTime, + isSubmitting, + error, + successMessage, + setDate, + setStartTime, + setEndTime, + submit, + } = useCreateReservation({ officeId, officeName }); + return ( Crear reserva - Pantalla en construcción. + + + Espacio + {officeName ?? 'No indicado'} + + ID oficina + {officeId ?? 'No indicado'} + + + + + + + + + {error ? {error} : null} + {successMessage ? {successMessage} : null} + + + + {isSubmitting ? 'Guardando...' : 'Guardar reserva'} + + ); } @@ -13,16 +75,52 @@ const styles = StyleSheet.create({ container: { flex: 1, padding: 16, - justifyContent: 'center', - alignItems: 'center', gap: 12, }, title: { fontSize: 28, fontWeight: '700', + marginBottom: 8, + }, + infoBox: { + borderWidth: 1, + borderColor: '#ddd', + borderRadius: 12, + padding: 12, + gap: 6, + marginBottom: 8, }, - text: { + label: { + fontSize: 14, + fontWeight: '700', + color: '#444', + }, + value: { fontSize: 16, - color: '#555', + color: '#111', + }, + input: { + borderWidth: 1, + borderColor: '#ccc', + borderRadius: 10, + paddingHorizontal: 14, + paddingVertical: 12, + }, + button: { + backgroundColor: '#1f6feb', + paddingVertical: 14, + borderRadius: 10, + alignItems: 'center', + marginTop: 8, + }, + buttonText: { + color: '#fff', + fontWeight: '600', + }, + error: { + color: 'red', + }, + success: { + color: 'green', }, }); -- cgit v1.2.3-54-g00ecf