Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-publisher into bilalqamar95/frontend-platform-upgrade
  • Loading branch information
BilalQamar95 committed Apr 24, 2024
2 parents 6625a14 + d784b41 commit b74a091
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"jsx-to-string": "1.4.0",
"moment": "2.30.1",
"moment-timezone": "0.5.45",
"postcss": "8.4.37",
"postcss": "8.4.38",
"prop-types": "15.8.1",
"query-string": "7.1.3",
"react": "^17.0.2",
Expand Down
15 changes: 13 additions & 2 deletions src/data/actions/courseInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
4. url_slug: Auto-generated on backend if not provided
5. tags: To maintain ordering returned by the backend
6. in_year_value: each dict key has default backend value which is not read by form unless changed.
7. additional_metadata.certificate_info: exec-ed courses needs it and is not read by form unless changed.
*/
return (dispatch) => {
const {
Expand All @@ -116,10 +117,18 @@ function updateFormValuesAfterSave(change, currentFormValues, initialValues) {
per_lead_usa: perLeadUSA,
per_lead_international: perLeadInternational,
per_click_usa: perClickUSA,
per_click_international: perClicknternational,
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);
Expand All @@ -130,7 +139,9 @@ 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) {
change(`course_runs[${i}].status`, initialCourseRuns[i].status);
change(`course_runs[${i}].transcript_languages`, initialCourseRuns[i].transcript_languages);
Expand Down
12 changes: 10 additions & 2 deletions src/data/actions/courseInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ describe('courseInfo edit course actions', () => {
per_click_usa: 25,
per_click_international: 30,
},
additional_metadata: {
certificate_info: {
heading: 'Test Certificate',
blurb: 'test blurb',
},
},
imageSrc: 'http://updated.image.src/woo.small',
course_runs: [
{
Expand All @@ -224,8 +230,10 @@ describe('courseInfo edit course actions', () => {
expect(changeMock).toHaveBeenNthCalledWith(8, 'in_year_value.per_lead_international', 20);
expect(changeMock).toHaveBeenNthCalledWith(9, 'in_year_value.per_click_usa', 25);
expect(changeMock).toHaveBeenNthCalledWith(10, 'in_year_value.per_click_international', 30);
expect(changeMock).toHaveBeenNthCalledWith(11, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(12, 'course_runs[0].transcript_languages', ['en-us']);
expect(changeMock).toHaveBeenNthCalledWith(11, 'additional_metadata.certificate_info.heading', 'Test Certificate');
expect(changeMock).toHaveBeenNthCalledWith(12, 'additional_metadata.certificate_info.blurb', 'test blurb');
expect(changeMock).toHaveBeenNthCalledWith(13, 'course_runs[0].status', 'published');
expect(changeMock).toHaveBeenNthCalledWith(14, 'course_runs[0].transcript_languages', ['en-us']);
});
});

Expand Down

0 comments on commit b74a091

Please sign in to comment.