43 lines
890 B
TypeScript
43 lines
890 B
TypeScript
import { h } from 'preact';
|
|
import { useState, useEffect } from 'preact/hooks';
|
|
|
|
// import style from './style.less';
|
|
import actions from './../actions';
|
|
import Bundle from './../components/bundle';
|
|
|
|
interface Props {
|
|
user: any,
|
|
offers: any[],
|
|
getUserOffers: (userId: string) => void,
|
|
}
|
|
|
|
const User = ({ user }: Props) => {
|
|
const [offers, setOffers] = useState([]);
|
|
|
|
useEffect(() => {
|
|
async function getWants() {
|
|
const [error, wants] = await actions.getWants();
|
|
if (error) return console.error(error);
|
|
setOffers(wants);
|
|
}
|
|
getWants();
|
|
}, []);
|
|
|
|
|
|
if (!offers.length) {
|
|
return (
|
|
<div class={'home'}>
|
|
loading...
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div class={'home'}>
|
|
{offers.map(Bundle)}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default User;
|