diff options
Diffstat (limited to 'src/app/(protected)/offices')
| -rw-r--r-- | src/app/(protected)/offices/[officeId].tsx | 98 |
1 files changed, 95 insertions, 3 deletions
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx index 8e3812f..c632490 100644 --- a/src/app/(protected)/offices/[officeId].tsx +++ b/src/app/(protected)/offices/[officeId].tsx @@ -1,8 +1,17 @@ import { Link, useLocalSearchParams } from 'expo-router'; -import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; +import { + ActivityIndicator, + Pressable, + ScrollView, + StyleSheet, + Text, + TextInput, + View, +} from 'react-native'; import { useOffice } from '@/features/offices/hooks/useOffice'; import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; import { StatusMessage } from '@/shared/ui/StatusMessage'; +import { useOfficeAvailability } from '@/features/reservations/hooks/useOfficeAvailability'; export default function OfficeDetailScreen() { const params = useLocalSearchParams<{ officeId: string }>(); @@ -15,6 +24,13 @@ export default function OfficeDetailScreen() { pendingOfficeId, toggleFavorite, } = useFavoriteOffices(); + const { + selectedDate, + reservations, + loading: loadingAvailability, + error: availabilityError, + setSelectedDate, + } = useOfficeAvailability(officeId); if (loading) { return ( @@ -43,7 +59,7 @@ export default function OfficeDetailScreen() { } return ( - <View style={styles.container}> + <ScrollView contentContainerStyle={styles.container}> <View style={styles.header}> <Text style={styles.title}>{office.name}</Text> <Pressable @@ -67,6 +83,7 @@ export default function OfficeDetailScreen() { </View> {favoritesError ? <StatusMessage message={favoritesError} /> : null} + {availabilityError ? <StatusMessage message={availabilityError} /> : null} <View style={styles.card}> <Text style={styles.label}>Ubicación</Text> @@ -83,6 +100,39 @@ export default function OfficeDetailScreen() { ) : null} </View> + <View style={styles.card}> + <Text style={styles.sectionTitle}>Disponibilidad</Text> + + <Text style={styles.label}>Fecha</Text> + <TextInput + style={styles.input} + placeholder="2026-04-01" + value={selectedDate} + onChangeText={setSelectedDate} + keyboardType="number-pad" + maxLength={10} + /> + + <Text style={styles.helper}>Consulta los horarios ocupados para esa fecha</Text> + + {loadingAvailability ? ( + <ActivityIndicator size="small" /> + ) : availabilityError ? null : reservations.length === 0 ? ( + <Text style={styles.availableText}>No hay bloques ocupados para esta fecha</Text> + ) : ( + <View style={styles.availabilityList}> + {reservations.map((reservation) => ( + <View key={reservation.id} style={styles.availabilityItem}> + <Text style={styles.availabilityTime}> + {reservation.startTime} - {reservation.endTime} + </Text> + <Text style={styles.availabilityStatus}>Ocupado</Text> + </View> + ))} + </View> + )} + </View> + <Link href={{ pathname: '/(protected)/reservations/create', @@ -98,7 +148,7 @@ export default function OfficeDetailScreen() { </Pressable> </Link> - </View> + </ScrollView> ); } @@ -137,10 +187,52 @@ const styles = StyleSheet.create({ fontWeight: '700', color: '#444', }, + sectionTitle: { + fontSize: 20, + fontWeight: '700', + marginBottom: 4, + }, value: { fontSize: 16, color: '#111', }, + input: { + borderWidth: 1, + borderColor: '#ccc', + borderRadius: 10, + paddingHorizontal: 14, + paddingVertical: 12, + marginTop: 4, + }, + helper: { + color: '#666', + fontSize: 12, + }, + availabilityList: { + gap: 10, + marginTop: 8, + }, + availabilityItem: { + borderWidth: 1, + borderColor: '#d9e5d4', + backgroundColor: '#f3faf1', + borderRadius: 10, + padding: 12, + gap: 4, + }, + availabilityTime: { + fontSize: 16, + fontWeight: '600', + color: '#1f3a1a', + }, + availabilityStatus: { + color: '#336b2f', + fontSize: 13, + }, + availableText: { + color: '#2e7d32', + marginTop: 8, + }, button: { backgroundColor: '#1f6feb', paddingVertical: 14, |