Skip to content

Commit

Permalink
feat(myinfo-children): enable myinfo child on storage admin create pa…
Browse files Browse the repository at this point in the history
…ge (#7988)

* enable myinfo child on storage admin create page

* fix: remove childname in _id

* chore: remove unused imports
  • Loading branch information
KenLSM authored Dec 16, 2024
1 parent 0177ab4 commit 2184850
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,7 @@ export const MyInfoFieldPanel = ({ searchValue }: { searchValue: string }) => {
</Box>
)}
</Droppable>
{user?.betaFlags?.children &&
form?.responseMode === FormResponseMode.Email ? (
{user?.betaFlags?.children ? (
<Droppable isDropDisabled droppableId={CREATE_MYINFO_CHILDREN_DROP_ID}>
{(provided) => (
<Box ref={provided.innerRef} {...provided.droppableProps}>
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/myinfo/myinfo.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ export const handleMyInfoChildHashResponse = (
// Validate each answer (child)
childAnswer.forEach((attrAnswer, subFieldIndex) => {
const key = getMyInfoChildHashKey(
field._id as string,
field._id,
subFields[subFieldIndex],
childIndex,
childName,
Expand Down
12 changes: 3 additions & 9 deletions src/app/modules/submission/submission.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ import {
MyInfoMissingLoginCookieError,
} from '../myinfo/myinfo.errors'
import { MyInfoKey } from '../myinfo/myinfo.types'
import { getMyInfoChildHashKey } from '../myinfo/myinfo.util'
import {
InvalidPaymentProductsError,
PaymentNotFoundError,
Expand Down Expand Up @@ -752,17 +751,12 @@ export const getAnswersForChild = (
return []
}
return response.answerArray.flatMap((arr, childIdx) => {
// First array element is always child name
const childName = arr[0]
return arr.map((answer, idx) => {
const subfield = subFields[idx]
return {
_id: getMyInfoChildHashKey(
response._id,
subFields[idx],
childIdx,
childName,
),
// Recreates the individual _id of the child field based on the parent field's _id and the subfield
// e.g., childrenbirthrecords.67585515e1ced6d790a91e14.childname.0
_id: `${MyInfoAttribute.ChildrenBirthRecords}.${response._id}.${subFields[idx]}.${childIdx}`,
fieldType: response.fieldType,
// qnChildIdx represents the index of the MyInfo field
// childIdx represents the index of the child in this MyInfo field
Expand Down

0 comments on commit 2184850

Please sign in to comment.