) {
return (
@@ -39,7 +44,15 @@ export default function QuestionSearchBar<
label="Sort by"
options={sortOptions}
value={sortValue}
- onChange={onSortChange}>
+ onChange={onSortChange}
+ />
+
);
}
diff --git a/apps/portal/src/pages/questions/index.tsx b/apps/portal/src/pages/questions/index.tsx
index 5ca513fe..d7558bb0 100644
--- a/apps/portal/src/pages/questions/index.tsx
+++ b/apps/portal/src/pages/questions/index.tsx
@@ -1,7 +1,9 @@
import { subMonths, subYears } from 'date-fns';
import { useRouter } from 'next/router';
import { useEffect, useMemo, useState } from 'react';
+import { NoSymbolIcon } from '@heroicons/react/24/outline';
import type { QuestionsQuestionType } from '@prisma/client';
+import { SlideOut } from '@tih/ui';
import QuestionOverviewCard from '~/components/questions/card/QuestionOverviewCard';
import ContributeQuestionCard from '~/components/questions/ContributeQuestionCard';
@@ -59,17 +61,22 @@ export default function QuestionsHomePage() {
: undefined;
}, [selectedQuestionAge]);
- const { data: questions } = trpc.useQuery([
- 'questions.questions.getQuestionsByFilter',
+ const { data: questions } = trpc.useQuery(
+ [
+ 'questions.questions.getQuestionsByFilter',
+ {
+ companies: selectedCompanies,
+ endDate: today,
+ locations: selectedLocations,
+ questionTypes: selectedQuestionTypes,
+ roles: [],
+ startDate,
+ },
+ ],
{
- companies: selectedCompanies,
- endDate: today,
- locations: selectedLocations,
- questionTypes: selectedQuestionTypes,
- roles: [],
- startDate,
+ keepPreviousData: true,
},
- ]);
+ );
const utils = trpc.useContext();
const { mutate: createQuestion } = trpc.useMutation(
@@ -83,6 +90,7 @@ export default function QuestionsHomePage() {
const [hasLanded, setHasLanded] = useState(false);
const [loaded, setLoaded] = useState(false);
+ const [filterDrawerOpen, setFilterDrawerOpen] = useState(false);
const companyFilterOptions = useMemo(() => {
return COMPANIES.map((company) => ({
@@ -153,79 +161,72 @@ export default function QuestionsHomePage() {
return null;
}
+ const filterSidebar = (
+
+ {
+ if (checked) {
+ setSelectedCompanies([...selectedCompanies, optionValue]);
+ } else {
+ setSelectedCompanies(
+ selectedCompanies.filter((company) => company !== optionValue),
+ );
+ }
+ }}
+ />
+ {
+ if (checked) {
+ setSelectedQuestionTypes([...selectedQuestionTypes, optionValue]);
+ } else {
+ setSelectedQuestionTypes(
+ selectedQuestionTypes.filter(
+ (questionType) => questionType !== optionValue,
+ ),
+ );
+ }
+ }}
+ />
+ {
+ setSelectedQuestionAge(optionValue);
+ }}
+ />
+ {
+ if (checked) {
+ setSelectedLocations([...selectedLocations, optionValue]);
+ } else {
+ setSelectedLocations(
+ selectedLocations.filter((location) => location !== optionValue),
+ );
+ }
+ }}
+ />
+
+ );
+
return !hasLanded ? (
) : (
-
-
-
-
-
-
+
+
+
+
+
{
createQuestion({
@@ -250,6 +251,9 @@ export default function QuestionsHomePage() {
},
]}
sortValue="most-recent"
+ onFilterOptionsToggle={() => {
+ setFilterDrawerOpen(!filterDrawerOpen);
+ }}
onSortChange={(value) => {
// eslint-disable-next-line no-console
console.log(value);
@@ -257,7 +261,6 @@ export default function QuestionsHomePage() {
/>
{(questions ?? []).map((question) => (
))}
+ {(questions ?? []).length === 0 && (
+
+
+
Nothing found. Try changing your search filters.
+
+ )}
+
+
+ {
+ setFilterDrawerOpen(false);
+ }}>
+ {filterSidebar}
+
+
);