wants wip"
This commit is contained in:
1 parent
c99f6fd2b6
commit
f5e75f4fe6
7 files changed
+33
-12
No files matched your search
@@ -48,6 +48,10 @@ const actions = {
|
||||
return api.get(`/user/${userId}/offers`);
|
||||
},
|
||||
|
||||
getWants: async function getWants() {
|
||||
return api.get('/wants');
|
||||
},
|
||||
|
||||
getLogin: async function getLogin() {
|
||||
return api.get('/auth/login')
|
||||
},
|
||||
|
||||
+1
-4
@@ -2,7 +2,6 @@ import { h } from 'preact';
|
||||
import { useState, useEffect } from 'preact/hooks';
|
||||
import { Route, Router, route } from 'preact-router';
|
||||
|
||||
// import mcratesStore from './store';
|
||||
import actions from './actions';
|
||||
|
||||
import Header from './components/header';
|
||||
@@ -12,8 +11,6 @@ import Login from './routes/login';
|
||||
import Search from './routes/search';
|
||||
import User from './routes/user';
|
||||
|
||||
// const store = mcratesStore();
|
||||
|
||||
function App() {
|
||||
const [user, setUser] = useState(null);
|
||||
|
||||
@@ -41,7 +38,7 @@ function App() {
|
||||
<Route path="/" component={Home} />
|
||||
<Route path="/login" component={Login} success={loginSuccess} />
|
||||
<Route path="/search" component={Search} />
|
||||
<Route path="/user/:userId" component={User} />
|
||||
<Route path="/list/" component={User} user={user} />
|
||||
</Router>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -5,8 +5,8 @@ const Header = ({ user }) => {
|
||||
const nav = () => (
|
||||
<nav>
|
||||
<a href="/search">Offers</a>
|
||||
<a href='/list'>List</a>
|
||||
<a href="/search">Search</a>
|
||||
<a href={`/user/${user.id}`}>List</a>
|
||||
</nav>
|
||||
);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const User = () => {
|
||||
const [noResults, setNoResults] = useState(false);
|
||||
|
||||
async function fetchResults() {
|
||||
const { data } = await axios.post(`http://localhost:41337/want/search`, {
|
||||
const { data } = await axios.post(`http://localhost:41337/wants/search`, {
|
||||
artist,
|
||||
title,
|
||||
});
|
||||
|
||||
@@ -6,17 +6,22 @@ import actions from './../actions';
|
||||
import Bundle from './../components/bundle';
|
||||
|
||||
interface Props {
|
||||
userId: string,
|
||||
user: any,
|
||||
offers: any[],
|
||||
getUserOffers: (userId: string) => void,
|
||||
}
|
||||
|
||||
const User = ({ userId }: Props) => {
|
||||
const User = ({ user }: Props) => {
|
||||
const [offers, setOffers] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
actions.getOffers(userId).then(setOffers);
|
||||
}, [userId]);
|
||||
async function getWants() {
|
||||
const [error, wants] = await actions.getWants();
|
||||
if (error) return console.error(error);
|
||||
setOffers(wants);
|
||||
}
|
||||
getWants();
|
||||
}, []);
|
||||
|
||||
|
||||
if (!offers.length) {
|
||||
|
||||
Reference in new issue
Block a user