summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)/offices/\
blob: 34095c5afddda2078e5956a1510e040d23442404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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',
  },
});