diff options
Diffstat (limited to 'src/app/(protected)/reservations/create.tsx')
| -rw-r--r-- | src/app/(protected)/reservations/create.tsx | 110 |
1 files changed, 104 insertions, 6 deletions
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 ( <View style={styles.container}> <Text style={styles.title}>Crear reserva</Text> - <Text style={styles.text}>Pantalla en construcción.</Text> + + <View style={styles.infoBox}> + <Text style={styles.label}>Espacio</Text> + <Text style={styles.value}>{officeName ?? 'No indicado'}</Text> + + <Text style={styles.label}>ID oficina</Text> + <Text style={styles.value}>{officeId ?? 'No indicado'}</Text> + </View> + + <TextInput + style={styles.input} + placeholder="Fecha (YYYY-MM-DD)" + value={date} + onChangeText={setDate} + /> + + <TextInput + style={styles.input} + placeholder="Hora inicio (HH:MM)" + value={startTime} + onChangeText={setStartTime} + /> + + <TextInput + style={styles.input} + placeholder="Hora fin (HH:MM)" + value={endTime} + onChangeText={setEndTime} + /> + + {error ? <Text style={styles.error}>{error}</Text> : null} + {successMessage ? <Text style={styles.success}>{successMessage}</Text> : null} + + <Pressable style={styles.button} onPress={submit} disabled={isSubmitting}> + <Text style={styles.buttonText}> + {isSubmitting ? 'Guardando...' : 'Guardar reserva'} + </Text> + </Pressable> </View> ); } @@ -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', }, }); |