From bae3e98ba7671e970038a1ae944a071d3f67f24c Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 28 Nov 2023 13:15:20 -0700 Subject: [PATCH 01/10] add new filters --- .../citizenshipFilterFormControlLabels.tsx | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Assets/citizenshipFilterFormControlLabels.tsx b/src/Assets/citizenshipFilterFormControlLabels.tsx index 429cf3dec..60f7cf7ce 100644 --- a/src/Assets/citizenshipFilterFormControlLabels.tsx +++ b/src/Assets/citizenshipFilterFormControlLabels.tsx @@ -1,4 +1,5 @@ import { FormattedMessage } from 'react-intl'; +import { FormattedMessageType } from '../Types/Questions'; export type CitizenLabels = | 'non_citizen' @@ -7,9 +8,12 @@ export type CitizenLabels = | 'gc_5plus' | 'gc_18plus_no5' | 'gc_under18_no5' - | 'gc_under19_pregnant_no5'; + | 'other' + | 'otherWithWorkPermission' + | 'otherHealthCareUnder19' + | 'otherHealthCarePregnant'; -const citizenshipFilterFormControlLabels = { +const citizenshipFilterFormControlLabels: Record = { non_citizen: ( ), - gc_under19_pregnant_no5: ( - - ), refugee: ( ), + other: , + otherWithWorkPermission: ( + + ), + otherHealthCareUnder19: ( + + ), + otherHealthCarePregnant: ( + + ), }; export default citizenshipFilterFormControlLabels; From c01a57ff2481597a118c42537b122096ed85931e Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 28 Nov 2023 13:22:35 -0700 Subject: [PATCH 02/10] add citizen filter map --- src/Assets/citizenshipFilterFormControlLabels.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Assets/citizenshipFilterFormControlLabels.tsx b/src/Assets/citizenshipFilterFormControlLabels.tsx index 60f7cf7ce..dd69d0852 100644 --- a/src/Assets/citizenshipFilterFormControlLabels.tsx +++ b/src/Assets/citizenshipFilterFormControlLabels.tsx @@ -62,3 +62,10 @@ const citizenshipFilterFormControlLabels: Record([ + ['non_citizen', []], + ['green_card', ['gc_5plus', 'gc_18plus_no5', 'gc_under18_no5']], + ['refugee', []], + ['other', ['otherWithWorkPermission', 'otherHealthCareUnder19', 'otherHealthCarePregnant']], +]); From 4bbc58107f548456a81aee7eaff6823d6465d7aa Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 28 Nov 2023 14:07:52 -0700 Subject: [PATCH 03/10] loop over filter map to make filter tabel --- .../citizenshipFilterFormControlLabels.tsx | 6 +- .../FilterSection/CitizenshipPopover.tsx | 83 ++++++------------- src/Components/Results/Results.tsx | 5 +- 3 files changed, 34 insertions(+), 60 deletions(-) diff --git a/src/Assets/citizenshipFilterFormControlLabels.tsx b/src/Assets/citizenshipFilterFormControlLabels.tsx index dd69d0852..de18fcfa9 100644 --- a/src/Assets/citizenshipFilterFormControlLabels.tsx +++ b/src/Assets/citizenshipFilterFormControlLabels.tsx @@ -44,19 +44,19 @@ const citizenshipFilterFormControlLabels: Record ), otherHealthCareUnder19: ( ), otherHealthCarePregnant: ( ), }; diff --git a/src/Components/FilterSection/CitizenshipPopover.tsx b/src/Components/FilterSection/CitizenshipPopover.tsx index a66e09268..a2e3fc907 100644 --- a/src/Components/FilterSection/CitizenshipPopover.tsx +++ b/src/Components/FilterSection/CitizenshipPopover.tsx @@ -5,7 +5,7 @@ import IconButton from '@mui/material/IconButton'; import { Checkbox, Stack } from '@mui/material'; import { GridFilterItem, GridFilterOperator } from '@mui/x-data-grid'; import { UpdateFilterArg } from '../Results/Results'; -import citizenshipFilterFormControlLabels from '../../Assets/citizenshipFilterFormControlLabels'; +import citizenshipFilterFormControlLabels, { filterNestedMap } from '../../Assets/citizenshipFilterFormControlLabels'; import type { CitizenLabels } from '../../Assets/citizenshipFilterFormControlLabels'; import './CitizenshipPopover.css'; @@ -56,22 +56,16 @@ const CitizenshipPopover = ({ const handleFilterSelect = (citizenshipType: CitizenLabels) => { const isChecked = citizenshipFilterIsChecked[citizenshipType]; - let updatedCitizenshipFilterIsChecked: Record = { + const updatedCitizenshipFilterIsChecked: Record = { ...citizenshipFilterIsChecked, [citizenshipType]: !isChecked, }; - if (citizenshipType === 'green_card') { - // if the citizenshipType is `green_card`, then set green_card and all the gc_options to true or false - // i.e. green_card and all the gc_options should be the same when citizenshipType is `green_card` - updatedCitizenshipFilterIsChecked = { - ...updatedCitizenshipFilterIsChecked, - gc_5plus: !isChecked, - gc_18plus_no5: !isChecked, - gc_under18_no5: !isChecked, - gc_under19_pregnant_no5: !isChecked, - }; + for (const nestedFilter of filterNestedMap.get(citizenshipType) ?? []) { + // if a parent is not checked, then set its children to false, and if a parent becomes checked, then set its children to true + updatedCitizenshipFilterIsChecked[nestedFilter] = !isChecked; } + const typedUpdatedCitizenshipFilterIsChecked = Object.keys(updatedCitizenshipFilterIsChecked) as CitizenLabels[]; const selectedCitizenshipFilters = typedUpdatedCitizenshipFilterIsChecked.filter((citizenshipType) => { return updatedCitizenshipFilterIsChecked[citizenshipType]; @@ -105,56 +99,33 @@ const CitizenshipPopover = ({ setCitizenshipFilterIsChecked(updatedCitizenshipFilterIsChecked); }; - const typedCitizenshipFilterIsChecked = Object.keys(citizenshipFilterIsChecked) as CitizenLabels[]; - - const renderMainAndSubFilters = (citizenshipFilters: Record) => { - return typedCitizenshipFilterIsChecked.map((citizenshipType) => { - //here we need to add an sx prop to indent them if they're the gc_filters - const isGreenCardSubCitizenshipType = [ - 'gc_5plus', - 'gc_18plus_no5', - 'gc_under18_no5', - 'gc_under19_pregnant_no5', - ].includes(citizenshipType); - - return ( - handleFilterSelect(citizenshipType)} - /> - } - /> - ); - }); - }; - - const renderMainFilters = (citizenshipFilters: Record) => { - //green_card is false - const initialThreeFilters: CitizenLabels[] = ['non_citizen', 'green_card', 'refugee']; - return initialThreeFilters.map((initialFilter) => { - return ( + const renderCitizenshipFilters = (citizenshipFilters: Record) => { + const filters: JSX.Element[] = []; + filterNestedMap.forEach((children, parentLabel) => { + filters.push( handleFilterSelect(initialFilter)} /> + handleFilterSelect(parentLabel)} /> } - /> + />, ); + if (citizenshipFilters[parentLabel]) { + children.forEach((label) => { + filters.push( + handleFilterSelect(label)} />} + />, + ); + }); + } }); - }; - const renderCitizenshipFilters = (citizenshipFilters: Record) => { - if (citizenshipFilters.green_card) { - return renderMainAndSubFilters(citizenshipFilters); - } else { - return renderMainFilters(citizenshipFilters); - } + return filters; }; return ( diff --git a/src/Components/Results/Results.tsx b/src/Components/Results/Results.tsx index 7aa7ead35..7800e590a 100644 --- a/src/Components/Results/Results.tsx +++ b/src/Components/Results/Results.tsx @@ -81,8 +81,11 @@ const Results = ({ handleTextFieldChange }: ResultsProps) => { gc_5plus: false, gc_18plus_no5: false, gc_under18_no5: false, - gc_under19_pregnant_no5: false, refugee: false, + other: false, + otherWithWorkPermission: false, + otherHealthCareUnder19: false, + otherHealthCarePregnant: false, }); const categoryState = useState('All Categories'); const eligibilityState = useState('eligibleBenefits'); From 1543c519a343f8f45677450d981480fc7d2f7fdc Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 28 Nov 2023 14:30:32 -0700 Subject: [PATCH 04/10] fix formatting --- src/Components/FilterSection/CitizenshipPopover.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Components/FilterSection/CitizenshipPopover.tsx b/src/Components/FilterSection/CitizenshipPopover.tsx index a2e3fc907..6bf1d8aff 100644 --- a/src/Components/FilterSection/CitizenshipPopover.tsx +++ b/src/Components/FilterSection/CitizenshipPopover.tsx @@ -111,6 +111,7 @@ const CitizenshipPopover = ({ } />, ); + if (citizenshipFilters[parentLabel]) { children.forEach((label) => { filters.push( From b7f7b0bd273538286553f71a20cb53cf3fd05c17 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 28 Nov 2023 14:40:36 -0700 Subject: [PATCH 05/10] increase filter spacing on mobile --- src/Components/FilterSection/CitizenshipPopover.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Components/FilterSection/CitizenshipPopover.css b/src/Components/FilterSection/CitizenshipPopover.css index abc06d425..bb706f52b 100644 --- a/src/Components/FilterSection/CitizenshipPopover.css +++ b/src/Components/FilterSection/CitizenshipPopover.css @@ -1,3 +1,7 @@ .MuiFormControlLabel-root.gc-subcitizen-indentation { margin-left: 1.25rem; } + +.MuiFormControlLabel-label { + padding: 0.5rem 0; +} From fe9da2ebb3e59ffcaa10ad5582d1cbc6aab7140f Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 29 Nov 2023 15:25:29 -0700 Subject: [PATCH 06/10] fix language select in 211 header --- .../TwoOneOneHeader/TwoOneOneHeader.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js b/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js index 2f68268e2..19cb626fa 100644 --- a/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js +++ b/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js @@ -69,17 +69,8 @@ const TwoOneOneHeader = ({ handleTextfieldChange }) => { }; const setRenderValue = () => { - const currentLocale = locale; - switch (currentLocale) { - case 'en-US': - return 'EN'; - case 'es': - return 'ES'; - case 'vi': - return 'VI'; - default: - return 'EN'; - } + const currentLocale = context.locale; + return currentLocale.slice(0, 2).toLocaleUpperCase(); }; const create211Links = () => { From f7665c79db312e892ca1bde22456a6951844d2f4 Mon Sep 17 00:00:00 2001 From: Caleb Date: Wed, 29 Nov 2023 15:27:20 -0700 Subject: [PATCH 07/10] fix 211 language select --- .../TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js b/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js index 19cb626fa..fb4244bca 100644 --- a/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js +++ b/src/Components/TwoOneOneComponents/TwoOneOneHeader/TwoOneOneHeader.js @@ -69,7 +69,7 @@ const TwoOneOneHeader = ({ handleTextfieldChange }) => { }; const setRenderValue = () => { - const currentLocale = context.locale; + const currentLocale = locale; return currentLocale.slice(0, 2).toLocaleUpperCase(); }; From 44bd8a47f5e1c7d669cd03e68c2877583e61b6b5 Mon Sep 17 00:00:00 2001 From: Caleb Date: Thu, 30 Nov 2023 14:06:41 -0700 Subject: [PATCH 08/10] default to sending 0 if assets are blank --- src/Assets/updateScreen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Assets/updateScreen.ts b/src/Assets/updateScreen.ts index 91b97b2f6..b7da2776d 100644 --- a/src/Assets/updateScreen.ts +++ b/src/Assets/updateScreen.ts @@ -26,7 +26,7 @@ const getScreensBody = (formData: FormData, languageCode: Language) => { household_size: formData.householdSize === '' ? null : Number(formData.householdSize), household_members: householdMembers, expenses: expenses, - household_assets: formData.householdAssets, + household_assets: formData.householdAssets ?? 0, request_language_code: languageCode, has_benefits: formData.hasBenefits ?? 'preferNotToAnswer', has_acp: formData.benefits.acp, From f11a089a47b7fd597bfb95d7181b294822da77cb Mon Sep 17 00:00:00 2001 From: Caleb Date: Thu, 30 Nov 2023 15:09:37 -0700 Subject: [PATCH 09/10] make sure that household assets is a number --- src/Assets/updateScreen.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Assets/updateScreen.ts b/src/Assets/updateScreen.ts index b7da2776d..6b3a7ec85 100644 --- a/src/Assets/updateScreen.ts +++ b/src/Assets/updateScreen.ts @@ -15,6 +15,7 @@ const getScreensBody = (formData: FormData, languageCode: Language) => { const expenses = getExpensesBodies(formData); const finalReferralSource = formData.otherSource !== '' ? formData.otherSource : formData.referralSource; + const screenBody: ApiFormData = { is_test: formData.isTest ?? false, external_id: formData.externalID ?? null, @@ -26,7 +27,7 @@ const getScreensBody = (formData: FormData, languageCode: Language) => { household_size: formData.householdSize === '' ? null : Number(formData.householdSize), household_members: householdMembers, expenses: expenses, - household_assets: formData.householdAssets ?? 0, + household_assets: formData.householdAssets || 0, request_language_code: languageCode, has_benefits: formData.hasBenefits ?? 'preferNotToAnswer', has_acp: formData.benefits.acp, From aa6a1f1c4860a3daca3b4b795f95db8d7171b20d Mon Sep 17 00:00:00 2001 From: Caleb Date: Fri, 1 Dec 2023 10:12:46 -0700 Subject: [PATCH 10/10] move filterNestedMap higher in the file --- src/Assets/citizenshipFilterFormControlLabels.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Assets/citizenshipFilterFormControlLabels.tsx b/src/Assets/citizenshipFilterFormControlLabels.tsx index de18fcfa9..56f0ab4c1 100644 --- a/src/Assets/citizenshipFilterFormControlLabels.tsx +++ b/src/Assets/citizenshipFilterFormControlLabels.tsx @@ -13,6 +13,13 @@ export type CitizenLabels = | 'otherHealthCareUnder19' | 'otherHealthCarePregnant'; +export const filterNestedMap = new Map([ + ['non_citizen', []], + ['green_card', ['gc_5plus', 'gc_18plus_no5', 'gc_under18_no5']], + ['refugee', []], + ['other', ['otherWithWorkPermission', 'otherHealthCareUnder19', 'otherHealthCarePregnant']], +]); + const citizenshipFilterFormControlLabels: Record = { non_citizen: ( ([ - ['non_citizen', []], - ['green_card', ['gc_5plus', 'gc_18plus_no5', 'gc_under18_no5']], - ['refugee', []], - ['other', ['otherWithWorkPermission', 'otherHealthCareUnder19', 'otherHealthCarePregnant']], -]);