|
|
@ -13,6 +13,7 @@ import LandingComponent from '~/components/questions/LandingComponent';
|
|
|
|
import QuestionSearchBar from '~/components/questions/QuestionSearchBar';
|
|
|
|
import QuestionSearchBar from '~/components/questions/QuestionSearchBar';
|
|
|
|
|
|
|
|
|
|
|
|
import type { QuestionAge } from '~/utils/questions/constants';
|
|
|
|
import type { QuestionAge } from '~/utils/questions/constants';
|
|
|
|
|
|
|
|
import { ROLES } from '~/utils/questions/constants';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
COMPANIES,
|
|
|
|
COMPANIES,
|
|
|
|
LOCATIONS,
|
|
|
|
LOCATIONS,
|
|
|
@ -47,6 +48,9 @@ export default function QuestionsHomePage() {
|
|
|
|
] = useSearchFilterSingle<QuestionAge>('questionAge', {
|
|
|
|
] = useSearchFilterSingle<QuestionAge>('questionAge', {
|
|
|
|
defaultValue: 'all',
|
|
|
|
defaultValue: 'all',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [selectedRoles, setSelectedRoles, areRolesInitialized] =
|
|
|
|
|
|
|
|
useSearchFilter('roles');
|
|
|
|
const [selectedLocations, setSelectedLocations, areLocationsInitialized] =
|
|
|
|
const [selectedLocations, setSelectedLocations, areLocationsInitialized] =
|
|
|
|
useSearchFilter('locations');
|
|
|
|
useSearchFilter('locations');
|
|
|
|
|
|
|
|
|
|
|
@ -69,7 +73,7 @@ export default function QuestionsHomePage() {
|
|
|
|
endDate: today,
|
|
|
|
endDate: today,
|
|
|
|
locations: selectedLocations,
|
|
|
|
locations: selectedLocations,
|
|
|
|
questionTypes: selectedQuestionTypes,
|
|
|
|
questionTypes: selectedQuestionTypes,
|
|
|
|
roles: [],
|
|
|
|
roles: selectedRoles,
|
|
|
|
startDate,
|
|
|
|
startDate,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -113,6 +117,13 @@ export default function QuestionsHomePage() {
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}, [selectedQuestionAge]);
|
|
|
|
}, [selectedQuestionAge]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const roleFilterOptions = useMemo(() => {
|
|
|
|
|
|
|
|
return ROLES.map((role) => ({
|
|
|
|
|
|
|
|
...role,
|
|
|
|
|
|
|
|
checked: selectedRoles.includes(role.value),
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
}, [selectedRoles]);
|
|
|
|
|
|
|
|
|
|
|
|
const locationFilterOptions = useMemo(() => {
|
|
|
|
const locationFilterOptions = useMemo(() => {
|
|
|
|
return LOCATIONS.map((location) => ({
|
|
|
|
return LOCATIONS.map((location) => ({
|
|
|
|
...location,
|
|
|
|
...location,
|
|
|
@ -124,6 +135,7 @@ export default function QuestionsHomePage() {
|
|
|
|
const { company, location, questionType } = data;
|
|
|
|
const { company, location, questionType } = data;
|
|
|
|
|
|
|
|
|
|
|
|
setSelectedCompanies([company]);
|
|
|
|
setSelectedCompanies([company]);
|
|
|
|
|
|
|
|
setSelectedRoles([]);
|
|
|
|
setSelectedLocations([location]);
|
|
|
|
setSelectedLocations([location]);
|
|
|
|
setSelectedQuestionTypes([questionType as QuestionsQuestionType]);
|
|
|
|
setSelectedQuestionTypes([questionType as QuestionsQuestionType]);
|
|
|
|
setHasLanded(true);
|
|
|
|
setHasLanded(true);
|
|
|
@ -134,12 +146,14 @@ export default function QuestionsHomePage() {
|
|
|
|
areCompaniesInitialized &&
|
|
|
|
areCompaniesInitialized &&
|
|
|
|
areQuestionTypesInitialized &&
|
|
|
|
areQuestionTypesInitialized &&
|
|
|
|
isQuestionAgeInitialized &&
|
|
|
|
isQuestionAgeInitialized &&
|
|
|
|
|
|
|
|
areRolesInitialized &&
|
|
|
|
areLocationsInitialized
|
|
|
|
areLocationsInitialized
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}, [
|
|
|
|
}, [
|
|
|
|
areCompaniesInitialized,
|
|
|
|
areCompaniesInitialized,
|
|
|
|
areQuestionTypesInitialized,
|
|
|
|
areQuestionTypesInitialized,
|
|
|
|
isQuestionAgeInitialized,
|
|
|
|
isQuestionAgeInitialized,
|
|
|
|
|
|
|
|
areRolesInitialized,
|
|
|
|
areLocationsInitialized,
|
|
|
|
areLocationsInitialized,
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
@ -156,10 +170,12 @@ export default function QuestionsHomePage() {
|
|
|
|
locations: selectedLocations,
|
|
|
|
locations: selectedLocations,
|
|
|
|
questionAge: selectedQuestionAge,
|
|
|
|
questionAge: selectedQuestionAge,
|
|
|
|
questionTypes: selectedQuestionTypes,
|
|
|
|
questionTypes: selectedQuestionTypes,
|
|
|
|
|
|
|
|
roles: selectedRoles,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const hasFilter =
|
|
|
|
const hasFilter =
|
|
|
|
selectedCompanies.length > 0 ||
|
|
|
|
selectedCompanies.length > 0 ||
|
|
|
|
|
|
|
|
selectedRoles.length > 0 ||
|
|
|
|
selectedLocations.length > 0 ||
|
|
|
|
selectedLocations.length > 0 ||
|
|
|
|
selectedQuestionAge !== 'all' ||
|
|
|
|
selectedQuestionAge !== 'all' ||
|
|
|
|
selectedQuestionTypes.length > 0;
|
|
|
|
selectedQuestionTypes.length > 0;
|
|
|
@ -175,6 +191,7 @@ export default function QuestionsHomePage() {
|
|
|
|
loaded,
|
|
|
|
loaded,
|
|
|
|
pathname,
|
|
|
|
pathname,
|
|
|
|
selectedCompanies,
|
|
|
|
selectedCompanies,
|
|
|
|
|
|
|
|
selectedRoles,
|
|
|
|
selectedLocations,
|
|
|
|
selectedLocations,
|
|
|
|
selectedQuestionAge,
|
|
|
|
selectedQuestionAge,
|
|
|
|
selectedQuestionTypes,
|
|
|
|
selectedQuestionTypes,
|
|
|
@ -235,6 +252,31 @@ export default function QuestionsHomePage() {
|
|
|
|
setSelectedQuestionAge(optionValue);
|
|
|
|
setSelectedQuestionAge(optionValue);
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
<FilterSection
|
|
|
|
|
|
|
|
label="Roles"
|
|
|
|
|
|
|
|
options={roleFilterOptions}
|
|
|
|
|
|
|
|
renderInput={({ onOptionChange, options, field }) => (
|
|
|
|
|
|
|
|
<Typeahead
|
|
|
|
|
|
|
|
{...field}
|
|
|
|
|
|
|
|
label=""
|
|
|
|
|
|
|
|
options={options}
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
|
|
|
|
onSelect={({ value }) => {
|
|
|
|
|
|
|
|
onOptionChange(value, true);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
onOptionChange={(optionValue, checked) => {
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
|
|
|
setSelectedRoles([...selectedRoles, optionValue]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setSelectedRoles(
|
|
|
|
|
|
|
|
selectedRoles.filter((role) => role !== optionValue),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
<FilterSection
|
|
|
|
<FilterSection
|
|
|
|
label="Location"
|
|
|
|
label="Location"
|
|
|
|
options={locationFilterOptions}
|
|
|
|
options={locationFilterOptions}
|
|
|
|