search just uses query
This commit is contained in:
1 parent
5fab62345b
commit
6d18a86697
8 files changed
+18
-17
No files matched your search
@@ -1,5 +1,7 @@
|
|||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
search input simplify
|
||||||
|
|
||||||
status stepper
|
status stepper
|
||||||
|
|
||||||
queue up wantlist adds to gracefully handle rate limiting
|
queue up wantlist adds to gracefully handle rate limiting
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ async function start() {
|
|||||||
events,
|
events,
|
||||||
} = createServices(log);
|
} = createServices(log);
|
||||||
|
|
||||||
// events.emit(Events.StartupSync);
|
events.emit(Events.StartupSync);
|
||||||
// events.emit(Events.ListingsUpdated);
|
// events.emit(Events.ListingsUpdated);
|
||||||
|
|
||||||
api.listen();
|
api.listen();
|
||||||
|
|||||||
+3
-3
@@ -93,9 +93,9 @@ export default function createApi(log: Log, pg: Pg, discogs, offers, events) {
|
|||||||
ctx.response.body = wants;
|
ctx.response.body = wants;
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/want/search', async function wantPost(ctx, next) {
|
router.post('/want/search', async function wantSearch(ctx, next) {
|
||||||
const { artist, title } = ctx.request.body;
|
const { query } = ctx.request.body;
|
||||||
const results = await discogs.search(artist, title);
|
const results = await discogs.search(query);
|
||||||
ctx.response.body = results;
|
ctx.response.body = results;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -58,10 +58,9 @@ export default function createDiscogs(log: Log, pg: Pg) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function search(artist: string, title: string) {
|
async function search(query: string) {
|
||||||
const url = new URL(`${apiBase}/database/search`);
|
const url = new URL(`${apiBase}/database/search`);
|
||||||
url.searchParams.append('artist', artist);
|
url.searchParams.append('query', query);
|
||||||
url.searchParams.append('title', title);
|
|
||||||
url.searchParams.append('type', 'release');
|
url.searchParams.append('type', 'release');
|
||||||
url.searchParams.append('format', 'vinyl');
|
url.searchParams.append('format', 'vinyl');
|
||||||
const { data: { results } } = await api.get(url.href);
|
const { data: { results } } = await api.get(url.href);
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
|
||||||
export default function Swirl() {
|
export default function Swirl() {
|
||||||
return <div class='swirl' />;
|
return <div class='swirl' />;
|
||||||
}
|
}
|
||||||
+2
-2
@@ -48,8 +48,8 @@ const actions = {
|
|||||||
return api.get('/want/all');
|
return api.get('/want/all');
|
||||||
},
|
},
|
||||||
|
|
||||||
postWantSearch: async function postWantSearch(artist, title) {
|
postWantSearch: async function postWantSearch(query) {
|
||||||
return api.post('/want/search', { artist, title });
|
return api.post('/want/search', { query });
|
||||||
},
|
},
|
||||||
|
|
||||||
postWant: async function postWant(releaseId) {
|
postWant: async function postWant(releaseId) {
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ function Result(r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const User = () => {
|
const User = () => {
|
||||||
const [artist, setArtist] = useState('')
|
const [query, setQuery] = useState('')
|
||||||
const [title, setTitle] = useState('');
|
const [title, setTitle] = useState('');
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
const [results, setResults] = useState([]);
|
const [results, setResults] = useState([]);
|
||||||
const [infoText, setInfoText] = useState('');
|
const [infoText, setInfoText] = useState('');
|
||||||
|
|
||||||
async function fetchResults() {
|
async function fetchResults() {
|
||||||
const [error, results] = await http.postWantSearch(artist, title);
|
const [error, results] = await http.postWantSearch(query);
|
||||||
|
|
||||||
if (results.length === 0) {
|
if (results.length === 0) {
|
||||||
setResults([]);
|
setResults([]);
|
||||||
@@ -89,10 +89,8 @@ const User = () => {
|
|||||||
<div class='search'>
|
<div class='search'>
|
||||||
<div>
|
<div>
|
||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<label for="artist">Artist</label>
|
<label for="query">Query</label>
|
||||||
<input type="text" name="artist" ref={searchRef} placeholder="Ben Klock" id="artist" value={artist} onChange={e => setArtist((e.target as HTMLInputElement).value) } required />
|
<input type="text" name="query" ref={searchRef} placeholder="ben klock subzero" id="query" value={query} onChange={e => setQuery((e.target as HTMLInputElement).value) } required />
|
||||||
<label for="title">Title</label>
|
|
||||||
<input type="text" name="title" placeholder="Subzero" id="title" value={title} onChange={e => setTitle((e.target as HTMLInputElement).value)} required />
|
|
||||||
<input type="submit" value="Search" onClick={handleSubmit} />
|
<input type="submit" value="Search" onClick={handleSubmit} />
|
||||||
</form>
|
</form>
|
||||||
<hr />
|
<hr />
|
||||||
@@ -100,7 +98,7 @@ const User = () => {
|
|||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<label for="Discogs">Discogs Username</label>
|
<label for="Discogs">Discogs Username</label>
|
||||||
<input type="text" name="username" placeholder="Discogs Username" id="username" value={username} onChange={e => setUsername((e.target as HTMLInputElement).value) } required />
|
<input type="text" name="username" placeholder="Discogs Username" id="username" value={username} onChange={e => setUsername((e.target as HTMLInputElement).value) } required />
|
||||||
<input type="submit" value="Sync" onClick={handleDiscogsSubmit} />
|
<input type="submit" value="Sync Wantlist" onClick={handleDiscogsSubmit} />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ button, [type=submit] {
|
|||||||
|
|
||||||
.swirl {
|
.swirl {
|
||||||
grid-area: swirl;
|
grid-area: swirl;
|
||||||
height: 10rem;
|
height: 15rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user