diff options
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/(protected)/(tabs)/reservations/index.tsx | 755 | ||||
| -rw-r--r-- | src/app/(protected)/reservations/create.tsx | 526 |
2 files changed, 1022 insertions, 259 deletions
diff --git a/src/app/(protected)/(tabs)/reservations/index.tsx b/src/app/(protected)/(tabs)/reservations/index.tsx index 59d2cad..8eaa80e 100644 --- a/src/app/(protected)/(tabs)/reservations/index.tsx +++ b/src/app/(protected)/(tabs)/reservations/index.tsx @@ -1,14 +1,20 @@ +import { useState } from 'react'; import { ActivityIndicator, Alert, + Platform, Pressable, ScrollView, StyleSheet, Text, View, } from 'react-native'; +import { MaterialIcons } from '@expo/vector-icons'; +import theme from '@/theme'; import { useReservations } from '@/features/reservations/hooks/useReservations'; +const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; + function getReservationWindowStart(date: string, startTime: string): Date { return new Date(`${date}T${startTime}:00`); } @@ -53,6 +59,7 @@ function formatCheckInAt(value: unknown): string { } export default function ReservationsScreen() { + // hook principal de reservas const { activeReservations, historyReservations, @@ -65,7 +72,24 @@ export default function ReservationsScreen() { checkInReservation, } = useReservations(); + // controla la pestaña visible de reservas + const [activeTab, setActiveTab] = useState<'active' | 'history'>('active'); + + // confirmacion antes de cancelar una reserva + // en web usamos window.confirm porque Alert puede no comportarse bien const handleCancelReservation = (reservationId: string) => { + if (Platform.OS === 'web') { + const confirmed = window.confirm( + 'Esta acción marcará la reserva como cancelada.' + ); + + if (confirmed) { + void cancelReservation(reservationId); + } + + return; + } + // en movil sigue usando el Alert Alert.alert( 'Cancelar reserva', 'Esta acción marcará la reserva como cancelada.', @@ -82,6 +106,7 @@ export default function ReservationsScreen() { ); }; + // estado de carga general if (loading) { return ( <View style={styles.center}> @@ -90,12 +115,14 @@ export default function ReservationsScreen() { ); } + // estado de error general if (error) { return ( <View style={styles.center}> <Text style={styles.error}>{error}</Text> - <Pressable style={styles.button} onPress={reload}> - <Text style={styles.buttonText}>Reintentar</Text> + + <Pressable style={styles.primaryButton} onPress={reload}> + <Text style={styles.primaryButtonText}>Reintentar</Text> </Pressable> </View> ); @@ -103,198 +130,636 @@ export default function ReservationsScreen() { return ( <View style={styles.container}> - <Text style={styles.title}>Mis reservas</Text> - - <ScrollView contentContainerStyle={styles.list}> - <View style={styles.section}> - <Text style={styles.sectionTitle}>Activas</Text> - - {activeReservations.length === 0 ? ( - <Text style={styles.empty}>No tienes reservas activas</Text> - ) : ( - activeReservations.map((item) => ( - <View key={item.id} style={styles.card}> - <View style={styles.cardHeader}> - <Text style={styles.cardTitle}>{item.officeName}</Text> - <View - style={[ - styles.statusBadge, - styles.statusActive, - ]} - > - <Text style={styles.statusText}>Activa</Text> - </View> - </View> - <Text>Fecha: {item.date}</Text> - <Text>Inicio: {item.startTime}</Text> - <Text>Fin: {item.endTime}</Text> - <Text> - Llegada: {item.checkInAt ? formatCheckInAt(item.checkInAt) : 'Pendiente'} - </Text> + {/* cabecera superior */} + <View style={styles.topBar}> + <Text style={styles.topBarTitle}>Mis reservas</Text> + </View> - {!item.checkInAt && canCheckIn(item.date, item.startTime, item.endTime) ? ( - <Pressable - style={styles.checkInButton} - onPress={() => { - void checkInReservation(item.id); - }} - disabled={checkingInReservationId === item.id} - > - <Text style={styles.buttonText}> - {checkingInReservationId === item.id - ? 'Registrando llegada...' - : 'He llegado'} - </Text> - </Pressable> - ) : null} - - <Pressable - style={styles.cancelButton} - onPress={() => handleCancelReservation(item.id)} - disabled={cancelingReservationId === item.id} - > - <Text style={styles.buttonText}> - {cancelingReservationId === item.id - ? 'Cancelando...' - : 'Cancelar reserva'} - </Text> - </Pressable> - </View> - )) - )} + <ScrollView + style={styles.scroll} + contentContainerStyle={styles.content} + showsVerticalScrollIndicator={false} + > + {/* pestañas superiores */} + <View style={styles.tabsRow}> + <Pressable + style={[ + styles.tabButton, + activeTab === 'active' && styles.tabButtonActive, + ]} + onPress={() => setActiveTab('active')} + > + <Text + style={[ + styles.tabButtonText, + activeTab === 'active' && styles.tabButtonTextActive, + ]} + > + Activas ({activeReservations.length}) + </Text> + </Pressable> + + <Pressable + style={[ + styles.tabButton, + activeTab === 'history' && styles.tabButtonActive, + ]} + onPress={() => setActiveTab('history')} + > + <Text + style={[ + styles.tabButtonText, + activeTab === 'history' && styles.tabButtonTextActive, + ]} + > + Historial ({historyReservations.length}) + </Text> + </Pressable> </View> - <View style={styles.section}> - <Text style={styles.sectionTitle}>Historial</Text> - - {historyReservations.length === 0 ? ( - <Text style={styles.empty}>No tienes reservas en el historial</Text> - ) : ( - historyReservations.map((item) => ( - <View key={item.id} style={styles.card}> - <View style={styles.cardHeader}> - <Text style={styles.cardTitle}>{item.officeName}</Text> - <View - style={[ - styles.statusBadge, - item.status === 'completed' - ? styles.statusCompleted - : styles.statusCancelled, - ]} - > - <Text style={styles.statusText}> - {item.status === 'completed' ? 'Completada' : 'Cancelada'} - </Text> + {/* seccion de reservas activas */} + {activeTab === 'active' ? ( + <View style={styles.section}> + <View style={styles.sectionHeader}> + <Text style={styles.sectionTitle}>Activas</Text> + </View> + + {activeReservations.length === 0 ? ( + <View style={styles.emptyCard}> + <Text style={styles.emptyTitle}>No tienes reservas activas</Text> + <Text style={styles.emptyText}> + Cuando realices una nueva reserva, aparecerá aquí. + </Text> + </View> + ) : ( + activeReservations.map((item) => ( + <View key={item.id} style={styles.card}> + {/* cabecera de la tarjeta */} + <View style={styles.cardHeader}> + <View style={styles.cardHeaderLeft}> + <View style={styles.cardIconWrap}> + <MaterialIcons + name="business" + size={22} + color={colors.primary} + /> + </View> + + <View style={styles.cardTitleBlock}> + <Text style={styles.cardTitle}>{item.officeName}</Text> + <Text style={styles.cardSubtitle}>Reserva activa</Text> + </View> + </View> + + <View style={[styles.statusBadge, styles.statusActive]}> + <Text style={[styles.statusText, styles.statusTextActive]}> + Activa + </Text> + </View> + </View> + + {/* detalles de la reserva */} + <View style={styles.detailsList}> + <View style={styles.detailRow}> + <MaterialIcons + name="calendar-month" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}>{item.date}</Text> + </View> + + <View style={styles.detailRow}> + <MaterialIcons + name="schedule" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}> + {item.startTime} - {item.endTime} + </Text> + </View> + + <View style={styles.detailRow}> + <MaterialIcons + name="login" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}> + {item.checkInAt + ? `Llegada registrada: ${formatCheckInAt(item.checkInAt)}` + : 'Llegada pendiente'} + </Text> + </View> + </View> + + {/* linea separadora antes de acciones */} + <View style={styles.cardDivider} /> + + {/* boton de check-in visible siempre de forma temporal para ajustar diseño */} + {!item.checkInAt ? ( + <Pressable + style={styles.checkInButton} + onPress={() => { + void checkInReservation(item.id); + }} + disabled={checkingInReservationId === item.id} + > + <Text style={styles.checkInButtonText}> + {checkingInReservationId === item.id + ? 'Registrando llegada...' + : 'He llegado'} + </Text> + </Pressable> + ) : null} + + {/* fila de acciones secundarias */} + <View style={styles.actionsRow}> + {/* boton editar reserva */} + <Pressable + style={({ pressed }) => [ + styles.editButton, + pressed && styles.editButtonPressed, + ]} + > + <Text style={styles.editButtonText}>Editar</Text> + </Pressable> + + {/* boton cancelar */} + <Pressable + style={({ pressed }) => [ + styles.cancelButton, + pressed && styles.cancelButtonPressed, + ]} + onPress={() => handleCancelReservation(item.id)} + disabled={cancelingReservationId === item.id} + > + <View style={styles.cancelContent}> + <MaterialIcons name="cancel" size={14} color="#DC2626" /> + <Text style={styles.cancelButtonText}> + {cancelingReservationId === item.id ? 'Cancelando...' : 'Cancelar'} + </Text> + </View> + </Pressable> </View> </View> - <Text>Fecha: {item.date}</Text> - <Text>Inicio: {item.startTime}</Text> - <Text>Fin: {item.endTime}</Text> - <Text> - Llegada: {item.checkInAt ? formatCheckInAt(item.checkInAt) : 'No registrada'} + )) + )} + </View> + ) : null} + + {/* seccion historial */} + {activeTab === 'history' ? ( + <View style={styles.section}> + <View style={styles.sectionHeader}> + <Text style={styles.sectionTitle}>Historial</Text> + </View> + + {historyReservations.length === 0 ? ( + <View style={styles.emptyCard}> + <Text style={styles.emptyTitle}>No tienes historial</Text> + <Text style={styles.emptyText}> + Aquí verás tus reservas completadas o canceladas. </Text> </View> - )) - )} - </View> + ) : ( + historyReservations.map((item) => ( + <View key={item.id} style={styles.card}> + {/* cabecera de la tarjeta */} + <View style={styles.cardHeader}> + <View style={styles.cardHeaderLeft}> + <View style={styles.cardIconWrap}> + <MaterialIcons + name="business" + size={22} + color={colors.primary} + /> + </View> + + <View style={styles.cardTitleBlock}> + <Text style={styles.cardTitle}>{item.officeName}</Text> + <Text style={styles.cardSubtitle}>Reserva finalizada</Text> + </View> + </View> + + <View + style={[ + styles.statusBadge, + item.status === 'completed' + ? styles.statusCompleted + : styles.statusCancelled, + ]} + > + <Text + style={[ + styles.statusText, + item.status === 'completed' + ? styles.statusTextCompleted + : styles.statusTextCancelled, + ]} + > + {item.status === 'completed' ? 'Completada' : 'Cancelada'} + </Text> + </View> + </View> + + {/* detalles de historial */} + <View style={styles.detailsList}> + <View style={styles.detailRow}> + <MaterialIcons + name="calendar-month" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}>{item.date}</Text> + </View> + + <View style={styles.detailRow}> + <MaterialIcons + name="schedule" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}> + {item.startTime} - {item.endTime} + </Text> + </View> + + <View style={styles.detailRow}> + <MaterialIcons + name="login" + size={16} + color={colors.textSecondary} + /> + <Text style={styles.detailText}> + {item.checkInAt + ? `Llegada registrada: ${formatCheckInAt(item.checkInAt)}` + : 'Llegada no registrada'} + </Text> + </View> + </View> + </View> + )) + )} + </View> + ) : null} </ScrollView> </View> ); } const styles = StyleSheet.create({ + // contenedor principal container: { flex: 1, - padding: 16, + backgroundColor: colors.background, + }, + + // cabecera superior de la pantalla + topBar: { + backgroundColor: colors.surface, + borderBottomWidth: 1, + borderBottomColor: colors.border, + paddingHorizontal: spacing.xl, + paddingTop: spacing.xxxl, + paddingBottom: spacing.lg, + }, + + // titulo de la cabecera + topBarTitle: { + fontSize: typography.xxl, + fontWeight: fontWeight.semibold, + color: colors.text, + textAlign: 'left', + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + }, + + // scroll principal + scroll: { + flex: 1, + backgroundColor: colors.background, }, + + // contenido interno del scroll + content: { + paddingHorizontal: spacing.xl, + paddingTop: spacing.lg, + paddingBottom: spacing.xxxl, + gap: spacing.xl, + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + }, + + // estado de carga / error center: { flex: 1, alignItems: 'center', justifyContent: 'center', - padding: 24, - }, - title: { - fontSize: 28, - fontWeight: '700', - marginBottom: 16, - }, - list: { - gap: 12, - paddingBottom: 24, + padding: spacing.xxxl, + gap: spacing.md, + backgroundColor: colors.background, }, + + // seccion general section: { - gap: 12, + gap: spacing.md, }, + + // cabecera de seccion + sectionHeader: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'space-between', + }, + + // titulo de seccion sectionTitle: { - fontSize: 20, - fontWeight: '700', + fontSize: typography.xl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // fila de pestañas superiores + tabsRow: { + flexDirection: 'row', + gap: spacing.sm, + backgroundColor: '#E9EEF5', + borderRadius: radius.xxl, + padding: spacing.xs, + }, + + // boton de pestaña + tabButton: { + flex: 1, + paddingVertical: spacing.md, + borderRadius: radius.xl, + alignItems: 'center', }, + + // boton activo + tabButtonActive: { + backgroundColor: colors.surface, + ...shadows.card, + }, + + // texto de pestaña + tabButtonText: { + color: colors.textSecondary, + fontSize: typography.md, + fontWeight: fontWeight.medium, + }, + + // texto de pestaña activa + tabButtonTextActive: { + color: colors.text, + }, + + // tarjeta base de reserva card: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.lg, borderWidth: 1, - borderColor: '#ddd', - borderRadius: 12, - padding: 16, - gap: 6, + borderColor: colors.border, + gap: spacing.md, + ...shadows.card, }, + + // cabecera de la tarjeta cardHeader: { flexDirection: 'row', - alignItems: 'center', + alignItems: 'flex-start', justifyContent: 'space-between', - gap: 12, + gap: spacing.md, }, - cardTitle: { - fontSize: 18, - fontWeight: '600', + + // bloque izquierdo de la cabecera de la card + cardHeaderLeft: { + flexDirection: 'row', + alignItems: 'flex-start', + gap: spacing.md, + flex: 1, + }, + + // contenedor del icono del edificio + cardIconWrap: { + width: 40, + height: 40, + borderRadius: radius.md, + backgroundColor: colors.primarySoft, + alignItems: 'center', + justifyContent: 'center', + }, + + // bloque de titulo de tarjeta + cardTitleBlock: { flex: 1, + gap: 2, + }, + + // titulo principal de la reserva + cardTitle: { + fontSize: typography.lg, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // subtitulo pequeño + cardSubtitle: { + fontSize: typography.sm, + color: colors.textSecondary, }, + + // badge comun de estado statusBadge: { borderRadius: 999, - paddingHorizontal: 10, - paddingVertical: 4, + paddingHorizontal: spacing.sm, + paddingVertical: spacing.xs, }, + + // estado activa statusActive: { - backgroundColor: '#d7f5df', - }, - statusCancelled: { - backgroundColor: '#f3d8d8', + backgroundColor: '#DCFCE7', }, + + // estado completada statusCompleted: { - backgroundColor: '#dce8f8', + backgroundColor: '#DBEAFE', }, + + // estado cancelada + statusCancelled: { + backgroundColor: '#FEE2E2', + }, + + // texto base del estado statusText: { - fontSize: 12, - fontWeight: '700', - color: '#333', + fontSize: typography.xs, + fontWeight: fontWeight.semibold, }, - error: { - color: 'red', - marginBottom: 12, + + // color texto activa + statusTextActive: { + color: '#166534', }, - button: { - backgroundColor: '#1f6feb', - paddingHorizontal: 16, - paddingVertical: 12, - borderRadius: 10, + + // color texto completada + statusTextCompleted: { + color: '#1D4ED8', }, - buttonText: { - color: '#fff', - fontWeight: '600', + + // color texto cancelada + statusTextCancelled: { + color: '#B91C1C', }, - cancelButton: { - backgroundColor: '#c62828', - paddingVertical: 12, - borderRadius: 10, + + // lista de detalles + detailsList: { + gap: spacing.sm, + }, + + // fila individual de detalle + detailRow: { + flexDirection: 'row', alignItems: 'center', - marginTop: 8, + gap: spacing.sm, + }, + + // texto del detalle + detailText: { + fontSize: typography.md, + color: colors.textSecondary, + flex: 1, + }, + + // linea separadora antes de acciones + cardDivider: { + height: 1, + backgroundColor: colors.divider, + marginTop: spacing.xs, + }, + + // boton principal de reintento + primaryButton: { + backgroundColor: colors.primary, + paddingHorizontal: spacing.xl, + paddingVertical: spacing.md, + borderRadius: radius.md, + alignItems: 'center', + }, + + // texto del boton principal + primaryButtonText: { + color: colors.white, + fontWeight: fontWeight.semibold, }, + + // boton de check-in checkInButton: { - backgroundColor: '#2e7d32', - paddingVertical: 12, - borderRadius: 10, + backgroundColor: colors.successBg, + paddingVertical: spacing.md, + borderRadius: radius.md, + alignItems: 'center', + marginTop: spacing.xs, + }, + + // texto del boton de check-in + checkInButtonText: { + color: colors.successText, + fontWeight: fontWeight.semibold, + }, + + // fila de acciones secundarias + // coloca editar a la izquierda y cancelar a la derecha + actionsRow: { + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + marginTop: spacing.xs, + }, + + // boton editar reserva + editButton: { + paddingVertical: spacing.sm, + paddingHorizontal: spacing.md, + borderRadius: radius.md, + backgroundColor: colors.surface, + alignItems: 'center', + justifyContent: 'center', + }, + + // estado pulsado del boton editar + editButtonPressed: { + backgroundColor: '#EAF2FF', + }, + + // texto del boton editar + editButtonText: { + color: colors.primary, + fontWeight: fontWeight.medium, + fontSize: typography.sm, + }, + + // boton cancelar reserva + cancelButton: { + paddingVertical: spacing.sm, + paddingHorizontal: spacing.md, + borderRadius: radius.md, + backgroundColor: colors.surface, + alignItems: 'center', + justifyContent: 'center', + }, + + // estado pulsado del boton cancelar + cancelButtonPressed: { + backgroundColor: '#FEECEC', + }, + + // texto del boton cancelar + cancelButtonText: { + color: '#DC2626', + fontWeight: fontWeight.medium, + fontSize: typography.sm, + }, + + // contenido interno del boton cancelar + cancelContent: { + flexDirection: 'row', alignItems: 'center', - marginTop: 8, + gap: spacing.xs, }, - empty: { - color: '#666', + + // tarjeta vacia + emptyCard: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.lg, + borderWidth: 1, + borderColor: colors.border, + gap: spacing.xs, + }, + + // titulo de estado vacio + emptyTitle: { + fontSize: typography.md, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // texto de estado vacio + emptyText: { + fontSize: typography.sm, + color: colors.textSecondary, + lineHeight: 18, + }, + + // error general + error: { + color: colors.error, + textAlign: 'center', }, -}); +});
\ No newline at end of file diff --git a/src/app/(protected)/reservations/create.tsx b/src/app/(protected)/reservations/create.tsx index 65a16f5..8d03275 100644 --- a/src/app/(protected)/reservations/create.tsx +++ b/src/app/(protected)/reservations/create.tsx @@ -1,4 +1,4 @@ -import { useLocalSearchParams } from 'expo-router'; +import { Link, useLocalSearchParams } from 'expo-router'; import { KeyboardAvoidingView, Platform, @@ -9,10 +9,15 @@ import { TextInput, View, } from 'react-native'; +import { MaterialIcons } from '@expo/vector-icons'; +import theme from '@/theme'; import { useCreateReservation } from '@/features/reservations/hooks/useCreateReservation'; import { StatusMessage } from '@/shared/ui/StatusMessage'; +const { colors, spacing, radius, typography, fontWeight, layout, shadows } = theme; + export default function CreateReservationScreen() { + // parametros recibidos al entrar desde otra pantalla const params = useLocalSearchParams<{ officeId?: string; officeName?: string; @@ -23,6 +28,7 @@ export default function CreateReservationScreen() { const officeName = typeof params.officeName === 'string' ? params.officeName : undefined; + // hook de creacion de reserva const { date, startTime, @@ -42,166 +48,458 @@ export default function CreateReservationScreen() { 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> + {/* cabecera superior */} + <View style={styles.topBar}> + <Text style={styles.topBarTitle}>Crear reserva</Text> + </View> + + <ScrollView + style={styles.scroll} + contentContainerStyle={styles.content} + showsVerticalScrollIndicator={false} + > + {/* texto introductorio */} + <View style={styles.introSection}> + <Text style={styles.title}>Nueva reserva</Text> + <Text style={styles.subtitle}> + Selecciona el espacio, la fecha y el horario de tu reserva. + </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> + {/* tarjeta del espacio seleccionado */} + <View style={styles.card}> + <View style={styles.cardHeader}> + <View style={styles.cardHeaderLeft}> + <View style={styles.cardIconWrap}> + <MaterialIcons + name="business" + size={22} + color={colors.primary} + /> + </View> + + <View style={styles.cardTitleBlock}> + <Text style={styles.cardTitle}>Espacio</Text> + <Text style={styles.cardSubtitle}> + {officeName ?? 'No indicado'} + </Text> + </View> + </View> + </View> + + {/* enlace para volver a oficinas */} + <View style={styles.changeOfficeRow}> + <Link href="/(protected)/(tabs)/offices" asChild> + <Pressable + style={({ pressed }) => [ + styles.changeOfficeButton, + pressed && styles.changeOfficeButtonPressed, + ]} + > + <Text style={styles.changeOfficeButtonText}> + Cambiar oficina + </Text> + </Pressable> + </Link> + </View> </View> - <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> + {/* tarjeta de condiciones de reserva */} + <View style={styles.rulesCard}> + <Text style={styles.rulesTitle}>Condiciones de reserva</Text> + + <View style={styles.rulesList}> + <View style={styles.ruleRow}> + <MaterialIcons + name="schedule" + size={16} + color={colors.primary} + /> + <Text style={styles.ruleText}> + Horario permitido: de 08:00 a 20:00 + </Text> + </View> + + <View style={styles.ruleRow}> + <MaterialIcons + name="timer" + size={16} + color={colors.primary} + /> + <Text style={styles.ruleText}> + Duración mínima: 30 minutos + </Text> + </View> + + <View style={styles.ruleRow}> + <MaterialIcons + name="hourglass-bottom" + size={16} + color={colors.primary} + /> + <Text style={styles.ruleText}> + Duración máxima: 8 horas + </Text> + </View> + </View> </View> - <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> + {/* tarjeta del formulario */} + <View style={styles.card}> + <Text style={styles.sectionTitle}>Datos de la reserva</Text> + + {/* campo fecha */} + <View style={styles.field}> + <Text style={styles.label}>Fecha</Text> + + {/* en web usamos calendario nativo */} + {Platform.OS === 'web' ? ( + <input + type="date" + value={date} + onChange={(e) => setDate(e.target.value)} + min={new Date().toISOString().split('T')[0]} + style={{ + height: 46, + border: `1px solid ${colors.border}`, + borderRadius: radius.md, + padding: '0 14px', + fontSize: 14, + color: colors.text, + backgroundColor: colors.background, + outline: 'none', + }} + /> + ) : ( + <TextInput + style={styles.input} + placeholder="YYYY-MM-DD" + placeholderTextColor={colors.textSecondary} + value={date} + onChangeText={setDate} + keyboardType="number-pad" + maxLength={10} + /> + )} + + <Text style={styles.helper}> + {Platform.OS === 'web' + ? 'Selecciona una fecha en el calendario' + : 'Formato: YYYY-MM-DD'} + </Text> </View> - <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> + {/* fila de horas */} + <View style={styles.timeRow}> + <View style={[styles.field, styles.timeField]}> + <Text style={styles.label}>Hora de inicio</Text> + <TextInput + style={styles.input} + placeholder="09:00" + placeholderTextColor={colors.textSecondary} + value={startTime} + onChangeText={setStartTime} + keyboardType="number-pad" + maxLength={5} + /> + <Text style={styles.helper}>Formato 24h</Text> + </View> + + <View style={[styles.field, styles.timeField]}> + <Text style={styles.label}>Hora de fin</Text> + <TextInput + style={styles.input} + placeholder="10:00" + placeholderTextColor={colors.textSecondary} + value={endTime} + onChangeText={setEndTime} + keyboardType="number-pad" + maxLength={5} + /> + <Text style={styles.helper}>Debe ser posterior</Text> + </View> </View> - </View> - {error ? <StatusMessage message={error} /> : null} - {successMessage ? <StatusMessage message={successMessage} tone="success" /> : null} + {/* mensajes de error / exito */} + {error ? <StatusMessage message={error} /> : null} + {successMessage ? ( + <StatusMessage message={successMessage} tone="success" /> + ) : null} - <Pressable - style={[styles.button, (!isFormComplete || isSubmitting) && styles.buttonDisabled]} - onPress={submit} - disabled={!isFormComplete || isSubmitting} - > - <Text style={styles.buttonText}> - {isSubmitting ? 'Guardando...' : 'Guardar reserva'} - </Text> - </Pressable> + {/* boton principal de guardar */} + <Pressable + style={({ pressed }) => [ + styles.primaryButton, + (!isFormComplete || isSubmitting) && styles.primaryButtonDisabled, + pressed && + isFormComplete && + !isSubmitting && + styles.primaryButtonPressed, + ]} + onPress={submit} + disabled={!isFormComplete || isSubmitting} + > + <Text style={styles.primaryButtonText}> + {isSubmitting ? 'Guardando...' : 'Guardar reserva'} + </Text> + </Pressable> + </View> </ScrollView> </KeyboardAvoidingView> ); } const styles = StyleSheet.create({ + // contenedor principal container: { flex: 1, + backgroundColor: colors.background, }, + + // cabecera superior de la pantalla + topBar: { + backgroundColor: colors.surface, + borderBottomWidth: 1, + borderBottomColor: colors.border, + paddingHorizontal: spacing.xl, + paddingTop: spacing.xxxl, + paddingBottom: spacing.lg, + }, + + // titulo de la cabecera superior + topBarTitle: { + fontSize: typography.xxl, + fontWeight: fontWeight.semibold, + color: colors.text, + textAlign: 'left', + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', + }, + + // scroll principal + scroll: { + flex: 1, + backgroundColor: colors.background, + }, + + // contenido interno del scroll content: { - padding: 16, - gap: 14, + paddingHorizontal: spacing.xl, + paddingTop: spacing.lg, + paddingBottom: spacing.xxxl, + gap: spacing.xl, + maxWidth: layout.contentWidth, + width: '100%', + alignSelf: 'center', }, + + // bloque introductorio + introSection: { + gap: spacing.xs, + }, + + // titulo principal de la pantalla title: { - fontSize: 28, - fontWeight: '700', + fontSize: typography.xxxl, + fontWeight: fontWeight.semibold, + color: colors.text, }, + + // subtitulo explicativo subtitle: { - color: '#555', - marginBottom: 4, + fontSize: typography.md, + color: colors.textSecondary, + lineHeight: 20, }, - infoBox: { + + // tarjeta base reutilizable + card: { + backgroundColor: colors.surface, + borderRadius: radius.xxl, + padding: spacing.lg, borderWidth: 1, - borderColor: '#ddd', - borderRadius: 12, - padding: 12, - gap: 6, - marginBottom: 8, + borderColor: colors.border, + gap: spacing.md, + ...shadows.card, }, - rulesBox: { + + // tarjeta de condiciones con tono azul suave + rulesCard: { + backgroundColor: '#F4F8FF', + borderRadius: radius.xxl, + padding: spacing.lg, borderWidth: 1, - borderColor: '#d7e3f7', - backgroundColor: '#f4f8ff', - borderRadius: 12, - padding: 12, - gap: 4, + borderColor: '#D7E3F7', + gap: spacing.md, + }, + + // cabecera de tarjeta + cardHeader: { + flexDirection: 'row', + alignItems: 'flex-start', + justifyContent: 'space-between', + gap: spacing.md, + }, + + // bloque izquierdo de cabecera + cardHeaderLeft: { + flexDirection: 'row', + alignItems: 'flex-start', + gap: spacing.md, + flex: 1, }, + + // contenedor del icono del espacio + cardIconWrap: { + width: 40, + height: 40, + borderRadius: radius.md, + backgroundColor: colors.primarySoft, + alignItems: 'center', + justifyContent: 'center', + }, + + // bloque de textos de la tarjeta + cardTitleBlock: { + flex: 1, + gap: 2, + }, + + // titulo pequeño de tarjeta + cardTitle: { + fontSize: typography.sm, + color: colors.textSecondary, + fontWeight: fontWeight.regular, + }, + + // valor principal de tarjeta + cardSubtitle: { + fontSize: typography.lg, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // boton secundario para cambiar oficina + changeOfficeRow: { + width: '100%', + alignItems: 'flex-end', + }, + changeOfficeButton: { + paddingVertical: spacing.xs, + paddingHorizontal: spacing.sm, + borderRadius: radius.md, + }, + + // estado pulsado del boton cambiar oficina + changeOfficeButtonPressed: { + backgroundColor: '#EAF2FF', + }, + + // texto del boton cambiar oficina + changeOfficeButtonText: { + color: colors.primary, + fontWeight: fontWeight.medium, + fontSize: typography.sm, + }, + + // titulo interno de seccion + sectionTitle: { + fontSize: typography.xl, + fontWeight: fontWeight.semibold, + color: colors.text, + }, + + // titulo de condiciones rulesTitle: { - fontSize: 14, - fontWeight: '700', - color: '#1d4f91', - marginBottom: 2, + fontSize: typography.md, + fontWeight: fontWeight.semibold, + color: colors.primary, }, - rulesText: { - color: '#365b86', - fontSize: 13, + + // lista de reglas + rulesList: { + gap: spacing.sm, + }, + + // fila de una regla + ruleRow: { + flexDirection: 'row', + alignItems: 'center', + gap: spacing.sm, }, + + // texto de regla + ruleText: { + fontSize: typography.md, + color: colors.textSecondary, + flex: 1, + }, + + // bloque de campo individual field: { - gap: 6, + gap: spacing.sm, }, - row: { + + // fila de campos de hora + timeRow: { flexDirection: 'row', - gap: 12, + gap: spacing.lg, }, - rowField: { + + // ancho flexible de cada campo de hora + timeField: { flex: 1, }, + + // etiqueta del campo label: { - fontSize: 14, - fontWeight: '700', - color: '#444', - }, - value: { - fontSize: 16, - color: '#111', + fontSize: typography.md, + fontWeight: fontWeight.medium, + color: colors.text, }, + + // input de formulario input: { borderWidth: 1, - borderColor: '#ccc', - borderRadius: 10, - paddingHorizontal: 14, - paddingVertical: 12, + borderColor: colors.border, + borderRadius: radius.md, + paddingHorizontal: spacing.lg, + paddingVertical: spacing.md, + backgroundColor: colors.background, + color: colors.text, }, + + // texto de ayuda bajo el input helper: { - color: '#666', - fontSize: 12, + color: colors.textSecondary, + fontSize: typography.sm, }, - button: { - backgroundColor: '#1f6feb', - paddingVertical: 14, - borderRadius: 10, + + // boton principal de guardar + primaryButton: { + backgroundColor: colors.primary, + paddingVertical: spacing.lg, + borderRadius: radius.md, alignItems: 'center', - marginTop: 8, + justifyContent: 'center', + marginTop: spacing.sm, }, - buttonDisabled: { - backgroundColor: '#8fb5ec', + + // estado pulsado del boton principal + primaryButtonPressed: { + backgroundColor: '#185DCB', }, - buttonText: { - color: '#fff', - fontWeight: '600', + + // boton deshabilitado + primaryButtonDisabled: { + backgroundColor: '#8FB5EC', + }, + + // texto del boton principal + primaryButtonText: { + color: colors.white, + fontWeight: fontWeight.semibold, + fontSize: typography.md, }, -}); +});
\ No newline at end of file |