summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/(protected)')
-rw-r--r--src/app/(protected)/offices/[officeId].tsx139
1 files changed, 138 insertions, 1 deletions
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx
index caedb05..91e6905 100644
--- a/src/app/(protected)/offices/[officeId].tsx
+++ b/src/app/(protected)/offices/[officeId].tsx
@@ -5,14 +5,16 @@ import {
ScrollView,
StyleSheet,
Text,
+ TextInput,
View,
} from 'react-native';
import { useOffice } from '@/features/offices/hooks/useOffice';
import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices';
+import { useOfficeAvailability } from '@/features/reservations/hooks/useOfficeAvailability';
import theme from '@/theme';
-import { Feather, MaterialIcons } from '@expo/vector-icons';
+import { MaterialIcons } from '@expo/vector-icons';
export default function OfficeDetailScreen() {
const params = useLocalSearchParams<{ officeId: string }>();
@@ -25,6 +27,14 @@ export default function OfficeDetailScreen() {
pendingOfficeId,
toggleFavorite,
} = useFavoriteOffices();
+ const {
+ selectedDate,
+ reservations,
+ loading: availabilityLoading,
+ error: availabilityError,
+ setSelectedDate,
+ reload: reloadAvailability,
+ } = useOfficeAvailability(officeId);
if (loading) {
return (
@@ -124,6 +134,63 @@ export default function OfficeDetailScreen() {
</View>
)}
+ {/* AVAILABILITY */}
+ <View style={styles.card}>
+ <Text style={styles.sectionTitle}>Disponibilidad</Text>
+ <Text style={styles.text}>
+ Consulta los bloques ocupados para elegir un horario libre.
+ </Text>
+
+ <View style={styles.availabilityField}>
+ <Text style={styles.label}>Fecha</Text>
+ <TextInput
+ style={styles.input}
+ value={selectedDate}
+ onChangeText={setSelectedDate}
+ placeholder="YYYY-MM-DD"
+ keyboardType="number-pad"
+ maxLength={10}
+ />
+ </View>
+
+ {availabilityLoading ? (
+ <View style={styles.inlineState}>
+ <ActivityIndicator />
+ <Text style={styles.text}>Cargando disponibilidad...</Text>
+ </View>
+ ) : null}
+
+ {availabilityError ? (
+ <View style={styles.errorBox}>
+ <Text style={styles.errorText}>{availabilityError}</Text>
+ <Pressable onPress={reloadAvailability}>
+ <Text style={styles.retryText}>Reintentar</Text>
+ </Pressable>
+ </View>
+ ) : null}
+
+ {!availabilityLoading && !availabilityError ? (
+ reservations.length > 0 ? (
+ <View style={styles.occupiedList}>
+ {reservations.map((reservation) => (
+ <View key={reservation.id} style={styles.occupiedItem}>
+ <Text style={styles.occupiedTime}>
+ {reservation.startTime} - {reservation.endTime}
+ </Text>
+ <Text style={styles.occupiedText}>
+ Ocupado
+ </Text>
+ </View>
+ ))}
+ </View>
+ ) : (
+ <Text style={styles.availableText}>
+ No hay bloques ocupados para esta fecha.
+ </Text>
+ )
+ ) : null}
+ </View>
+
{/* FAVORITE */}
<Pressable
style={[
@@ -257,6 +324,76 @@ const styles = StyleSheet.create({
color: theme.colors.textSecondary,
},
+ availabilityField: {
+ gap: theme.spacing.sm,
+ marginTop: theme.spacing.md,
+ },
+
+ label: {
+ color: theme.colors.text,
+ fontWeight: theme.fontWeight.medium,
+ fontSize: theme.typography.sm,
+ },
+
+ input: {
+ borderWidth: 1,
+ borderColor: theme.colors.border,
+ borderRadius: theme.radius.md,
+ paddingHorizontal: theme.spacing.lg,
+ paddingVertical: theme.spacing.md,
+ backgroundColor: theme.colors.background,
+ color: theme.colors.text,
+ },
+
+ inlineState: {
+ marginTop: theme.spacing.md,
+ flexDirection: 'row',
+ alignItems: 'center',
+ gap: theme.spacing.sm,
+ },
+
+ errorBox: {
+ marginTop: theme.spacing.md,
+ gap: theme.spacing.sm,
+ },
+
+ errorText: {
+ color: theme.colors.error,
+ },
+
+ retryText: {
+ color: theme.colors.primary,
+ fontWeight: theme.fontWeight.medium,
+ },
+
+ occupiedList: {
+ marginTop: theme.spacing.md,
+ gap: theme.spacing.sm,
+ },
+
+ occupiedItem: {
+ borderWidth: 1,
+ borderColor: theme.colors.border,
+ borderRadius: theme.radius.md,
+ padding: theme.spacing.md,
+ backgroundColor: theme.colors.background,
+ },
+
+ occupiedTime: {
+ color: theme.colors.text,
+ fontWeight: theme.fontWeight.semibold,
+ },
+
+ occupiedText: {
+ color: theme.colors.textSecondary,
+ marginTop: theme.spacing.xs,
+ },
+
+ availableText: {
+ color: theme.colors.successText,
+ marginTop: theme.spacing.md,
+ },
+
badge: {
backgroundColor: theme.colors.divider,
paddingHorizontal: theme.spacing.md,