Allow admins select a cohort when creating a new post. If a user is not a discussions administrator, or if trying to edit existing post, can't select a cohort (field is hidden). fix: fix adding threads for topics that haven't been preloaded
26 lines
646 B
JavaScript
26 lines
646 B
JavaScript
/* eslint-disable import/prefer-default-export */
|
|
import { camelCaseObject } from '@edx/frontend-platform';
|
|
import { logError } from '@edx/frontend-platform/logging';
|
|
|
|
import {
|
|
getCourseCohorts,
|
|
} from './api';
|
|
import {
|
|
fetchCohortsFailed,
|
|
fetchCohortsRequest,
|
|
fetchCohortsSuccess,
|
|
} from './slices';
|
|
|
|
export function fetchCourseCohorts(courseId) {
|
|
return async (dispatch) => {
|
|
try {
|
|
dispatch(fetchCohortsRequest());
|
|
const data = await getCourseCohorts(courseId);
|
|
dispatch(fetchCohortsSuccess(camelCaseObject(data)));
|
|
} catch (error) {
|
|
dispatch(fetchCohortsFailed());
|
|
logError(error);
|
|
}
|
|
};
|
|
}
|