Skip to content

Commit

Permalink
fix: household member delete + order (bloom-housing#4510)
Browse files Browse the repository at this point in the history
* fix: household member delete + order

* fix: clean up

* fix: consistent naming

* fix: handle null order id
  • Loading branch information
ColinBuyck committed Jan 2, 2025
1 parent ff90bb3 commit 9fde03f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ const DetailsHouseholdMembers = ({ setMembersDrawer }: DetailsHouseholdMembersPr

return t("t.n/a")
}
return application?.householdMember?.map((item) => ({
const orderedHouseholdMembers = application?.householdMember?.sort(
(a, b) => a.orderId - b.orderId
)
return orderedHouseholdMembers?.map((item) => ({
name: { content: `${item.firstName} ${item.middleName} ${item.lastName}` },
relationship: {
content: item.relationship
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ const ApplicationForm = ({ listingId, editMode, application }: ApplicationFormPr

useEffect(() => {
if (application?.householdMember) {
setHouseholdMembers(application.householdMember)
const householdMemberNum = application.householdMember.length
const orderedHouseholdMembers = application.householdMember
//reset order ids to show members in order user added them
.map((member, idx) => {
return { ...member, orderId: householdMemberNum - idx }
})
.sort((a, b) => a.orderId - b.orderId)
setHouseholdMembers(orderedHouseholdMembers)
}
}, [application, setHouseholdMembers])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const FormHouseholdMembers = ({
</Drawer>

<Dialog
isOpen={!!membersDeleteModal}
isOpen={membersDeleteModal !== null}
ariaLabelledBy="form-household-members-dialog-header"
ariaDescribedBy="form-household-members-dialog-content"
onClose={() => setMembersDeleteModal(null)}
Expand Down

0 comments on commit 9fde03f

Please sign in to comment.