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) => {
return (
<Layout page={"capture"}>
<Layout page="capture">
<CommonDisplay
{...props}
hasSearchbar={true}
hasCapture={true}
hasAdvancedOptions={false}
placeholder={"Get best title match..."}
placeholder="Get best title match..."
displaySeeMoreHint={false}
displayQuestionsWrapper={displayQuestionsWrapperForCapture}
/>

View File

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