feat: implement learners area new UI (#197)
* feat: implement learners area new UI * fix: learners list UI * fix: initial learner sort based on role
This commit is contained in:
@@ -200,21 +200,3 @@ export async function uploadFile(blob, filename, courseId, threadKey) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the posts by a specific user in a course's discussions
|
||||
*
|
||||
* @param {string} courseId Course ID of the course
|
||||
* @param {string} username Username of the user
|
||||
* @param {number} page
|
||||
* @returns API Response object in the format
|
||||
* {
|
||||
* results: [array of posts],
|
||||
* pagination: {count, num_pages, next, previous}
|
||||
* }
|
||||
*/
|
||||
export async function getUserPosts(courseId, username, { page }) {
|
||||
const { data } = await getAuthenticatedHttpClient()
|
||||
.get(threadsApiUrl, { params: { course_id: courseId, author: username, page } });
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,13 @@ const threadsSlice = createSlice({
|
||||
sortedBy: ThreadOrdering.BY_LAST_ACTIVITY,
|
||||
},
|
||||
reducers: {
|
||||
fetchLearnerThreadsRequest: (state, { payload }) => {
|
||||
if (state.author !== payload.author) {
|
||||
state.pages = [];
|
||||
state.author = payload.author;
|
||||
}
|
||||
state.status = RequestStatus.IN_PROGRESS;
|
||||
},
|
||||
fetchThreadsRequest: (state) => {
|
||||
state.status = RequestStatus.IN_PROGRESS;
|
||||
},
|
||||
@@ -177,6 +184,7 @@ export const {
|
||||
deleteThreadFailed,
|
||||
deleteThreadRequest,
|
||||
deleteThreadSuccess,
|
||||
fetchLearnerThreadsRequest,
|
||||
fetchThreadDenied,
|
||||
fetchThreadFailed,
|
||||
fetchThreadRequest,
|
||||
|
||||
@@ -46,7 +46,7 @@ import {
|
||||
* @param data
|
||||
* @returns {{pagination, threadsById: {}, threadsInTopic: {}, avatars: {}}}
|
||||
*/
|
||||
function normaliseThreads(data) {
|
||||
export function normaliseThreads(data) {
|
||||
const normalized = {};
|
||||
let threads;
|
||||
if ('results' in data) {
|
||||
|
||||
Reference in New Issue
Block a user