Skip to content

Commit

Permalink
PXBF-1786-fix-bf-change-event: async data handling in modal
Browse files Browse the repository at this point in the history
  • Loading branch information
scottqueen-bixal committed Sep 12, 2024
1 parent 5b42529 commit c6acc5a
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 @@ -115,27 +115,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 c6acc5a

Please sign in to comment.