From 13cbfe50d9e911e63e76d19cd6c892b996b68566 Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Tue, 25 Jul 2023 19:19:26 +0500 Subject: [PATCH] fix: make courses with type empty editable in publisher --- src/utils/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index ff0fe2683..2a6c705cc 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -301,7 +301,14 @@ const formatPriceData = (formData, courseOptions) => { return priceData; } const parsedTypeOptions = parseCourseTypeOptions(courseOptionsData.type.type_options); - const priceLabels = parsedTypeOptions.priceLabels[formData.type]; + + /* + Since parsedTypeOptions.priceLabels do not contain information corresponding + to the empty CourseType, parsedTypeOptions.priceLabels[formData.type] evaluates + to undefined if formData.type is the empty CourseType. Add `|| {}` at the end to + ensure that a valid object is returned in that case + */ + const priceLabels = parsedTypeOptions.priceLabels[formData.type] || {}; // formData is going to potentially have more seat types than we need, so we pare down here Object.keys(priceLabels).forEach((seatType) => {