diff options
Diffstat (limited to 'src/app/(protected)/offices/\')
| -rw-r--r-- | src/app/(protected)/offices/\ | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/src/app/(protected)/offices/\ b/src/app/(protected)/offices/\ new file mode 100644 index 0000000..34095c5 --- /dev/null +++ b/src/app/(protected)/offices/\ @@ -0,0 +1,129 @@ +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 ( + <View style={styles.center}> + <ActivityIndicator size="large" /> + </View> + ); + } + + if (error || !office) { + return ( + <View style={styles.center}> + <Text style={styles.error}>{error ?? 'No se pudo cargar la oficina'}</Text> + + <Pressable style={styles.button} onPress={reload}> + <Text style={styles.buttonText}>Reintentar</Text> + </Pressable> + + <Link href="/(protected)/offices" asChild> + <Pressable style={styles.secondaryButton}> + <Text style={styles.buttonText}>Volver a espacios</Text> + </Pressable> + </Link> + </View> + ); + } + + return ( + <View style={styles.container}> + <Text style={styles.title}>{office.name}</Text> + + <View style={styles.card}> + <Text style={styles.label}>Ubicación</Text> + <Text style={styles.value}>{office.location}</Text> + + <Text style={styles.label}>Capacidad</Text> + <Text style={styles.value}>{office.capacity} personas</Text> + + {office.description ? ( + <> + <Text style={styles.label}>Descripción</Text> + <Text style={styles.value}>{office.description}</Text> + </> + ) : null} + </View> + + <Link + href={{ + pathname: '/(protected)/reservations/create', + params: { + officeId: office.id, + officeName: office.name, + }, + }} + asChild + > + <Pressable style={styles.button}> + <Text style={styles.buttonText}>Reservar este espacio</Text> + </Pressable> + </Link> + + </View> + ); +} + +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', + }, +}); |