Skip to content

Commit

Permalink
Merge pull request #1801 from GSA/1786-fix-bf-change-event
Browse files Browse the repository at this point in the history
PXBF-1786-fix-bf-change-event: async data handling in modal
  • Loading branch information
scottqueen-bixal authored Sep 13, 2024
2 parents 1d7bc1d + c6acc5a commit 779ece4
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions benefit-finder/src/shared/components/Modal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,33 @@ const Modal = ({

// handle dataLayer
useEffect(() => {
modalOpen === true &&
dataLayerUtils.dataLayerPush(window, {
event: modal.event,
bfData: {
pageView: modal.bfData.pageView,
viewTitle: `${dataLayerValue.viewTitle} modal`,
},
})
// handle dataLayer
modalOpen === true &&
dataLayerUtils.dataLayerPush(window, {
event: errors.event,
bfData: {
errors: '',
errorCount: {
number: 0,
string: `0`,
const handleModalData = async () => {
modalOpen === true &&
dataLayerUtils.dataLayerPush(window, {
event: modal.event,
bfData: {
pageView: modal.bfData.pageView,
viewTitle: `${dataLayerValue.viewTitle} modal`,
},
formSuccess: true,
},
})
})
}

// async so we can handle duplicates if needed
handleModalData().then(() => {
// handle dataLayer
modalOpen === true &&
dataLayerUtils.dataLayerPush(window, {
event: errors.event,
bfData: {
errors: '',
errorCount: {
number: 0,
string: `0`,
},
formSuccess: true,
},
})
})
}, [])

/**
Expand Down

0 comments on commit 779ece4

Please sign in to comment.