summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-21 12:22:35 +0100
committerAlberto Duarte Delgado <alberto@albertoduarte.com>2026-04-21 12:22:35 +0100
commitc685ee8dd304b53c54b3661c2dc96f470af25737 (patch)
tree914e00f27263292a9d611d4c3ac08828d2151a16
parentbe90a5f202f80bb423c6e0aaf1c4d5feca668f01 (diff)
feat(offices): restaurar filtro de favoritos fixes #14
-rw-r--r--.gitignore3
-rw-r--r--src/app/(auth)/_layout.tsx2
-rw-r--r--src/app/(auth)/login.tsx21
-rw-r--r--src/app/(auth)/register.tsx21
-rw-r--r--src/app/(protected)/(tabs)/offices/index.tsx71
-rw-r--r--src/app/(protected)/offices/[officeId].tsx13
-rw-r--r--src/app/index.tsx2
-rw-r--r--src/features/auth/hooks/useLogin.ts2
-rw-r--r--src/features/auth/hooks/useRegister.ts2
-rw-r--r--src/features/offices/types.ts1
-rw-r--r--src/shared/lib/mockData.ts30
-rw-r--r--tsconfig.json2
12 files changed, 153 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 39a4896..bf9f426 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,9 @@ yarn-error.*
# typescript
*.tsbuildinfo
+# local AI assistant state
+.codex
+
# generated native folders
/ios
diff --git a/src/app/(auth)/_layout.tsx b/src/app/(auth)/_layout.tsx
index 1fa69af..14383a2 100644
--- a/src/app/(auth)/_layout.tsx
+++ b/src/app/(auth)/_layout.tsx
@@ -20,7 +20,7 @@ export default function AuthLayout() {
}
if (user) {
- return <Redirect href="/(protected)/home" />;
+ return <Redirect href="/home" />;
}
return <Stack screenOptions={{ headerShown: false }} />;
diff --git a/src/app/(auth)/login.tsx b/src/app/(auth)/login.tsx
index 8dbac8b..9a3dfe0 100644
--- a/src/app/(auth)/login.tsx
+++ b/src/app/(auth)/login.tsx
@@ -185,6 +185,27 @@ const styles = StyleSheet.create({
color: colors.text,
},
+ inputWrapper: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ borderWidth: 1,
+ borderColor: colors.border,
+ borderRadius: radius.md,
+ backgroundColor: colors.background,
+ },
+
+ inputWithIcon: {
+ flex: 1,
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.md,
+ color: colors.text,
+ },
+
+ iconButton: {
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.md,
+ },
+
// texto de recuperar contraseña
forgotPassword: {
fontSize: typography.sm,
diff --git a/src/app/(auth)/register.tsx b/src/app/(auth)/register.tsx
index 902c752..7040189 100644
--- a/src/app/(auth)/register.tsx
+++ b/src/app/(auth)/register.tsx
@@ -235,6 +235,27 @@ const styles = StyleSheet.create({
color: colors.text,
},
+ inputWrapper: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ borderWidth: 1,
+ borderColor: colors.border,
+ borderRadius: radius.md,
+ backgroundColor: colors.background,
+ },
+
+ inputWithIcon: {
+ flex: 1,
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.md,
+ color: colors.text,
+ },
+
+ iconButton: {
+ paddingHorizontal: spacing.lg,
+ paddingVertical: spacing.md,
+ },
+
// boton principal
button: {
backgroundColor: colors.primary,
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
+});
diff --git a/src/app/index.tsx b/src/app/index.tsx
index eacde3c..6affd95 100644
--- a/src/app/index.tsx
+++ b/src/app/index.tsx
@@ -20,7 +20,7 @@ export default function IndexPage() {
}
if (user) {
- return <Redirect href="/(protected)/home" />;
+ return <Redirect href="/home" />;
}
return <Redirect href="/(auth)/welcome" />;
diff --git a/src/features/auth/hooks/useLogin.ts b/src/features/auth/hooks/useLogin.ts
index 6af76c5..c83618f 100644
--- a/src/features/auth/hooks/useLogin.ts
+++ b/src/features/auth/hooks/useLogin.ts
@@ -19,7 +19,7 @@ export function useLogin() {
password,
});
- router.replace('/(protected)/home');
+ router.replace('/home');
} catch (err) {
setError(getErrorMessage(err, 'No se pudo iniciar sesión'));
} finally {
diff --git a/src/features/auth/hooks/useRegister.ts b/src/features/auth/hooks/useRegister.ts
index fe83d85..80899d9 100644
--- a/src/features/auth/hooks/useRegister.ts
+++ b/src/features/auth/hooks/useRegister.ts
@@ -21,7 +21,7 @@ export function useRegister() {
password,
});
- router.replace('/(protected)/home');
+ router.replace('/home');
} catch (err) {
setError(getErrorMessage(err, 'No se pudo registrar el usuario'));
} finally {
diff --git a/src/features/offices/types.ts b/src/features/offices/types.ts
index 9f9d039..59820aa 100644
--- a/src/features/offices/types.ts
+++ b/src/features/offices/types.ts
@@ -3,5 +3,6 @@ export type Office = {
name: string;
location: string;
capacity: number;
+ available?: boolean;
description?: string;
};
diff --git a/src/shared/lib/mockData.ts b/src/shared/lib/mockData.ts
new file mode 100644
index 0000000..9ece33c
--- /dev/null
+++ b/src/shared/lib/mockData.ts
@@ -0,0 +1,30 @@
+import { UserProfile } from '@/features/profile/types';
+import { Reservation } from '@/features/reservations/types';
+
+type MockReservationLock = {
+ reservationId: string;
+ userId: string;
+ officeId: string;
+ date: string;
+ time: string;
+};
+
+export function mockDelay(durationMs = 250): Promise<void> {
+ return new Promise((resolve) => {
+ setTimeout(resolve, durationMs);
+ });
+}
+
+export const mockUserProfile: UserProfile = {
+ uid: 'mock-user',
+ email: 'mock@appoficina.local',
+ displayName: 'Usuario Demo',
+ photoURL: '',
+ phone: '',
+ company: '',
+ bio: '',
+};
+
+export const mockReservations: Reservation[] = [];
+
+export const mockReservationLocks: Record<string, MockReservationLock> = {};
diff --git a/tsconfig.json b/tsconfig.json
index 3fe2c77..dd27f42 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,7 +2,7 @@
"extends": "expo/tsconfig.base",
"compilerOptions": {
"baseUrl": ".",
- "ignoreDeprecations": "6.0",
+ "ignoreDeprecations": "5.0",
"paths": {
"@/*": ["src/*"]
}