Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor formatting of data before sending to the backend #864

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zawan-ila
Copy link
Contributor

PROD-3202

Description

In this PR, we make some changes to the formatting of data before sending it to the backend. This is done so as to ensure that the backend receives data in the format that it is expecting. This is required to enable the backend to decide whether the incoming data is different than the one present in the database or are there any real changes?

Comment on lines 316 to +327
return {
restriction_type: null,
countries: null,
states: null,
restriction_type: courseData.location_restriction?.restriction_type || null,
countries: courseData.location_restriction?.countries || [],
states: courseData.location_restriction?.states || [],
};
}

formatGeoLocationFields(courseData) {
if (courseData?.geolocation) {
return {
geoLocationName: courseData.geolocation.location_name,
geoLocationLng: courseData.geolocation.lng,
geoLocationLat: courseData.geolocation.lat,
};
}
return {
geoLocationName: null,
geoLocationLng: null,
geoLocationLat: null,
geoLocationName: courseData.geolocation?.location_name || '',
geoLocationLng: courseData.geolocation?.lng || null,
geoLocationLat: courseData.geolocation?.lat || null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is backend data rendering on publisher. Are you sure it is working as expected, like adding [] for fields?

Comment on lines +263 to +275
if (fact_1.heading && fact_2.heading) {
return [
fact_1, fact_2,
];
}
if (fact_1.heading) {
return [fact_1];
}
if (fact_2.heading) {
return [fact_2];
}
return [];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either both facts should be there or none. Only one fact is not allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants