import { h } from 'preact'; import { route } from 'preact-router'; import { useSelector } from 'react-redux' import { State } from './../store'; import * as toast from './../toast'; import OfferGroup from './../components/offer.group'; const GroupNav = (want) => { const href = want._count.offers ? `#${want.release}` : null; return (
{want.data.artists_sort} - {want.data.title} {want._count.offers}
); }; function Home() { const offers = useSelector((state: State) => state.offers); const wants = useSelector((state: State) => state.wants); if (offers && offers.length === 0) { toast.info('no offers', 'You have no offers yet, search for some more items.'); route('/search'); } if (!offers || !wants) return
loading...
; return (
{offers.map(OfferGroup)}
); } export default Home;