Files
crates/client/src/routes/user.tsx
T
2022-08-08 19:51:17 +10:00

38 lines
745 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 {
userId: string,
offers: any[],
getUserOffers: (userId: string) => void,
}
const User = ({ userId }: Props) => {
const [offers, setOffers] = useState([]);
useEffect(() => {
actions.getOffers(userId).then(setOffers);
}, [userId]);
if (!offers.length) {
return (
<div class={'home'}>
loading...
</div>
);
}
return (
<div class={'home'}>
{offers.map(Bundle)}
</div>
);
};
export default User;