Skip to content

Commit

Permalink
fix: make courses with type empty editable in publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
zawan-ila committed Jul 26, 2023
1 parent 8ab3e35 commit 13cbfe5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 13cbfe5

Please sign in to comment.