From 630005e541abc98d856b12a24c378994b15d5825 Mon Sep 17 00:00:00 2001 From: wlren Date: Sat, 8 Oct 2022 23:42:59 +0800 Subject: [PATCH] [questions][ui] Question age url param change --- apps/portal/src/pages/questions/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/portal/src/pages/questions/index.tsx b/apps/portal/src/pages/questions/index.tsx index 5bebfa4e..f6dbef87 100644 --- a/apps/portal/src/pages/questions/index.tsx +++ b/apps/portal/src/pages/questions/index.tsx @@ -77,9 +77,13 @@ export default function QuestionsHomePage() { // Set url query params useEffect(() => { if (router.isReady && !isSearchInitialized) { + const paramQuestionAge = router.query.questionAge; + const questionAge = Array.isArray(paramQuestionAge) + ? paramQuestionAge[0] + : paramQuestionAge ?? 'all'; setSelectedCompanies(paramToArray(router.query.companies)); setSelectedQuestionTypes(paramToArray(router.query.questionTypes)); - setSelectedQuestionAge(router.query.questionAge as string); + setSelectedQuestionAge(questionAge); setSelectedLocations(paramToArray(router.query.locations)); setIsSearchInitialized(true); @@ -111,8 +115,12 @@ export default function QuestionsHomePage() { query: { companies: selectedCompanies, locations: selectedLocations, - questionAge: selectedQuestionAge, questionTypes: selectedQuestionTypes, + ...(selectedQuestionAge !== 'all' + ? { + questionAge: selectedQuestionAge, + } + : {}), }, }, undefined,