diff --git a/apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx b/apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx index d40d6678..60dd3ffa 100644 --- a/apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx +++ b/apps/portal/src/components/questions/typeahead/RoleTypeahead.tsx @@ -1,13 +1,21 @@ -import { ROLES } from '~/utils/questions/constants'; +import { JobTitleLabels } from '~/components/shared/JobTitles'; import type { ExpandedTypeaheadProps } from './ExpandedTypeahead'; import ExpandedTypeahead from './ExpandedTypeahead'; +import type { FilterChoices } from '../filter/FilterSection'; export type RoleTypeaheadProps = Omit< ExpandedTypeaheadProps, 'label' | 'onQueryChange' | 'options' >; +const ROLES: FilterChoices = Object.entries(JobTitleLabels).map( + ([slug, label]) => ({ + id: slug, + label, + value: slug, + }), +); export default function RoleTypeahead(props: RoleTypeaheadProps) { return ( { + if (!aggregatedEncounters) { + return aggregatedEncounters; + } + + return relabelQuestionAggregates(aggregatedEncounters); + }, [aggregatedEncounters]); + const utils = trpc.useContext(); const { data: comments } = trpc.useQuery([ @@ -138,11 +148,11 @@ export default function QuestionPage() {
({ checked: true, id: role, - label: role, + label: JobTitleLabels[role as keyof typeof JobTitleLabels], value: role, })); }, [selectedRoles]); @@ -369,7 +371,7 @@ export default function QuestionsBrowsePage() { setSelectedRoles([...selectedRoles, option.value]); } else { setSelectedRoles( - selectedCompanies.filter((role) => role !== option.value), + selectedRoles.filter((role) => role !== option.value), ); } }} @@ -470,36 +472,37 @@ export default function QuestionsBrowsePage() {
{(questionsQueryData?.pages ?? []).flatMap( ({ data: questions }) => - questions.map((question) => ( - - )), + questions.map((question) => { + const { companyCounts, locationCounts, roleCounts } = + relabelQuestionAggregates( + question.aggregatedQuestionEncounters, + ); + + return ( + + ); + }), )}