diff options
| author | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 13:32:56 +0100 |
|---|---|---|
| committer | Alberto Duarte Delgado <alberto@albertoduarte.com> | 2026-04-01 13:32:56 +0100 |
| commit | e22992e29801e04ca4352045c5bd2f36eac1c31c (patch) | |
| tree | e9a4d8851ea958062af03527f6816ba94ddb0a85 /src/app/(protected)/offices | |
| parent | 08ce78dbd97ad792e163482f454f285557c7cdd0 (diff) | |
filtrado de oficinas y favoritos
Diffstat (limited to 'src/app/(protected)/offices')
| -rw-r--r-- | src/app/(protected)/offices/[officeId].tsx | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx index 34095c5..8e3812f 100644 --- a/src/app/(protected)/offices/[officeId].tsx +++ b/src/app/(protected)/offices/[officeId].tsx @@ -1,12 +1,20 @@ import { Link, useLocalSearchParams } from 'expo-router'; import { ActivityIndicator, Pressable, StyleSheet, Text, View } from 'react-native'; import { useOffice } from '@/features/offices/hooks/useOffice'; +import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; +import { StatusMessage } from '@/shared/ui/StatusMessage'; 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); + const { + favoriteOfficeIdsSet, + favoritesError, + pendingOfficeId, + toggleFavorite, + } = useFavoriteOffices(); if (loading) { return ( @@ -36,7 +44,29 @@ export default function OfficeDetailScreen() { return ( <View style={styles.container}> - <Text style={styles.title}>{office.name}</Text> + <View style={styles.header}> + <Text style={styles.title}>{office.name}</Text> + <Pressable + style={[ + styles.favoriteButton, + favoriteOfficeIdsSet.has(office.id) && styles.favoriteButtonActive, + ]} + onPress={() => { + void toggleFavorite(office.id); + }} + disabled={pendingOfficeId === office.id} + > + <Text style={styles.favoriteButtonText}> + {pendingOfficeId === office.id + ? '...' + : favoriteOfficeIdsSet.has(office.id) + ? '★' + : '☆'} + </Text> + </Pressable> + </View> + + {favoritesError ? <StatusMessage message={favoritesError} /> : null} <View style={styles.card}> <Text style={styles.label}>Ubicación</Text> @@ -88,6 +118,12 @@ const styles = StyleSheet.create({ title: { fontSize: 28, fontWeight: '700', + flex: 1, + }, + header: { + flexDirection: 'row', + alignItems: 'center', + gap: 12, }, card: { borderWidth: 1, @@ -118,6 +154,21 @@ const styles = StyleSheet.create({ borderRadius: 10, alignItems: 'center', }, + favoriteButton: { + width: 44, + height: 44, + borderRadius: 22, + alignItems: 'center', + justifyContent: 'center', + backgroundColor: '#eef2f6', + }, + favoriteButtonActive: { + backgroundColor: '#ffe8a3', + }, + favoriteButtonText: { + fontSize: 22, + color: '#8a6700', + }, buttonText: { color: '#fff', fontWeight: '600', |