From 35998370a09e13511514342ca4315821e83c53b8 Mon Sep 17 00:00:00 2001 From: Anita Date: Sat, 18 Apr 2026 13:33:35 +0100 Subject: feat(reservations): rediseño listado, create con calendario, check-in y navegación refs #7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(protected)/reservations/create.tsx | 526 ++++++++++++++++++++++------ 1 file changed, 412 insertions(+), 114 deletions(-) (limited to 'src/app/(protected)/reservations') 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} > - - Crear reserva - - Completa la fecha y el horario en formato 24h. - - - - Espacio - {officeName ?? 'No indicado'} + {/* cabecera superior */} + + Crear reserva + + + + {/* texto introductorio */} + + Nueva reserva + + Selecciona el espacio, la fecha y el horario de tu reserva. + - - Condiciones de reserva - Horario permitido: de 08:00 a 20:00 - Duración mínima: 30 minutos - Duración máxima: 8 horas + {/* tarjeta del espacio seleccionado */} + + + + + + + + + Espacio + + {officeName ?? 'No indicado'} + + + + + + {/* enlace para volver a oficinas */} + + + [ + styles.changeOfficeButton, + pressed && styles.changeOfficeButtonPressed, + ]} + > + + Cambiar oficina + + + + - - Fecha - - Formato: YYYY-MM-DD + {/* tarjeta de condiciones de reserva */} + + Condiciones de reserva + + + + + + Horario permitido: de 08:00 a 20:00 + + + + + + + Duración mínima: 30 minutos + + + + + + + Duración máxima: 8 horas + + + - - - Hora de inicio - - Formato 24h + {/* tarjeta del formulario */} + + Datos de la reserva + + {/* campo fecha */} + + Fecha + + {/* en web usamos calendario nativo */} + {Platform.OS === 'web' ? ( + 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', + }} + /> + ) : ( + + )} + + + {Platform.OS === 'web' + ? 'Selecciona una fecha en el calendario' + : 'Formato: YYYY-MM-DD'} + - - Hora de fin - - Debe ser posterior + {/* fila de horas */} + + + Hora de inicio + + Formato 24h + + + + Hora de fin + + Debe ser posterior + - - {error ? : null} - {successMessage ? : null} + {/* mensajes de error / exito */} + {error ? : null} + {successMessage ? ( + + ) : null} - - - {isSubmitting ? 'Guardando...' : 'Guardar reserva'} - - + {/* boton principal de guardar */} + [ + styles.primaryButton, + (!isFormComplete || isSubmitting) && styles.primaryButtonDisabled, + pressed && + isFormComplete && + !isSubmitting && + styles.primaryButtonPressed, + ]} + onPress={submit} + disabled={!isFormComplete || isSubmitting} + > + + {isSubmitting ? 'Guardando...' : 'Guardar reserva'} + + + ); } 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 -- cgit v1.2.3-54-g00ecf