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

Jipm/fix setting snake case #1

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/advanced-settings/data/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { camelCaseObject, getConfig } from '@edx/frontend-platform';
/* eslint-disable import/prefer-default-export */
import { camelCaseObject, getConfig, modifyObjectKeys, snakeCaseObject } from '@edx/frontend-platform';

Check failure on line 2 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

Expected a line break after this opening brace

Check failure on line 2 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

Expected a line break before this closing brace
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { convertObjectToSnakeCase } from '../../utils';

Expand All @@ -14,7 +15,13 @@
export async function getCourseAdvancedSettings(courseId) {
const { data } = await getAuthenticatedHttpClient()
.get(`${getCourseAdvancedSettingsApiUrl(courseId)}?fetch_all=0`);
return camelCaseObject(data);
const objectFormatted = camelCaseObject(data);
return modifyObjectKeys(objectFormatted, (key) => {
if (objectFormatted[key]) {
objectFormatted[key]['value'] = snakeCaseObject(objectFormatted[key]['value'])

Check failure on line 21 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

["value"] is better written in dot notation

Check failure on line 21 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

["value"] is better written in dot notation

Check failure on line 21 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

Missing semicolon
}
return key;
});
}

/**
Expand All @@ -26,7 +33,13 @@
export async function updateCourseAdvancedSettings(courseId, settings) {
const { data } = await getAuthenticatedHttpClient()
.patch(`${getCourseAdvancedSettingsApiUrl(courseId)}`, convertObjectToSnakeCase(settings));
return camelCaseObject(data);
const objectFormatted = camelCaseObject(data);
return modifyObjectKeys(objectFormatted, (key) => {
if (objectFormatted[key]) {
objectFormatted[key]['value'] = snakeCaseObject(objectFormatted[key]['value'])

Check failure on line 39 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

["value"] is better written in dot notation

Check failure on line 39 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

["value"] is better written in dot notation

Check failure on line 39 in src/advanced-settings/data/api.js

View workflow job for this annotation

GitHub Actions / tests

Missing semicolon
}
return key;
});
}

/**
Expand Down
Loading