From 31584b4e5a3a551e2ceb15281a38677c39c46e12 Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Mon, 30 Mar 2026 15:55:32 +0100 Subject: Offices logic --- src/app/(protected)/(tabs)/_layout.tsx | 24 +++++ src/app/(protected)/(tabs)/_layout.tsx~ | 0 src/app/(protected)/(tabs)/home.tsx | 50 +++++++++ src/app/(protected)/(tabs)/offices/index.tsx | 107 +++++++++++++++++++ src/app/(protected)/(tabs)/profile/index.tsx | 28 +++++ src/app/(protected)/(tabs)/reservations/index.tsx | 28 +++++ src/app/(protected)/home.tsx | 50 --------- src/app/(protected)/offices/[officeId].tsx | 119 ++++++++++++++++++++++ src/app/(protected)/offices/index.tsx | 0 src/app/(protected)/profile/index.tsx | 0 src/app/(protected)/reservations/create.tsx | 28 +++++ src/app/(protected)/reservations/index.tsx | 0 12 files changed, 384 insertions(+), 50 deletions(-) create mode 100644 src/app/(protected)/(tabs)/_layout.tsx create mode 100644 src/app/(protected)/(tabs)/_layout.tsx~ create mode 100644 src/app/(protected)/(tabs)/home.tsx create mode 100644 src/app/(protected)/(tabs)/offices/index.tsx create mode 100644 src/app/(protected)/(tabs)/profile/index.tsx create mode 100644 src/app/(protected)/(tabs)/reservations/index.tsx delete mode 100644 src/app/(protected)/home.tsx delete mode 100644 src/app/(protected)/offices/index.tsx delete mode 100644 src/app/(protected)/profile/index.tsx delete mode 100644 src/app/(protected)/reservations/index.tsx (limited to 'src/app/(protected)') diff --git a/src/app/(protected)/(tabs)/_layout.tsx b/src/app/(protected)/(tabs)/_layout.tsx new file mode 100644 index 0000000..0b71c6d --- /dev/null +++ b/src/app/(protected)/(tabs)/_layout.tsx @@ -0,0 +1,24 @@ +import { Tabs } from 'expo-router'; + +export default function TabsLayout() { + return ( + + + + + + + ); +} diff --git a/src/app/(protected)/(tabs)/_layout.tsx~ b/src/app/(protected)/(tabs)/_layout.tsx~ new file mode 100644 index 0000000..e69de29 diff --git a/src/app/(protected)/(tabs)/home.tsx b/src/app/(protected)/(tabs)/home.tsx new file mode 100644 index 0000000..76a5bda --- /dev/null +++ b/src/app/(protected)/(tabs)/home.tsx @@ -0,0 +1,50 @@ +import { Pressable, StyleSheet, Text, View } from 'react-native'; +import { useAuthSession } from '@/providers/AuthProvider'; + +export default function HomeScreen() { + const { user, logout } = useAuthSession(); + + return ( + + Inicio + + Bienvenido{user?.displayName ? `, ${user.displayName}` : ''} + + {user?.email} + + + Cerrar sesión + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + justifyContent: 'center', + padding: 24, + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + subtitle: { + fontSize: 18, + }, + email: { + color: '#555', + marginBottom: 20, + }, + button: { + backgroundColor: '#c62828', + paddingVertical: 14, + borderRadius: 10, + alignItems: 'center', + }, + buttonText: { + color: '#fff', + fontWeight: '600', + }, +}); diff --git a/src/app/(protected)/(tabs)/offices/index.tsx b/src/app/(protected)/(tabs)/offices/index.tsx new file mode 100644 index 0000000..23445ee --- /dev/null +++ b/src/app/(protected)/(tabs)/offices/index.tsx @@ -0,0 +1,107 @@ +import { Link } from 'expo-router'; +import { + ActivityIndicator, + FlatList, + Pressable, + StyleSheet, + Text, + View, +} from 'react-native'; +import { useOffices } from '@/features/offices/hooks/useOffices'; + +export default function OfficesScreen() { + const { offices, loading, error, reload } = useOffices(); + + if (loading) { + return ( + + + + ); + } + + if (error) { + return ( + + {error} + + Reintentar + + + ); + } + + return ( + + Espacios + + item.id} + contentContainerStyle={styles.list} + ListEmptyComponent={ + No hay espacios disponibles + } + renderItem={({ item }) => ( + + + {item.name} + {item.location} + Capacidad: {item.capacity} + {item.description ? {item.description} : null} + + + )} + /> + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + }, + center: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + padding: 24, + }, + title: { + fontSize: 28, + fontWeight: '700', + marginBottom: 16, + }, + list: { + gap: 12, + }, + card: { + borderWidth: 1, + borderColor: '#ddd', + borderRadius: 12, + padding: 16, + gap: 6, + }, + cardTitle: { + fontSize: 18, + fontWeight: '600', + }, + error: { + color: 'red', + marginBottom: 12, + }, + button: { + backgroundColor: '#1f6feb', + paddingHorizontal: 16, + paddingVertical: 12, + borderRadius: 10, + }, + buttonText: { + color: '#fff', + fontWeight: '600', + }, + empty: { + color: '#666', + }, +}); diff --git a/src/app/(protected)/(tabs)/profile/index.tsx b/src/app/(protected)/(tabs)/profile/index.tsx new file mode 100644 index 0000000..a59d568 --- /dev/null +++ b/src/app/(protected)/(tabs)/profile/index.tsx @@ -0,0 +1,28 @@ +import { StyleSheet, Text, View } from 'react-native'; + +export default function ProfileScreen() { + return ( + + Perfil + Pantalla en construcción. + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + justifyContent: 'center', + alignItems: 'center', + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + text: { + fontSize: 16, + color: '#555', + }, +}); diff --git a/src/app/(protected)/(tabs)/reservations/index.tsx b/src/app/(protected)/(tabs)/reservations/index.tsx new file mode 100644 index 0000000..817ec6e --- /dev/null +++ b/src/app/(protected)/(tabs)/reservations/index.tsx @@ -0,0 +1,28 @@ +import { StyleSheet, Text, View } from 'react-native'; + +export default function ReservationsScreen() { + return ( + + Reservas + Pantalla en construcción. + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + justifyContent: 'center', + alignItems: 'center', + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + text: { + fontSize: 16, + color: '#555', + }, +}); diff --git a/src/app/(protected)/home.tsx b/src/app/(protected)/home.tsx deleted file mode 100644 index 76a5bda..0000000 --- a/src/app/(protected)/home.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Pressable, StyleSheet, Text, View } from 'react-native'; -import { useAuthSession } from '@/providers/AuthProvider'; - -export default function HomeScreen() { - const { user, logout } = useAuthSession(); - - return ( - - Inicio - - Bienvenido{user?.displayName ? `, ${user.displayName}` : ''} - - {user?.email} - - - Cerrar sesión - - - ); -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - padding: 24, - gap: 12, - }, - title: { - fontSize: 28, - fontWeight: '700', - }, - subtitle: { - fontSize: 18, - }, - email: { - color: '#555', - marginBottom: 20, - }, - button: { - backgroundColor: '#c62828', - paddingVertical: 14, - borderRadius: 10, - alignItems: 'center', - }, - buttonText: { - color: '#fff', - fontWeight: '600', - }, -}); diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx index e69de29..77fd610 100644 --- a/src/app/(protected)/offices/[officeId].tsx +++ b/src/app/(protected)/offices/[officeId].tsx @@ -0,0 +1,119 @@ +import { Link, useLocalSearchParams } from 'expo-router'; +import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; +import { useOffice } from '@/features/offices/hooks/useOffice'; + +export default function OfficeDetailScreen() { + const params = useLocalSearchParams<{ officeId: string }>(); + const officeId = typeof params.officeId === 'string' ? params.officeId : undefined; + + const { office, loading, error, reload } = useOffice(officeId); + + if (loading) { + return ( + + + + ); + } + + if (error || !office) { + return ( + + {error ?? 'No se pudo cargar la oficina'} + + + Reintentar + + + + + Volver a espacios + + + + ); + } + + return ( + + {office.name} + + + Ubicación + {office.location} + + Capacidad + {office.capacity} personas + + {office.description ? ( + <> + Descripción + {office.description} + + ) : null} + + + + + Reservar este espacio + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + gap: 16, + }, + center: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + padding: 24, + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + card: { + borderWidth: 1, + borderColor: '#ddd', + borderRadius: 12, + padding: 16, + gap: 10, + }, + label: { + fontSize: 14, + fontWeight: '700', + color: '#444', + }, + value: { + fontSize: 16, + color: '#111', + }, + button: { + backgroundColor: '#1f6feb', + paddingVertical: 14, + borderRadius: 10, + alignItems: 'center', + }, + secondaryButton: { + backgroundColor: '#555', + paddingVertical: 14, + paddingHorizontal: 16, + borderRadius: 10, + alignItems: 'center', + }, + buttonText: { + color: '#fff', + fontWeight: '600', + }, + error: { + color: 'red', + textAlign: 'center', + }, +}); diff --git a/src/app/(protected)/offices/index.tsx b/src/app/(protected)/offices/index.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/(protected)/profile/index.tsx b/src/app/(protected)/profile/index.tsx deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/(protected)/reservations/create.tsx b/src/app/(protected)/reservations/create.tsx index e69de29..c1c88b3 100644 --- a/src/app/(protected)/reservations/create.tsx +++ b/src/app/(protected)/reservations/create.tsx @@ -0,0 +1,28 @@ +import { StyleSheet, Text, View } from 'react-native'; + +export default function CreateReservationScreen() { + return ( + + Crear reserva + Pantalla en construcción. + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + padding: 16, + justifyContent: 'center', + alignItems: 'center', + gap: 12, + }, + title: { + fontSize: 28, + fontWeight: '700', + }, + text: { + fontSize: 16, + color: '#555', + }, +}); diff --git a/src/app/(protected)/reservations/index.tsx b/src/app/(protected)/reservations/index.tsx deleted file mode 100644 index e69de29..0000000 -- cgit v1.2.3-54-g00ecf