From 40cc6cea25d048c2e77e11bbfea0cd1e5eb784f6 Mon Sep 17 00:00:00 2001 From: Enrique Pérez Pérez Date: Sun, 19 Apr 2026 19:32:09 +0200 Subject: Completado cambios pantalla oficinas y detalle de oficina #12 y #13 --- src/app/(protected)/(tabs)/offices/index.tsx | 413 ++++++++++++++------------- 1 file changed, 222 insertions(+), 191 deletions(-) (limited to 'src/app/(protected)/(tabs)/offices/index.tsx') diff --git a/src/app/(protected)/(tabs)/offices/index.tsx b/src/app/(protected)/(tabs)/offices/index.tsx index 9040fbd..ee19917 100644 --- a/src/app/(protected)/(tabs)/offices/index.tsx +++ b/src/app/(protected)/(tabs)/offices/index.tsx @@ -9,53 +9,29 @@ import { TextInput, View, } from 'react-native'; + import { useOffices } from '@/features/offices/hooks/useOffices'; import { useFavoriteOffices } from '@/features/offices/hooks/useFavoriteOffices'; -import { StatusMessage } from '@/shared/ui/StatusMessage'; +import { Feather, MaterialIcons } from '@expo/vector-icons'; +import theme from '@/theme'; export default function OfficesScreen() { const { offices, loading, error, reload } = useOffices(); - const { - favoriteOfficeIdsSet, - isLoadingFavorites, - favoritesError, - pendingOfficeId, - toggleFavorite, - } = useFavoriteOffices(); + const { favoriteOfficeIdsSet, isLoadingFavorites } = useFavoriteOffices(); + const [search, setSearch] = useState(''); - const [minimumCapacity, setMinimumCapacity] = useState(''); - const [showFavoritesOnly, setShowFavoritesOnly] = useState(false); const filteredOffices = useMemo(() => { - const normalizedSearch = search.trim().toLowerCase(); - const parsedCapacity = Number(minimumCapacity); - const hasCapacityFilter = minimumCapacity.trim().length > 0 && !Number.isNaN(parsedCapacity); - - return offices.filter((office) => { - const matchesSearch = - normalizedSearch.length === 0 || - office.name.toLowerCase().includes(normalizedSearch); - - const matchesCapacity = - !hasCapacityFilter || office.capacity >= parsedCapacity; - - const matchesFavorites = - !showFavoritesOnly || favoriteOfficeIdsSet.has(office.id); - - return matchesSearch && matchesCapacity && matchesFavorites; - }); - }, [favoriteOfficeIdsSet, minimumCapacity, offices, search, showFavoritesOnly]); - - const clearFilters = () => { - setSearch(''); - setMinimumCapacity(''); - setShowFavoritesOnly(false); - }; + const normalized = search.toLowerCase(); + return offices.filter((o) => + o.name.toLowerCase().includes(normalized) + ); + }, [offices, search]); if (loading || isLoadingFavorites) { return ( - + ); } @@ -63,223 +39,278 @@ export default function OfficesScreen() { if (error) { return ( - {error} - - Reintentar + {error} + + Reintentar ); } return ( - - Espacios - - - Buscar y filtrar + + + {/* HEADER */} + + Espacios disponibles + {/* SEARCH */} - - setMinimumCapacity(value.replace(/\D/g, ''))} - keyboardType="number-pad" - /> - - - setShowFavoritesOnly((current) => !current)} - > - - {showFavoritesOnly ? 'Viendo favoritos' : 'Solo favoritos'} - - - - - Limpiar filtros - - - {favoritesError ? : null} + {/* COUNT */} + + {filteredOffices.length} espacio + {filteredOffices.length !== 1 ? 's' : ''} encontrados + + {/* LIST */} item.id} contentContainerStyle={styles.list} - ListEmptyComponent={ - - {offices.length === 0 - ? 'No hay espacios disponibles' - : showFavoritesOnly - ? 'No tienes oficinas favoritas que coincidan con los filtros' - : 'No hay espacios que coincidan con los filtros'} - - } - renderItem={({ item }) => ( - - - {item.name} - { - void toggleFavorite(item.id); - }} - disabled={pendingOfficeId === item.id} - > - - {pendingOfficeId === item.id - ? '...' - : favoriteOfficeIdsSet.has(item.id) - ? '★' - : '☆'} - - - + renderItem={({ item }) => { + const isFav = favoriteOfficeIdsSet.has(item.id); + return ( - - {item.location} - Capacidad: {item.capacity} - {item.description ? {item.description} : null} + + + {/* IMAGE PLACEHOLDER */} + {/* + 🏢 + */} + + + + {/* INFO */} + + + + {item.name} + + {item.location} + + + + › + + + + {item.capacity} personas + + + + {/* + {item.price ?? '—'} + */} + + + + {isFav ? 'Favorito' : 'Disponible'} + + + + + + ); + }} + ListEmptyComponent={ + + + No se encontraron espacios + - )} + } /> + ); } const styles = StyleSheet.create({ container: { flex: 1, - padding: 16, + backgroundColor: theme.colors.background, }, + +content: { + flex: 1, + width: '100%', + maxWidth: theme.layout.contentWidth, + alignSelf: 'center', +}, + center: { flex: 1, - alignItems: 'center', justifyContent: 'center', - padding: 24, - }, - title: { - fontSize: 28, - fontWeight: '700', - marginBottom: 16, + alignItems: 'center', }, - filtersBox: { - borderWidth: 1, - borderColor: '#d8e0ea', - backgroundColor: '#f7f9fc', - borderRadius: 12, - padding: 12, - gap: 10, - marginBottom: 16, + + header: { + backgroundColor: theme.colors.surface, + padding: theme.spacing.xl, + borderBottomWidth: 1, + borderColor: theme.colors.border, }, - filtersTitle: { - fontSize: 16, - fontWeight: '700', - color: '#22354a', + + title: { + fontSize: theme.typography.xxxl, + fontWeight: theme.fontWeight.semibold, + color: theme.colors.text, + marginBottom: theme.spacing.md, }, - input: { + + search: { + backgroundColor: theme.colors.white, borderWidth: 1, - borderColor: '#ccd5df', - borderRadius: 10, - paddingHorizontal: 14, - paddingVertical: 12, - backgroundColor: '#fff', + borderColor: theme.colors.border, + borderRadius: theme.radius.lg, + paddingHorizontal: theme.spacing.lg, + paddingVertical: theme.spacing.md, }, - filterActions: { - flexDirection: 'row', - gap: 10, + + resultText: { + fontSize: theme.typography.sm, + color: theme.colors.textSecondary, + paddingHorizontal: theme.spacing.xl, + paddingTop: theme.spacing.md, }, + list: { - gap: 12, + padding: theme.spacing.xl, + gap: theme.spacing.lg, }, + card: { + backgroundColor: theme.colors.surface, + borderRadius: theme.radius.lg, + padding: theme.spacing.lg, borderWidth: 1, - borderColor: '#ddd', - borderRadius: 12, - padding: 16, - gap: 10, + borderColor: theme.colors.border, + ...theme.shadows.card, }, - cardHeader: { + + cardContent: { flexDirection: 'row', + gap: theme.spacing.lg, + }, + + imageBox: { + width: 80, + height: 80, + borderRadius: theme.radius.lg, + backgroundColor: theme.colors.primarySoft, alignItems: 'center', + justifyContent: 'center', + }, + + imageIcon: { + fontSize: 28, + }, + + info: { + flex: 1, + gap: theme.spacing.sm, + }, + + rowBetween: { + flexDirection: 'row', justifyContent: 'space-between', - gap: 12, + alignItems: 'flex-start', }, + cardTitle: { - fontSize: 18, - fontWeight: '600', - flex: 1, + fontSize: theme.typography.lg, + fontWeight: theme.fontWeight.semibold, + color: theme.colors.text, }, - cardBody: { - gap: 6, + + cardSubtitle: { + fontSize: theme.typography.sm, + color: theme.colors.textSecondary, }, - error: { - color: 'red', - marginBottom: 12, + + chevron: { + fontSize: 18, + color: theme.colors.muted, }, - button: { - backgroundColor: '#1f6feb', - paddingHorizontal: 16, - paddingVertical: 12, - borderRadius: 10, + + capacity: { + fontSize: theme.typography.sm, + color: theme.colors.textSecondary, }, - secondaryButton: { - backgroundColor: '#5d6b79', - flex: 1, - paddingHorizontal: 16, - paddingVertical: 12, - borderRadius: 10, + + footer: { + flexDirection: 'row', + justifyContent: 'space-between', alignItems: 'center', }, - toggleButton: { - backgroundColor: '#1f6feb', - flex: 1, - paddingHorizontal: 16, - paddingVertical: 12, - borderRadius: 10, - alignItems: 'center', + + price: { + color: theme.colors.primary, + fontWeight: theme.fontWeight.medium, }, - toggleButtonActive: { - backgroundColor: '#174ea6', + + badge: { + backgroundColor: theme.colors.divider, + paddingHorizontal: theme.spacing.md, + paddingVertical: theme.spacing.xs, + borderRadius: theme.radius.sm, }, - favoriteButton: { - width: 40, - height: 40, - borderRadius: 20, - alignItems: 'center', - justifyContent: 'center', - backgroundColor: '#eef2f6', + + badgeActive: { + backgroundColor: theme.colors.successBg, + }, + + badgeText: { + fontSize: theme.typography.sm, + color: theme.colors.textSecondary, + }, + + badgeTextActive: { + color: theme.colors.successText, }, - favoriteButtonActive: { - backgroundColor: '#ffe8a3', + + emptyBox: { + alignItems: 'center', + padding: theme.spacing.xxxl, }, - favoriteButtonText: { - fontSize: 20, - color: '#8a6700', + + emptyText: { + color: theme.colors.textSecondary, }, - buttonText: { - color: '#fff', - fontWeight: '600', + + primaryButton: { + marginTop: theme.spacing.md, + backgroundColor: theme.colors.primary, + padding: theme.spacing.md, + borderRadius: theme.radius.md, }, - empty: { - color: '#666', + + primaryButtonText: { + color: theme.colors.white, + fontWeight: theme.fontWeight.semibold, }, -}); +}); \ No newline at end of file -- cgit v1.2.3-54-g00ecf