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:
Awais Ansari
2022-06-20 16:14:13 +05:00
committed by GitHub
parent 84148954d0
commit 59187d2217
34 changed files with 460 additions and 737 deletions

View File

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

View File

@@ -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,

View File

@@ -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) {