feat: added add more notification button functionality

This commit is contained in:
SundasNoreen
2023-05-22 13:02:57 +05:00
parent f8fc794458
commit e76f5b6937
8 changed files with 70 additions and 32 deletions

View File

@@ -1,15 +1,8 @@
/* eslint-disable import/prefer-default-export */
// import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { getConfig } from '@edx/frontend-platform';
export const getApiBaseUrl = () => getConfig().LMS_BASE_URL;
export async function getNotifications(notificationType) {
// const url = `${getApiBaseUrl()}/api/discussion/v1/notifications/`;
// const { data } = await getAuthenticatedHttpClient()
// .get(url);
export async function getNotifications(notificationType, notificationCount) {
const data = {
discussions: {
TODAY: [
@@ -185,7 +178,23 @@ export async function getNotifications(notificationType) {
],
},
};
return data[notificationType];
const notifications = data[notificationType];
const { TODAY = [], EARLIER = [] } = notifications || [];
let todayNotifications = TODAY;
let earlierNotifications = [];
let totalCount = 0;
if (TODAY && EARLIER) {
if (TODAY.length > notificationCount) {
todayNotifications = TODAY.slice(0, notificationCount);
} else {
todayNotifications = TODAY;
earlierNotifications = EARLIER.slice(0, notificationCount - TODAY.length);
}
totalCount = TODAY.length + EARLIER.length;
}
return { TODAY: todayNotifications, EARLIER: earlierNotifications, totalCount };
}
export async function getNotificationCounts() {