feat: add support for pagination on learner page [BD-38] [TNL-9844] (#129)

Adds support for pagination on the learners page, including the learners list, the post, comments and responses lists.
This commit is contained in:
Kshitij Sobti
2022-04-20 16:40:27 +05:30
committed by GitHub
parent 36ff2fad27
commit e8a3e4eaa8
11 changed files with 144 additions and 73 deletions

View File

@@ -10,19 +10,20 @@ const apiBaseUrl = getConfig().LMS_BASE_URL;
export const coursesApiUrl = `${apiBaseUrl}/api/discussion/v1/courses/`;
export const userProfileApiUrl = `${apiBaseUrl}/api/user/v1/accounts`;
export const postsApiUrl = `${apiBaseUrl}/api/discussion/v1/threads/`;
export const commentsApiUrl = `${apiBaseUrl}/api/discussion/v1/comments/`;
/**
* Fetches all the learners in the given course.
* @param {string} courseId
* @param {number} page
* @param {string} orderBy
* @returns {Promise<{}>}
*/
export async function getLearners(
courseId,
courseId, { page, orderBy },
) {
const params = { page, orderBy };
const url = `${coursesApiUrl}${courseId}/activity_stats/`;
const { data } = await getAuthenticatedHttpClient().get(url);
const { data } = await getAuthenticatedHttpClient().get(url, { params });
return data;
}