🏗️ Refactored the search form
This commit is contained in:
@@ -148,44 +148,37 @@ 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: {
|
format: "json",
|
||||||
format: "json",
|
// hack
|
||||||
// hack
|
query: issueSearchQuery.inferredIssueDetails.name
|
||||||
query: issueSearchQuery.inferredIssueDetails.name
|
.replace(/[^a-zA-Z0-9 ]/g, "")
|
||||||
.replace(/[^a-zA-Z0-9 ]/g, "")
|
.trim(),
|
||||||
.trim(),
|
limit: "100",
|
||||||
limit: "100",
|
page: 1,
|
||||||
page: 1,
|
resources: "volume",
|
||||||
resources: "volume",
|
scorerConfiguration: {
|
||||||
scorerConfiguration: {
|
searchParams: issueSearchQuery.inferredIssueDetails,
|
||||||
searchParams: issueSearchQuery.inferredIssueDetails,
|
|
||||||
},
|
|
||||||
rawFileDetails: searchPayload,
|
|
||||||
},
|
},
|
||||||
transformResponse: (r) => {
|
rawFileDetails: searchPayload,
|
||||||
const matches = JSON.parse(r);
|
},
|
||||||
return matches;
|
transformResponse: (r) => {
|
||||||
// return sortBy(matches, (match) => -match.score);
|
const matches = JSON.parse(r);
|
||||||
},
|
return matches;
|
||||||
})
|
// 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) &&
|
matches = response.data.results;
|
||||||
response.data.results.length === 1
|
} else {
|
||||||
) {
|
matches = response.data.map((match) => match);
|
||||||
matches = response.data.results;
|
}
|
||||||
} else {
|
const scoredMatches = matches.sort((a, b) => b.score - a.score);
|
||||||
matches = response.data.map((match) => match);
|
setComicVineMatches(scoredMatches);
|
||||||
}
|
|
||||||
const scoredMatches = matches.sort((a, b) => b.score - a.score);
|
|
||||||
setComicVineMatches(scoredMatches);
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user