From 2c7ccd1396ec87be92695fafedb3faf8a3332d55 Mon Sep 17 00:00:00 2001 From: Ali Akbar <52413434+Ali-D-Akbar@users.noreply.github.com> Date: Wed, 17 Apr 2024 17:59:13 +0500 Subject: [PATCH] fix: reading undefined additional metadata (#958) --- src/data/actions/courseInfo.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/data/actions/courseInfo.js b/src/data/actions/courseInfo.js index fefa72db9..b4c1a47f8 100644 --- a/src/data/actions/courseInfo.js +++ b/src/data/actions/courseInfo.js @@ -117,16 +117,18 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) { per_lead_usa: perLeadUSA, per_lead_international: perLeadInternational, per_click_usa: perClickUSA, - per_click_international: perClicknternational, - }, - additional_metadata: { - certificate_info: { - heading, - blurb, - }, + per_click_international: perClickInternational, }, + additional_metadata: additionalMetadata, } = initialValues; + const { + certificate_info: { + heading, + blurb, + } = {}, + } = additionalMetadata || {}; + // This emits a redux action called CHANGE that will update: change('imageSrc', initialImageSrc); change('geoLocationLat', geoLocationLat); @@ -137,7 +139,7 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) { change('in_year_value.per_lead_usa', perLeadUSA); change('in_year_value.per_lead_international', perLeadInternational); change('in_year_value.per_click_usa', perClickUSA); - change('in_year_value.per_click_international', perClicknternational); + change('in_year_value.per_click_international', perClickInternational); change('additional_metadata.certificate_info.heading', heading); change('additional_metadata.certificate_info.blurb', blurb); for (let i = 0; i < initialCourseRuns.length; i += 1) {