1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
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>
<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>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 16,
gap: 12,
},
title: {
fontSize: 28,
fontWeight: '700',
marginBottom: 8,
},
infoBox: {
borderWidth: 1,
borderColor: '#ddd',
borderRadius: 12,
padding: 12,
gap: 6,
marginBottom: 8,
},
label: {
fontSize: 14,
fontWeight: '700',
color: '#444',
},
value: {
fontSize: 16,
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',
},
});
|