// home.jsx — HomePage // t, useState, useEffect etc. available from components.jsx (loaded first) function HomePage({ data, setRoute, onOpenDestiny }) { const seed = data || DOPO.SEED; const { user, services, assets, memories, people } = seed; const totalItems = services.length + assets.length; const assignedItems = services.filter(s => s.destiny && s.destiny !== null).length + assets.filter(a => a.destiny && a.destiny !== null).length; const memoriesCount = memories.length; const circleCount = people.length; const unassignedServices = services.filter(s => !s.destiny).slice(0, 3); const latestMemories = memories.slice(0, 4); const latestServices = services.slice(0, 5); const hour = new Date().getHours(); const greeting = hour < 12 ? 'Buongiorno' : hour < 18 ? 'Buon pomeriggio' : 'Buonasera'; const suggestions = [ { icon: 'shield', color: 'var(--olive-500)', title: 'Completa l\'inventario', desc: `${totalItems - assignedItems} servizi senza destino. Decidili ora.`, action: () => setRoute('inventory'), }, { icon: 'memories', color: 'var(--jade-700)', title: 'Scrivi una memoria', desc: 'Una lettera, un audio, una foto. Per chi ami.', action: () => setRoute('memories'), }, { icon: 'circle', color: 'var(--gr-700)', title: 'Invita la cerchia', desc: `${people.filter(p => !p.invited).length} persone non ancora invitate.`, action: () => setRoute('circle'), }, ]; const kindLabel = { letter: 'Lettera', audio: 'Audio', photo: 'Foto', video: 'Video', doc: 'Documento' }; const kindClass = { letter: 'mem-letter', audio: 'mem-audio', photo: 'mem-photo', video: 'mem-video', doc: 'mem-doc' }; return (
{/* Hero */}
{/* Left */}
{greeting}, {user.name.split(' ')[0]}

{t.home.hero_title_serif}
{t.home.hero_title_serif_2}

{t.home.hero_sub}

{/* Right — progress card */}
{/* Header */}
{t.home.plan_title}
{seed.profileProgress}% {t.home.plan_complete}
{/* Stats */}
{/* Circle */}
{t.home.your_circle}
{people.map(p => (
{p.name.split(' ')[0]}
))}
{/* Unassigned alert */} {unassignedServices.length > 0 && (
{unassignedServices.length + services.filter(s => !s.destiny).length - unassignedServices.length} servizi senza destino
Decidi cosa succederà a Google Drive, Fineco e altri.
)}
{/* Suggestions */}
setRoute('inventory')}> {t.home.see_all} } />
{suggestions.map((s, i) => (
{s.title}
{s.desc}
Vai
))}
{/* Latest memories */}
setRoute('memories')}> {t.home.see_all} } />
{latestMemories.map(m => { const cls = kindClass[m.kind] || 'mem-doc'; const kl = kindLabel[m.kind] || m.kind; const pMap = Object.fromEntries(seed.people.map(p => [p.id, p])); return (
setRoute('memories')}>
{kl}
{m.kind === 'letter' && (
{m.body}
)} {m.kind === 'photo' && (
🌊
)} {m.kind === 'audio' && (
DURATA
{m.duration}
)} {m.kind === 'video' && (
VIDEO
{m.duration}
)} {/* Assignees */} {m.assignees.length > 0 && (
)}
{m.title}
{new Date(m.date).toLocaleDateString('it-IT', { year: 'numeric', month: 'short', day: 'numeric' })}
); })}
{/* Latest services */}
setRoute('inventory')}> {t.home.see_all} } />
{latestServices.map(s => ( onOpenDestiny(s, 'service')}> ))}
Servizio Categoria Destino Persone
{s.name}
{s.email}
{s.category} {s.assignees.length > 0 ? ( ) : ( )}
); } Object.assign(window, { HomePage });