From 08ce78dbd97ad792e163482f454f285557c7cdd0 Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Wed, 1 Apr 2026 13:03:25 +0100 Subject: Mejoras de UX y feedback de errores; y, manejo de status de reserva --- src/app/(protected)/(tabs)/profile/index.tsx | 11 +- src/app/(protected)/(tabs)/reservations/index.tsx | 125 ++++++++++------ src/app/(protected)/reservations/create.tsx | 167 ++++++++++++++++------ 3 files changed, 212 insertions(+), 91 deletions(-) (limited to 'src/app/(protected)') diff --git a/src/app/(protected)/(tabs)/profile/index.tsx b/src/app/(protected)/(tabs)/profile/index.tsx index 1e87f21..760b352 100644 --- a/src/app/(protected)/(tabs)/profile/index.tsx +++ b/src/app/(protected)/(tabs)/profile/index.tsx @@ -12,6 +12,7 @@ import { useAuthSession } from '@/providers/AuthProvider'; import { useProfile } from '@/features/profile/hooks/useProfile'; import { useUpdateProfile } from '@/features/profile/hooks/useUpdateProfile'; import { router } from 'expo-router'; +import { StatusMessage } from '@/shared/ui/StatusMessage'; export default function ProfileScreen() { const { logout } = useAuthSession(); @@ -96,8 +97,8 @@ export default function ProfileScreen() { autoCorrect={false} /> - {updateError ? {updateError} : null} - {successMessage ? {successMessage} : null} + {updateError ? : null} + {successMessage ? : null} @@ -191,9 +192,7 @@ const styles = StyleSheet.create({ fontWeight: '600', }, error: { - color: 'red', - }, - success: { - color: 'green', + color: '#9f1d35', + textAlign: 'center', }, }); diff --git a/src/app/(protected)/(tabs)/reservations/index.tsx b/src/app/(protected)/(tabs)/reservations/index.tsx index a2a0d9d..ccec7e9 100644 --- a/src/app/(protected)/(tabs)/reservations/index.tsx +++ b/src/app/(protected)/(tabs)/reservations/index.tsx @@ -1,8 +1,8 @@ import { ActivityIndicator, Alert, - FlatList, Pressable, + ScrollView, StyleSheet, Text, View, @@ -11,7 +11,8 @@ import { useReservations } from '@/features/reservations/hooks/useReservations'; export default function ReservationsScreen() { const { - reservations, + activeReservations, + historyReservations, loading, error, reload, @@ -59,48 +60,77 @@ export default function ReservationsScreen() { Mis reservas - item.id} - contentContainerStyle={styles.list} - ListEmptyComponent={ - No tienes reservas todavía - } - renderItem={({ item }) => ( - - - {item.officeName} - - - {item.status === 'active' ? 'Activa' : 'Cancelada'} - + + + Activas + + {activeReservations.length === 0 ? ( + No tienes reservas activas + ) : ( + activeReservations.map((item) => ( + + + {item.officeName} + + Activa + + + Fecha: {item.date} + Inicio: {item.startTime} + Fin: {item.endTime} + + handleCancelReservation(item.id)} + disabled={cancelingReservationId === item.id} + > + + {cancelingReservationId === item.id + ? 'Cancelando...' + : 'Cancelar reserva'} + + - - Fecha: {item.date} - Inicio: {item.startTime} - Fin: {item.endTime} + )) + )} + + + + Historial - {item.status === 'active' ? ( - handleCancelReservation(item.id)} - disabled={cancelingReservationId === item.id} - > - - {cancelingReservationId === item.id - ? 'Cancelando...' - : 'Cancelar reserva'} - - - ) : null} - - )} - /> + {historyReservations.length === 0 ? ( + No tienes reservas en el historial + ) : ( + historyReservations.map((item) => ( + + + {item.officeName} + + + {item.status === 'completed' ? 'Completada' : 'Cancelada'} + + + + Fecha: {item.date} + Inicio: {item.startTime} + Fin: {item.endTime} + + )) + )} + + ); } @@ -123,6 +153,14 @@ const styles = StyleSheet.create({ }, list: { gap: 12, + paddingBottom: 24, + }, + section: { + gap: 12, + }, + sectionTitle: { + fontSize: 20, + fontWeight: '700', }, card: { borderWidth: 1, @@ -153,6 +191,9 @@ const styles = StyleSheet.create({ statusCancelled: { backgroundColor: '#f3d8d8', }, + statusCompleted: { + backgroundColor: '#dce8f8', + }, statusText: { fontSize: 12, fontWeight: '700', diff --git a/src/app/(protected)/reservations/create.tsx b/src/app/(protected)/reservations/create.tsx index 138f0ee..65a16f5 100644 --- a/src/app/(protected)/reservations/create.tsx +++ b/src/app/(protected)/reservations/create.tsx @@ -1,6 +1,16 @@ import { useLocalSearchParams } from 'expo-router'; -import { Pressable, StyleSheet, Text, TextInput, View } from 'react-native'; +import { + KeyboardAvoidingView, + Platform, + Pressable, + ScrollView, + StyleSheet, + Text, + TextInput, + View, +} from 'react-native'; import { useCreateReservation } from '@/features/reservations/hooks/useCreateReservation'; +import { StatusMessage } from '@/shared/ui/StatusMessage'; export default function CreateReservationScreen() { const params = useLocalSearchParams<{ @@ -17,6 +27,7 @@ export default function CreateReservationScreen() { date, startTime, endTime, + isFormComplete, isSubmitting, error, successMessage, @@ -27,60 +38,101 @@ export default function CreateReservationScreen() { } = useCreateReservation({ officeId, officeName }); return ( - - Crear reserva + + + Crear reserva + + Completa la fecha y el horario en formato 24h. + - - Espacio - {officeName ?? 'No indicado'} + + Espacio + {officeName ?? 'No indicado'} + - ID oficina - {officeId ?? 'No indicado'} - + + Condiciones de reserva + Horario permitido: de 08:00 a 20:00 + Duración mínima: 30 minutos + Duración máxima: 8 horas + - + + Fecha + + Formato: YYYY-MM-DD + - + + + Hora de inicio + + Formato 24h + - + + Hora de fin + + Debe ser posterior + + - {error ? {error} : null} - {successMessage ? {successMessage} : null} + {error ? : null} + {successMessage ? : null} - - - {isSubmitting ? 'Guardando...' : 'Guardar reserva'} - - - + + + {isSubmitting ? 'Guardando...' : 'Guardar reserva'} + + + + ); } const styles = StyleSheet.create({ container: { flex: 1, + }, + content: { padding: 16, - gap: 12, + gap: 14, }, title: { fontSize: 28, fontWeight: '700', - marginBottom: 8, + }, + subtitle: { + color: '#555', + marginBottom: 4, }, infoBox: { borderWidth: 1, @@ -90,6 +142,34 @@ const styles = StyleSheet.create({ gap: 6, marginBottom: 8, }, + rulesBox: { + borderWidth: 1, + borderColor: '#d7e3f7', + backgroundColor: '#f4f8ff', + borderRadius: 12, + padding: 12, + gap: 4, + }, + rulesTitle: { + fontSize: 14, + fontWeight: '700', + color: '#1d4f91', + marginBottom: 2, + }, + rulesText: { + color: '#365b86', + fontSize: 13, + }, + field: { + gap: 6, + }, + row: { + flexDirection: 'row', + gap: 12, + }, + rowField: { + flex: 1, + }, label: { fontSize: 14, fontWeight: '700', @@ -106,6 +186,10 @@ const styles = StyleSheet.create({ paddingHorizontal: 14, paddingVertical: 12, }, + helper: { + color: '#666', + fontSize: 12, + }, button: { backgroundColor: '#1f6feb', paddingVertical: 14, @@ -113,14 +197,11 @@ const styles = StyleSheet.create({ alignItems: 'center', marginTop: 8, }, + buttonDisabled: { + backgroundColor: '#8fb5ec', + }, buttonText: { color: '#fff', fontWeight: '600', }, - error: { - color: 'red', - }, - success: { - color: 'green', - }, }); -- cgit v1.2.3-54-g00ecf