summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)/offices
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-03-30 17:37:42 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-03-30 17:37:42 +0100
commit174f1acd46c4ffbde88c04465e8fa6b6810ce113 (patch)
treed0c6705b0130f088e76b7303d394ff2a8d66129c /src/app/(protected)/offices
parent31584b4e5a3a551e2ceb15281a38677c39c46e12 (diff)
logica de reservas
Diffstat (limited to 'src/app/(protected)/offices')
-rw-r--r--src/app/(protected)/offices/[officeId].tsx18
-rw-r--r--src/app/(protected)/offices/\129
2 files changed, 143 insertions, 4 deletions
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx
index 77fd610..34095c5 100644
--- a/src/app/(protected)/offices/[officeId].tsx
+++ b/src/app/(protected)/offices/[officeId].tsx
@@ -53,11 +53,21 @@ export default function OfficeDetailScreen() {
) : null}
</View>
- <Link href="/(protected)/reservations/create" asChild>
- <Pressable style={styles.button}>
- <Text style={styles.buttonText}>Reservar este espacio</Text>
- </Pressable>
+ <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>
);
}
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',
+ },
+});