🏗️ Refactored the search form

This commit is contained in:
2024-01-04 09:24:56 -05:00
parent ad12c05514
commit 09151a99e9
2 changed files with 31 additions and 38 deletions

View File

@@ -148,8 +148,7 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
seriesSearchQuery, seriesSearchQuery,
) => { ) => {
try { try {
await axios const response = await axios({
.request({
url: `${COMICVINE_SERVICE_URI}/volumeBasedSearch`, url: `${COMICVINE_SERVICE_URI}/volumeBasedSearch`,
method: "POST", method: "POST",
data: { data: {
@@ -171,21 +170,15 @@ export const ComicDetail = (data: ComicDetailProps): ReactElement => {
return matches; return matches;
// return sortBy(matches, (match) => -match.score); // return sortBy(matches, (match) => -match.score);
}, },
}) });
.then((response) => {
console.log(response);
let matches: any = []; let matches: any = [];
if ( if (!isNil(response.data.results) && response.data.results.length === 1) {
!isNil(response.data.results) &&
response.data.results.length === 1
) {
matches = response.data.results; matches = response.data.results;
} else { } else {
matches = response.data.map((match) => match); matches = response.data.map((match) => match);
} }
const scoredMatches = matches.sort((a, b) => b.score - a.score); const scoredMatches = matches.sort((a, b) => b.score - a.score);
setComicVineMatches(scoredMatches); setComicVineMatches(scoredMatches);
});
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }

View File

@@ -24,7 +24,7 @@ export const ComicVineMatchPanel = (comicVineData): ReactElement => {
<> <>
<article <article
role="alert" role="alert"
className="mt-4 rounded-lg max-w-screen-md border-s-4 border-blue-500 bg-blue-50 p-4 dark:border-s-4 dark:border-blue-600 dark:bg-blue-300 dark:text-slate-600 text-sm" className="mt-4 rounded-lg max-w-screen-md border-s-4 border-yellow-500 bg-yellow-50 p-4 dark:border-s-4 dark:border-yellow-600 dark:bg-yellow-300 dark:text-slate-600 text-sm"
> >
<div> <div>
<p>ComicVine match results are an approximation.</p> <p>ComicVine match results are an approximation.</p>