diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-30 15:55:32 +0100 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-03-30 15:55:32 +0100 |
| commit | 31584b4e5a3a551e2ceb15281a38677c39c46e12 (patch) | |
| tree | eae47ea7351aa47f25244b42d8d11b69ee9c9d4e /src/app/(protected)/(tabs) | |
| parent | 6aede83b39f1050b7528b243278a85e5623856be (diff) | |
Offices logic
Diffstat (limited to 'src/app/(protected)/(tabs)')
| -rw-r--r-- | src/app/(protected)/(tabs)/_layout.tsx | 24 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/_layout.tsx~ | 0 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/home.tsx | 50 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/offices/index.tsx | 107 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/profile/index.tsx | 28 | ||||
| -rw-r--r-- | src/app/(protected)/(tabs)/reservations/index.tsx | 28 |
6 files changed, 237 insertions, 0 deletions
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 ( + <Tabs screenOptions={{ headerShown: false }}> + <Tabs.Screen + name="home" + options={{ title: 'Inicio' }} + /> + <Tabs.Screen + name="offices" + options={{ title: 'Espacios' }} + /> + <Tabs.Screen + name="reservations" + options={{ title: 'Reservas' }} + /> + <Tabs.Screen + name="profile" + options={{ title: 'Perfil' }} + /> + </Tabs> + ); +} diff --git a/src/app/(protected)/(tabs)/_layout.tsx~ b/src/app/(protected)/(tabs)/_layout.tsx~ new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/app/(protected)/(tabs)/_layout.tsx~ 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 ( + <View style={styles.container}> + <Text style={styles.title}>Inicio</Text> + <Text style={styles.subtitle}> + Bienvenido{user?.displayName ? `, ${user.displayName}` : ''} + </Text> + <Text style={styles.email}>{user?.email}</Text> + + <Pressable style={styles.button} onPress={logout}> + <Text style={styles.buttonText}>Cerrar sesión</Text> + </Pressable> + </View> + ); +} + +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 ( + <View style={styles.center}> + <ActivityIndicator size="large" /> + </View> + ); + } + + 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> + </View> + ); + } + + return ( + <View style={styles.container}> + <Text style={styles.title}>Espacios</Text> + + <FlatList + data={offices} + keyExtractor={(item) => item.id} + contentContainerStyle={styles.list} + ListEmptyComponent={ + <Text style={styles.empty}>No hay espacios disponibles</Text> + } + renderItem={({ item }) => ( + <Link href={`/(protected)/offices/${item.id}`} asChild> + <Pressable style={styles.card}> + <Text style={styles.cardTitle}>{item.name}</Text> + <Text>{item.location}</Text> + <Text>Capacidad: {item.capacity}</Text> + {item.description ? <Text>{item.description}</Text> : null} + </Pressable> + </Link> + )} + /> + </View> + ); +} + +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 ( + <View style={styles.container}> + <Text style={styles.title}>Perfil</Text> + <Text style={styles.text}>Pantalla en construcción.</Text> + </View> + ); +} + +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 ( + <View style={styles.container}> + <Text style={styles.title}>Reservas</Text> + <Text style={styles.text}>Pantalla en construcción.</Text> + </View> + ); +} + +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', + }, +}); |