From 4e42516caf74e340d00a20c93759cf3a1fa577ce Mon Sep 17 00:00:00 2001 From: Emily Jablonski <65367387+emilyjablonski@users.noreply.github.com> Date: Wed, 29 May 2024 15:46:01 -0600 Subject: [PATCH] fix: saving household member (#4108) --- api/prisma/seed-helpers/listing-factory.ts | 32 +- api/prisma/seed-staging.ts | 131 +++++++- .../sections/DetailsHouseholdMembers.tsx | 10 +- .../sections/FormHouseholdMembers.tsx | 26 +- sites/public/cypress.config.ts | 2 +- .../e2e/pages/submit-application.spec.ts | 4 +- .../cypress/mockData/applicationData.ts | 137 +++++---- sites/public/cypress/support/commands.js | 282 +++++++++++++++--- sites/public/cypress/support/index.d.ts | 7 +- .../applications/ValidateAddress.tsx | 1 + .../components/shared/FormSummaryDetails.tsx | 63 ++-- .../pages/applications/contact/address.tsx | 25 +- .../pages/applications/household/member.tsx | 48 +-- .../household/preferred-units.tsx | 1 + 14 files changed, 570 insertions(+), 199 deletions(-) diff --git a/api/prisma/seed-helpers/listing-factory.ts b/api/prisma/seed-helpers/listing-factory.ts index 232e5e05fc..57a83b522c 100644 --- a/api/prisma/seed-helpers/listing-factory.ts +++ b/api/prisma/seed-helpers/listing-factory.ts @@ -95,16 +95,30 @@ export const listingFactory = async ( : new Date(), listingMultiselectQuestions: optionalParams?.multiselectQuestions ? { - create: optionalParams.multiselectQuestions.map( - (question, index) => ({ - multiselectQuestions: { - connect: { - id: question.id, + create: [ + ...optionalParams?.multiselectQuestions + ?.filter( + (question) => question.applicationSection === 'preferences', + ) + .map((question, index) => ({ + multiselectQuestions: { + connect: { + id: question.id, + }, }, - }, - ordinal: index + 1, - }), - ), + ordinal: index + 1, + })), + ...optionalParams?.multiselectQuestions + ?.filter((question) => question.applicationSection === 'programs') + .map((question, index) => ({ + multiselectQuestions: { + connect: { + id: question.id, + }, + }, + ordinal: index + 1, + })), + ], } : undefined, applications: optionalParams?.applications diff --git a/api/prisma/seed-staging.ts b/api/prisma/seed-staging.ts index b5156b9708..848e1e4735 100644 --- a/api/prisma/seed-staging.ts +++ b/api/prisma/seed-staging.ts @@ -161,6 +161,21 @@ export const stagingSeed = async ( }, }), }); + const multiselectQuestion3 = await prismaClient.multiselectQuestions.create({ + data: multiselectQuestionFactory(jurisdiction.id, { + multiselectQuestion: { + text: 'Veteran', + description: + 'Have you or anyone in your household served in the US military?', + applicationSection: MultiselectQuestionsApplicationSectionEnum.programs, + optOutText: 'Prefer not to say', + options: [ + { text: 'Yes', exclusive: true, ordinal: 1 }, + { text: 'No', exclusive: true, ordinal: 2 }, + ], + }, + }), + }); const multiselectQuestionPrograms = await prismaClient.multiselectQuestions.create({ data: multiselectQuestionFactory(jurisdiction.id, { @@ -875,7 +890,121 @@ export const stagingSeed = async ( ], }, }, - multiselectQuestions: [multiselectQuestion2, multiselectQuestion1], + multiselectQuestions: [ + multiselectQuestion2, + multiselectQuestion1, + multiselectQuestion3, + ], + units: [ + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[0].id, + }, + }, + }, + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[1].id, + }, + }, + }, + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[2].id, + }, + }, + }, + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[3].id, + }, + }, + }, + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[4].id, + }, + }, + }, + { + amiPercentage: '30', + monthlyIncomeMin: '2000', + floor: 1, + maxOccupancy: 3, + minOccupancy: 1, + monthlyRent: '1200', + numBathrooms: 1, + numBedrooms: 1, + number: '101', + sqFeet: '750.00', + amiChart: { connect: { id: amiChart.id } }, + unitTypes: { + connect: { + id: unitTypes[5].id, + }, + }, + }, + ], }, ].map( async ( diff --git a/sites/partners/src/components/applications/PaperApplicationDetails/sections/DetailsHouseholdMembers.tsx b/sites/partners/src/components/applications/PaperApplicationDetails/sections/DetailsHouseholdMembers.tsx index 25d8038974..01f3b4b296 100644 --- a/sites/partners/src/components/applications/PaperApplicationDetails/sections/DetailsHouseholdMembers.tsx +++ b/sites/partners/src/components/applications/PaperApplicationDetails/sections/DetailsHouseholdMembers.tsx @@ -14,11 +14,11 @@ const DetailsHouseholdMembers = ({ setMembersDrawer }: DetailsHouseholdMembersPr const application = useContext(ApplicationContext) const householdMembersHeaders = { - name: t("t.name"), - relationship: t("t.relationship"), - birth: t("application.household.member.dateOfBirth"), - sameResidence: t("application.add.sameResidence"), - workInRegion: t("application.details.workInRegion"), + name: "t.name", + relationship: "t.relationship", + birth: "application.household.member.dateOfBirth", + sameResidence: "application.add.sameResidence", + workInRegion: "application.details.workInRegion", action: "", } diff --git a/sites/partners/src/components/applications/PaperApplicationForm/sections/FormHouseholdMembers.tsx b/sites/partners/src/components/applications/PaperApplicationForm/sections/FormHouseholdMembers.tsx index 38c00847d5..10535e5ddb 100644 --- a/sites/partners/src/components/applications/PaperApplicationForm/sections/FormHouseholdMembers.tsx +++ b/sites/partners/src/components/applications/PaperApplicationForm/sections/FormHouseholdMembers.tsx @@ -18,21 +18,23 @@ const FormHouseholdMembers = ({ householdMembers, setHouseholdMembers, }: FormHouseholdMembersProps) => { - const [membersDrawer, setMembersDrawer] = useState(null) + type MembersDrawer = HouseholdMember | null + + const [membersDrawer, setMembersDrawer] = useState(null) const [membersDeleteModal, setMembersDeleteModal] = useState(null) const memberTableHeaders = { - name: t("t.name"), - relationship: t("t.relationship"), - dob: t("application.household.member.dateOfBirth"), - sameResidence: t("application.add.sameResidence"), - workInRegion: t("application.details.workInRegion"), + name: "t.name", + relationship: "t.relationship", + dob: "application.household.member.dateOfBirth", + sameResidence: "application.add.sameResidence", + workInRegion: "application.details.workInRegion", action: "", } const editMember = useCallback( - (orderId: number) => { - setMembersDrawer(orderId) + (member: HouseholdMember) => { + setMembersDrawer(member) }, [setMembersDrawer] ) @@ -108,7 +110,7 @@ const FormHouseholdMembers = ({