From c685ee8dd304b53c54b3661c2dc96f470af25737 Mon Sep 17 00:00:00 2001 From: Alberto Duarte Delgado Date: Tue, 21 Apr 2026 12:22:35 +0100 Subject: feat(offices): restaurar filtro de favoritos fixes #14 --- src/app/(protected)/(tabs)/offices/index.tsx | 71 +++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 6 deletions(-) (limited to 'src/app/(protected)/(tabs)') diff --git a/src/app/(protected)/(tabs)/offices/index.tsx b/src/app/(protected)/(tabs)/offices/index.tsx index ee19917..c84123a 100644 --- a/src/app/(protected)/(tabs)/offices/index.tsx +++ b/src/app/(protected)/(tabs)/offices/index.tsx @@ -20,13 +20,18 @@ export default function OfficesScreen() { const { favoriteOfficeIdsSet, isLoadingFavorites } = useFavoriteOffices(); const [search, setSearch] = useState(''); + const [showOnlyFavorites, setShowOnlyFavorites] = useState(false); const filteredOffices = useMemo(() => { const normalized = search.toLowerCase(); - return offices.filter((o) => - o.name.toLowerCase().includes(normalized) - ); - }, [offices, search]); + return offices.filter((office) => { + const matchesSearch = office.name.toLowerCase().includes(normalized); + const matchesFavorite = + !showOnlyFavorites || favoriteOfficeIdsSet.has(office.id); + + return matchesSearch && matchesFavorite; + }); + }, [favoriteOfficeIdsSet, offices, search, showOnlyFavorites]); if (loading || isLoadingFavorites) { return ( @@ -61,6 +66,32 @@ export default function OfficesScreen() { value={search} onChangeText={setSearch} /> + + setShowOnlyFavorites((current) => !current)} + > + + + Solo favoritos + + {/* COUNT */} @@ -139,7 +170,9 @@ export default function OfficesScreen() { ListEmptyComponent={ - No se encontraron espacios + {showOnlyFavorites + ? 'No tienes espacios favoritos con estos filtros' + : 'No se encontraron espacios'} } @@ -191,6 +224,32 @@ content: { paddingVertical: theme.spacing.md, }, + favoriteFilterButton: { + marginTop: theme.spacing.md, + borderWidth: 1, + borderColor: theme.colors.primary, + borderRadius: theme.radius.lg, + paddingHorizontal: theme.spacing.lg, + paddingVertical: theme.spacing.md, + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + gap: theme.spacing.sm, + }, + + favoriteFilterButtonActive: { + backgroundColor: theme.colors.primary, + }, + + favoriteFilterText: { + color: theme.colors.primary, + fontWeight: theme.fontWeight.medium, + }, + + favoriteFilterTextActive: { + color: theme.colors.white, + }, + resultText: { fontSize: theme.typography.sm, color: theme.colors.textSecondary, @@ -313,4 +372,4 @@ content: { color: theme.colors.white, fontWeight: theme.fontWeight.semibold, }, -}); \ No newline at end of file +}); -- cgit v1.2.3-54-g00ecf