51 lines
935 B
TypeScript
51 lines
935 B
TypeScript
import { h } from 'preact';
|
|
import { connect } from 'unistore/preact'
|
|
|
|
import actions from './../actions';
|
|
|
|
// import Bundle from './../components/bundle';
|
|
|
|
interface Props {
|
|
bundles: any[];
|
|
getBundles: () => void,
|
|
}
|
|
|
|
function Bundle(bundle) {
|
|
return (
|
|
<div class="bundle">
|
|
<h2>{bundle.username} - {bundle.seller}</h2>
|
|
<h3>{bundle.total} {bundle.currency}</h3>
|
|
<h4>Ships: {bundle.mentionsAustralia && 'AU'} {bundle.mentionsWorldwide && 'WORLD'}</h4>
|
|
{bundle.items.map(i => (
|
|
<div key={i.id}>
|
|
<a href={i.uri}>
|
|
<h4>{i.description}</h4>
|
|
</a>
|
|
<h5>{i.price} {i.currency}</h5>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
|
|
function Home({ bundles, getBundles }: Props) {
|
|
if (!bundles.length) {
|
|
getBundles();
|
|
|
|
return (
|
|
<div class={'home'}>
|
|
loading...
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div class={'home'}>
|
|
{bundles.map(Bundle)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default connect('bundles', actions)(Home);
|