Files
frontend-app-discussions/src/discussions/cohorts/data/thunks.js
Maxim Beder 5fafa44b56 feat: add cohort selection
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
2021-10-28 21:51:48 +02:00

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);
}
};
}