// PropertyDetailScreen — gallery, key facts, description, consultant contact panel. function PropertyDetailScreen({ propertyId, onBack }) { const { Button, Badge, IconButton, Avatar } = window.SBLImVeisDesignSystem_08a506; const { isMobile } = window.useResponsive(); const { t, field } = window.useLang(); const p = window.SBL_DATA.properties.find((x) => x.id === propertyId) || window.SBL_DATA.properties[0]; const [active, setActive] = React.useState(0); const kindLabel = { sale: 'Venda', rent: 'Aluguel', season: 'Temporada' }[p.kind]; // ── Favorites ────────────────────────────────────────────────────────────── function loadFavs() { try { return JSON.parse(localStorage.getItem('sbl_favorites') || '[]'); } catch { return []; } } const [fav, setFav] = React.useState(() => loadFavs().includes(p.id)); const [favToast, setFavToast] = React.useState(null); const favTimerRef = React.useRef(null); function toggleFav() { const favs = loadFavs(); const isNowFav = !favs.includes(p.id); const next = isNowFav ? [...favs, p.id] : favs.filter(id => id !== p.id); localStorage.setItem('sbl_favorites', JSON.stringify(next)); setFav(isNowFav); window.dispatchEvent(new CustomEvent('sbl:favorites-changed')); clearTimeout(favTimerRef.current); setFavToast(isNowFav ? 'added' : 'removed'); favTimerRef.current = setTimeout(() => setFavToast(null), 3000); } React.useEffect(() => () => clearTimeout(favTimerRef.current), []); function handleShare() { const siteUrl = window.location.origin + (window.location.pathname.replace(/\/[^/]*$/, '/') || '/'); const text = t('Veja esse imóvel incrível que encontrei no site da SBL:') + ' ' + p.title + ' — ' + siteUrl; window.open('https://wa.me/?text=' + encodeURIComponent(text), '_blank', 'noopener'); } const gallery = p.gallery || []; const thumbRef = React.useRef(null); function prev() { setActive(i => (i - 1 + gallery.length) % gallery.length); } function next() { setActive(i => (i + 1) % gallery.length); } // Scroll active thumbnail into view React.useEffect(() => { if (!thumbRef.current) return; const el = thumbRef.current.children[active]; if (el) el.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' }); }, [active]); // Keyboard navigation React.useEffect(() => { function onKey(e) { if (e.key === 'ArrowLeft') prev(); else if (e.key === 'ArrowRight') next(); } window.addEventListener('keydown', onKey); return () => window.removeEventListener('keydown', onKey); }, [gallery.length]); const facts = [ { icon: 'bed-double', v: p.beds, l: t('Quartos') }, { icon: 'bath', v: p.baths, l: t('Banheiros') }, { icon: 'car', v: p.parking, l: t('Vagas') }, { icon: 'maximize', v: p.area + ' m²', l: t('Área útil') }, ]; const arrowBtn = (onClick, icon, side) => ( ); return (
{/* Gallery */}
{/* Main photo */}
{p.title} {/* Badges */}
{t(kindLabel)} {p.featured && {t('Destaque')}}
{/* Fav / share */}
{/* Counter */} {gallery.length > 1 && (
{active + 1} / {gallery.length}
)} {/* Arrows */} {gallery.length > 1 && arrowBtn(prev, 'chevron-left', 'left')} {gallery.length > 1 && arrowBtn(next, 'chevron-right', 'right')}
{/* Thumbnail strip */} {gallery.length > 1 && (
{gallery.map((g, i) => (
setActive(i)} style={{ flexShrink: 0, width: isMobile ? 68 : 88, height: isMobile ? 50 : 64, borderRadius: 8, overflow: 'hidden', cursor: 'pointer', border: active === i ? '2.5px solid var(--brown-500)' : '2.5px solid transparent', opacity: active === i ? 1 : 0.6, transition: 'opacity 0.15s, border-color 0.15s', boxShadow: active === i ? '0 0 0 1px var(--brown-300)' : 'none', }} >
))}
)}
{/* Body */}
{p.location}

{field(p, 'title')}

{facts.map((f) => (
{f.v}
{f.l}
))}

{t('Sobre o imóvel')}

{field(p, 'desc')}

{p.amenities && p.amenities.length > 0 && ( <>

{t('Diferenciais')}

{p.amenities.map((a) => (
{a}
))}
)}
{/* Contact panel */}
{/* Favorites toast */} {favToast && (
{favToast === 'added' ? t('♥ Salvo nos favoritos') : t('♡ Removido dos favoritos')} {favToast === 'added' && ( )}
)}
); } window.PropertyDetailScreen = PropertyDetailScreen;