summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)/reservations/create.tsx
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 13:03:25 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-01 13:03:25 +0100
commit08ce78dbd97ad792e163482f454f285557c7cdd0 (patch)
tree998ce8d7d48f8344d9ec34691809f2482cde5136 /src/app/(protected)/reservations/create.tsx
parentc927739f8f221feabb6e19af2c2667eda905a2eb (diff)
Mejoras de UX y feedback de errores; y, manejo de status de reserva
Diffstat (limited to 'src/app/(protected)/reservations/create.tsx')
-rw-r--r--src/app/(protected)/reservations/create.tsx167
1 files changed, 124 insertions, 43 deletions
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 (
- <View style={styles.container}>
- <Text style={styles.title}>Crear reserva</Text>
+ <KeyboardAvoidingView
+ style={styles.container}
+ behavior={Platform.OS === 'ios' ? 'padding' : undefined}
+ >
+ <ScrollView contentContainerStyle={styles.content}>
+ <Text style={styles.title}>Crear reserva</Text>
+ <Text style={styles.subtitle}>
+ Completa la fecha y el horario en formato 24h.
+ </Text>
- <View style={styles.infoBox}>
- <Text style={styles.label}>Espacio</Text>
- <Text style={styles.value}>{officeName ?? 'No indicado'}</Text>
+ <View style={styles.infoBox}>
+ <Text style={styles.label}>Espacio</Text>
+ <Text style={styles.value}>{officeName ?? 'No indicado'}</Text>
+ </View>
- <Text style={styles.label}>ID oficina</Text>
- <Text style={styles.value}>{officeId ?? 'No indicado'}</Text>
- </View>
+ <View style={styles.rulesBox}>
+ <Text style={styles.rulesTitle}>Condiciones de reserva</Text>
+ <Text style={styles.rulesText}>Horario permitido: de 08:00 a 20:00</Text>
+ <Text style={styles.rulesText}>Duración mínima: 30 minutos</Text>
+ <Text style={styles.rulesText}>Duración máxima: 8 horas</Text>
+ </View>
- <TextInput
- style={styles.input}
- placeholder="Fecha (YYYY-MM-DD)"
- value={date}
- onChangeText={setDate}
- />
+ <View style={styles.field}>
+ <Text style={styles.label}>Fecha</Text>
+ <TextInput
+ style={styles.input}
+ placeholder="2026-04-01"
+ value={date}
+ onChangeText={setDate}
+ keyboardType="number-pad"
+ maxLength={10}
+ />
+ <Text style={styles.helper}>Formato: YYYY-MM-DD</Text>
+ </View>
- <TextInput
- style={styles.input}
- placeholder="Hora inicio (HH:MM)"
- value={startTime}
- onChangeText={setStartTime}
- />
+ <View style={styles.row}>
+ <View style={[styles.field, styles.rowField]}>
+ <Text style={styles.label}>Hora de inicio</Text>
+ <TextInput
+ style={styles.input}
+ placeholder="09:00"
+ value={startTime}
+ onChangeText={setStartTime}
+ keyboardType="number-pad"
+ maxLength={5}
+ />
+ <Text style={styles.helper}>Formato 24h</Text>
+ </View>
- <TextInput
- style={styles.input}
- placeholder="Hora fin (HH:MM)"
- value={endTime}
- onChangeText={setEndTime}
- />
+ <View style={[styles.field, styles.rowField]}>
+ <Text style={styles.label}>Hora de fin</Text>
+ <TextInput
+ style={styles.input}
+ placeholder="10:00"
+ value={endTime}
+ onChangeText={setEndTime}
+ keyboardType="number-pad"
+ maxLength={5}
+ />
+ <Text style={styles.helper}>Debe ser posterior</Text>
+ </View>
+ </View>
- {error ? <Text style={styles.error}>{error}</Text> : null}
- {successMessage ? <Text style={styles.success}>{successMessage}</Text> : null}
+ {error ? <StatusMessage message={error} /> : null}
+ {successMessage ? <StatusMessage message={successMessage} tone="success" /> : null}
- <Pressable style={styles.button} onPress={submit} disabled={isSubmitting}>
- <Text style={styles.buttonText}>
- {isSubmitting ? 'Guardando...' : 'Guardar reserva'}
- </Text>
- </Pressable>
- </View>
+ <Pressable
+ style={[styles.button, (!isFormComplete || isSubmitting) && styles.buttonDisabled]}
+ onPress={submit}
+ disabled={!isFormComplete || isSubmitting}
+ >
+ <Text style={styles.buttonText}>
+ {isSubmitting ? 'Guardando...' : 'Guardar reserva'}
+ </Text>
+ </Pressable>
+ </ScrollView>
+ </KeyboardAvoidingView>
);
}
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',
- },
});