auth init

This commit is contained in:
ntr committed 2022-08-08 19:51:17 +10:00
1 parent faa2e70e08
commit 413aeedadf
29 files changed
+2854 -649

No files matched your search

+16 -23
View File
@@ -1,9 +1,7 @@
import { h } from 'preact';
import { useState, useEffect } from 'preact/hooks';
import { connect } from 'unistore/preact';
import axios from 'axios';
import style from './style.less';
// import style from './style.less';
import actions from './../actions';
import Bundle from './../components/bundle';
@@ -14,31 +12,26 @@ interface Props {
}
const User = ({ userId }: Props) => {
const [offers, setOffers] = useState([]);
const [offers, setOffers] = useState([]);
useEffect(() => {
async function fetchOffers() {
const { data } = await axios.get(`http://localhost:41337/user/${userId}/offers`);
setOffers(data);
}
fetchOffers();
useEffect(() => {
actions.getOffers(userId).then(setOffers);
}, [userId]);
if (!offers.length) {
return (
<div class={'home'}>
loading...
</div>
);
}
if (!offers.length) {
return (
<div class={'home'}>
loading...
</div>
);
}
return (
<div class={'home'}>
{offers.map(Bundle)}
</div>
);
<div class={'home'}>
{offers.map(Bundle)}
</div>
);
};
export default connect(['offers'], actions)(User);
export default User;