Skip to content

Commit

Permalink
fix: saving household member (#4108)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyjablonski authored May 29, 2024
1 parent 71c8a16 commit 4e42516
Show file tree
Hide file tree
Showing 14 changed files with 570 additions and 199 deletions.
32 changes: 23 additions & 9 deletions api/prisma/seed-helpers/listing-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
131 changes: 130 additions & 1 deletion api/prisma/seed-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ const FormHouseholdMembers = ({
householdMembers,
setHouseholdMembers,
}: FormHouseholdMembersProps) => {
const [membersDrawer, setMembersDrawer] = useState<number | null>(null)
type MembersDrawer = HouseholdMember | null

const [membersDrawer, setMembersDrawer] = useState<MembersDrawer>(null)
const [membersDeleteModal, setMembersDeleteModal] = useState<number | null>(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]
)
Expand Down Expand Up @@ -108,7 +110,7 @@ const FormHouseholdMembers = ({
<Button
type="button"
className="font-semibold"
onClick={() => editMember(member.orderId)}
onClick={() => editMember(member)}
variant="text"
>
{t("t.edit")}
Expand Down Expand Up @@ -142,7 +144,9 @@ const FormHouseholdMembers = ({
type="button"
variant="primary-outlined"
size="sm"
onClick={() => setMembersDrawer(householdMembers.length + 1)}
onClick={() =>
setMembersDrawer({ orderId: householdMembers.length + 1 } as HouseholdMember)
}
id={"addHouseholdMemberButton"}
>
{t("application.add.addHouseholdMember")}
Expand All @@ -159,7 +163,7 @@ const FormHouseholdMembers = ({
onSubmit={(member) => saveMember(member)}
onClose={() => setMembersDrawer(null)}
members={householdMembers}
editedMemberId={membersDrawer}
editedMemberId={membersDrawer?.orderId}
/>
</Drawer>

Expand Down
2 changes: 1 addition & 1 deletion sites/public/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
video: true,
videoUploadOnPasses: false,
numTestsKeptInMemory: 0,

viewportHeight: 1500,
env: {
codeCoverage: {
url: "/api/__coverage__",
Expand Down
4 changes: 2 additions & 2 deletions sites/public/cypress/e2e/pages/submit-application.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { ElmVillageApplication, minimalDataApplication } from "../../mockData/ap

describe("Submit", function () {
it("should submit an application for the Elm Village listing", function () {
cy.submitApplication("Elm Village", ElmVillageApplication, false)
cy.submitApplication("Elm Village", ElmVillageApplication, false, true)
})
it("should submit a minimal application for the Test: Default, No Preferences", function () {
cy.submitApplication("Blue Sky Apartments", minimalDataApplication, false)
cy.submitApplication("Blue Sky Apartments", minimalDataApplication, false, false)
})
})
Loading

0 comments on commit 4e42516

Please sign in to comment.