summaryrefslogtreecommitdiffstats
path: root/src/app/(protected)
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/(protected)')
-rw-r--r--src/app/(protected)/(tabs)/offices/index.tsx71
-rw-r--r--src/app/(protected)/offices/[officeId].tsx13
2 files changed, 72 insertions, 12 deletions
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}
/>
+
+ <Pressable
+ style={[
+ styles.favoriteFilterButton,
+ showOnlyFavorites && styles.favoriteFilterButtonActive,
+ ]}
+ onPress={() => setShowOnlyFavorites((current) => !current)}
+ >
+ <MaterialIcons
+ name={showOnlyFavorites ? 'star' : 'star-outline'}
+ size={18}
+ color={
+ showOnlyFavorites
+ ? theme.colors.white
+ : theme.colors.primary
+ }
+ />
+ <Text
+ style={[
+ styles.favoriteFilterText,
+ showOnlyFavorites && styles.favoriteFilterTextActive,
+ ]}
+ >
+ Solo favoritos
+ </Text>
+ </Pressable>
</View>
{/* COUNT */}
@@ -139,7 +170,9 @@ export default function OfficesScreen() {
ListEmptyComponent={
<View style={styles.emptyBox}>
<Text style={styles.emptyText}>
- No se encontraron espacios
+ {showOnlyFavorites
+ ? 'No tienes espacios favoritos con estos filtros'
+ : 'No se encontraron espacios'}
</Text>
</View>
}
@@ -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
+});
diff --git a/src/app/(protected)/offices/[officeId].tsx b/src/app/(protected)/offices/[officeId].tsx
index fbcd9f8..caedb05 100644
--- a/src/app/(protected)/offices/[officeId].tsx
+++ b/src/app/(protected)/offices/[officeId].tsx
@@ -45,7 +45,7 @@ export default function OfficeDetailScreen() {
<Text style={styles.primaryButtonText}>Reintentar</Text>
</Pressable>
- <Link href="/(protected)/offices" asChild>
+ <Link href="/offices" asChild>
<Pressable style={styles.secondaryButton}>
<Text style={styles.primaryButtonText}>Volver</Text>
</Pressable>
@@ -55,12 +55,13 @@ export default function OfficeDetailScreen() {
}
const isFav = favoriteOfficeIdsSet.has(office.id);
+ const isAvailable = office.available ?? true;
return (
<ScrollView contentContainerStyle={styles.container}>
<View style={styles.content}>
{/* HEADER */}
- <Link href="/(protected)/offices" asChild>
+ <Link href="/offices" asChild>
<Pressable>
<Text style={styles.back}>← Volver a espacios</Text>
</Pressable>
@@ -90,16 +91,16 @@ export default function OfficeDetailScreen() {
<View
style={[
styles.badge,
- office.available && styles.badgeActive,
+ isAvailable && styles.badgeActive,
]}
>
<Text
style={[
styles.badgeText,
- office.available && styles.badgeTextActive,
+ isAvailable && styles.badgeTextActive,
]}
>
- {office.available ? 'Disponible' : 'Ocupado'}
+ {isAvailable ? 'Disponible' : 'Ocupado'}
</Text>
</View>
</View>
@@ -321,4 +322,4 @@ const styles = StyleSheet.create({
padding: theme.spacing.md,
borderRadius: theme.radius.md,
},
-}); \ No newline at end of file
+});