// home.jsx — gs.town home / dashboard. Exported to window.
const SAFE_TOP = 54;
function SectionHead({ title, action, onAction }) {
return (
{title}
{action && (
)}
);
}
function HomeHeader({ dark }) {
return (
);
}
function QuickActions({ onAct }) {
return (
{QUICK_ACTIONS.map(a => (
))}
);
}
function FeedCard({ report, onOpen, onUp, upActive }) {
const c = CATS[report.cat] || CATS.lainnya;
return (
onOpen(report)} style={{ display: 'flex', width: '100%', textAlign: 'left',
gap: 0, background: 'var(--surface)', border: '1px solid var(--border)', borderRadius: 'var(--r-card)',
overflow: 'hidden', cursor: 'pointer', boxShadow: 'var(--sh-1)', fontFamily: 'var(--font)' }}>
{c.label}
{report.time}
{report.title}
{report.area}
{ e.stopPropagation(); onUp(report.id); }}>
);
}
function PlaceCard({ place, onOpen, wide = false }) {
const dc = DIR_CATS.find(d => d.key === place.cat) || DIR_CATS[0];
return (
);
}
function Home({ dark, t, go, openReport, openPlace, startReport, reports = [], places = [], myUps = {}, onUp, loading }) {
const toggleUp = onUp || (() => {});
const newCount = reports.filter(r => r.status === 'open').length;
const shownPlaces = t.showSponsored ? places : places.filter(p => !p.sponsored);
const onQuick = (k) => {
if (k === 'dir') return go('directory');
if (k === 'announce') return go('home');
return startReport(k);
};
return (
{/* hero map */}
go('map')} style={{ position: 'relative', height: 248, margin: '0 0',
borderRadius: 0, overflow: 'hidden', cursor: 'pointer' }}>
go('map')} />
{/* floating "new reports" card */}
{newCount} laporan baru hari ini
Buka peta
{/* quick actions */}
{/* feed */}
go('map')} />
{reports.length === 0 ? (
{loading ? 'Memuat laporan...' : 'Belum ada laporan. Jadi yang pertama melapor!'}
) : reports.slice(0, 6).map(r => (
))}
{/* popular places */}
go('directory')} />
{shownPlaces.length === 0 ? (
Direktori segera hadir.
) : shownPlaces.map(p =>
)}
);
}
Object.assign(window, { Home, SectionHead, PlaceCard, FeedCard, QuickActions, SAFE_TOP });