fix: capture page

This commit is contained in:
Vyacheslav Matyukhin 2022-04-21 00:35:48 +04:00
parent 689edac83e
commit db85d80ddb
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C
2 changed files with 7 additions and 6 deletions

View File

@ -10,13 +10,13 @@ export { getServerSideProps } from "../web/search/anySearchPage";
const CapturePage: NextPage<Props> = (props) => { const CapturePage: NextPage<Props> = (props) => {
return ( return (
<Layout page={"capture"}> <Layout page="capture">
<CommonDisplay <CommonDisplay
{...props} {...props}
hasSearchbar={true} hasSearchbar={true}
hasCapture={true} hasCapture={true}
hasAdvancedOptions={false} hasAdvancedOptions={false}
placeholder={"Get best title match..."} placeholder="Get best title match..."
displaySeeMoreHint={false} displaySeeMoreHint={false}
displayQuestionsWrapper={displayQuestionsWrapperForCapture} displayQuestionsWrapper={displayQuestionsWrapperForCapture}
/> />

View File

@ -81,27 +81,28 @@ const CommonDisplay: React.FC<Props> = ({
if (queryIsEmpty) { if (queryIsEmpty) {
const filterManually = (results: QuestionFragment[]) => { const filterManually = (results: QuestionFragment[]) => {
let filteredResults = [...results];
if ( if (
queryParameters.forecastingPlatforms && queryParameters.forecastingPlatforms &&
queryParameters.forecastingPlatforms.length > 0 queryParameters.forecastingPlatforms.length > 0
) { ) {
results = results.filter((result) => filteredResults = filteredResults.filter((result) =>
queryParameters.forecastingPlatforms.includes(result.platform.id) queryParameters.forecastingPlatforms.includes(result.platform.id)
); );
} }
if (queryParameters.starsThreshold === 4) { if (queryParameters.starsThreshold === 4) {
results = results.filter( filteredResults = filteredResults.filter(
(result) => result.qualityIndicators.stars >= 4 (result) => result.qualityIndicators.stars >= 4
); );
} }
if (queryParameters.forecastsThreshold) { if (queryParameters.forecastsThreshold) {
// TODO / FIXME / remove? // TODO / FIXME / remove?
} }
return results; return filteredResults;
}; };
return filterManually(defaultResults); return filterManually(defaultResults);
} else { } else {
return queryResults.data?.result; return queryResults.data?.result || [];
} }
}, [queryResults.data, queryParameters]); }, [queryResults.data, queryParameters]);