Skip to content

Commit

Permalink
fetch restricted runs in publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
zawan-ila committed Jun 21, 2024
1 parent 5252f68 commit 4ca9fe8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/data/services/DiscoveryDataApiService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';

import { PAGE_SIZE } from '../constants/table';
import { restrictionTypeValues } from '../../utils';

Check failure on line 4 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Dependency cycle detected

const discoveryBaseUrl = `${process.env.DISCOVERY_API_BASE_URL}/api/v1`;
const publisherBaseUrl = `${process.env.DISCOVERY_API_BASE_URL}/publisher/api`;
Expand All @@ -10,6 +11,7 @@ class DiscoveryDataApiService {
const queryParams = {
editable: 1,
exclude_utm: 1,
include_restricted: restrictionTypeValues.join(","),

Check failure on line 14 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
};
const url = `${discoveryBaseUrl}/courses/${uuid}/`;
return getAuthenticatedHttpClient().get(url, {
Expand All @@ -21,6 +23,7 @@ class DiscoveryDataApiService {
const queryParams = {
editable: 1,
exclude_utm: 1,
include_restricted: restrictionTypeValues.join(","),

Check failure on line 26 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
...params,
};
const url = `${discoveryBaseUrl}/course_runs/${key}`;
Expand All @@ -45,6 +48,7 @@ class DiscoveryDataApiService {
fields: fields.join(),
editable: 1,
exclude_utm: 1,
include_restricted: restrictionTypeValues.join(","),

Check failure on line 51 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
...options,
};
const url = `${discoveryBaseUrl}/courses/`;
Expand Down Expand Up @@ -145,6 +149,7 @@ class DiscoveryDataApiService {
static editCourseRuns(courseRunsData) {
const queryParams = {
exclude_utm: 1,
include_restricted: restrictionTypeValues.join(","),

Check failure on line 152 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
};
// Create a promises array to handle all of the new/modified course runs
const promises = courseRunsData.map((courseRun) => {
Expand Down Expand Up @@ -213,6 +218,7 @@ class DiscoveryDataApiService {
const { uuid } = courseData;
const queryParams = {
exclude_utm: 1,
include_restricted: restrictionTypeValues.join(","),

Check failure on line 221 in src/data/services/DiscoveryDataApiService.js

View workflow job for this annotation

GitHub Actions / tests

Strings must use singlequote
};
const url = `${discoveryBaseUrl}/courses/${uuid}/`;
return getAuthenticatedHttpClient().patch(url, courseData, {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ const restrictionTypeOptions = [
{ value: 'custom-b2c', label: 'Custom B2C' },
];

const restrictionTypeValues = restrictionTypeOptions.map(opt=>opt.value).filter(Boolean)

Check failure on line 378 in src/utils/index.js

View workflow job for this annotation

GitHub Actions / tests

Missing space before =>

Check failure on line 378 in src/utils/index.js

View workflow job for this annotation

GitHub Actions / tests

Missing space after =>

Check failure on line 378 in src/utils/index.js

View workflow job for this annotation

GitHub Actions / tests

Missing semicolon

export {
courseRunIsArchived,
getDateWithDashes,
Expand Down Expand Up @@ -408,4 +410,5 @@ export {
courseTagObjectsToSelectOptions,
getCourseUrlSlugPattern,
restrictionTypeOptions,
restrictionTypeValues,
};

0 comments on commit 4ca9fe8

Please sign in to comment.