diff --git a/src/Notifications/data/api.js b/src/Notifications/data/api.js
index 0de5a60..64b812c 100644
--- a/src/Notifications/data/api.js
+++ b/src/Notifications/data/api.js
@@ -2,180 +2,148 @@ import { getConfig } from '@edx/frontend-platform';
export const getApiBaseUrl = () => getConfig().LMS_BASE_URL;
+const parseNotificationList = (notificationList) => {
+ const currentTime = Date.now();
+ const twentyFourHoursAgo = currentTime - (24 * 60 * 60 * 1000);
+ const today = [];
+ const earlier = [];
+ notificationList.forEach(obj => {
+ const objectTime = obj.time;
+ if (objectTime >= twentyFourHoursAgo && objectTime <= currentTime) { today.push(obj); } else { earlier.push(obj); }
+ });
+ return { today, earlier };
+};
export async function getNotifications(notificationType, notificationCount) {
+ const notificationData = [
+ {
+ type: 'post',
+ respondingUser: 'SCM_Lead',
+ notificationContent: 'Hello and welcome to SC0x!',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684996319038',
+ },
+ {
+ type: 'post',
+ respondingUser: 'SCM_Lead',
+ notificationContent: 'Hello and welcome to SC0x!',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684996319038',
+ },
+ {
+ type: 'post',
+ respondingUser: 'SCM_Lead',
+ notificationContent: 'Hello and welcome to SC0x!',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684996319038',
+ },
+ {
+ type: 'help',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684996339844',
+ },
+ {
+ type: 'post',
+ respondingUser: 'SCM_Lead',
+ notificationContent: 'Hello and welcome to SC0x!',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253634808',
+ author: '',
+ },
+ {
+ type: 'help',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: '',
+ },
+ {
+ type: 'respond',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'Can’t find linear regression in section 3 review',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: '',
+ },
+ {
+ type: 'comment',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'Can’t find linear regression in section 3 review',
+ targetUser: 'MITx_Expert’s ',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: '',
+ },
+ {
+ type: 'question',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'Examples of quadratic equations in supply chains',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: '',
+ },
+ {
+ type: 'comment',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
+ targetUser: 'MITx_Expert’s ',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: 'testuser',
+ },
+ {
+ type: 'comment',
+ respondingUser: 'MITx_Learner',
+ notificationContent: 'Convexity of f(x)=1/x , x>1',
+ targetUser: '',
+ courseName: 'Supply Chain Analytics',
+ URL: '',
+ status: 'unread',
+ time: '1684253736371',
+ author: 'testuser',
+ },
+ ];
+
+ const { today, earlier } = parseNotificationList(notificationData);
+
const data = {
discussions: {
- TODAY: [
- {
- type: 'post',
- respondingUser: 'SCM_Lead',
- notificationContent: 'Hello and welcome to SC0x!',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- },
- {
- type: 'help',
- respondingUser: 'MITx_Learner',
- notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- },
- ],
+ TODAY: today,
+ EARLIER: earlier,
},
reminders: {
- TODAY: [
- {
- type: 'post',
- respondingUser: 'SCM_Lead',
- notificationContent: 'Hello and welcome to SC0x!',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253634808',
- author: '',
- },
- {
- type: 'help',
- respondingUser: 'MITx_Learner',
- notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: '',
- },
- {
- type: 'respond',
- respondingUser: 'MITx_Learner',
- notificationContent: 'Can’t find linear regression in section 3 review',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: '',
- },
- {
- type: 'comment',
- respondingUser: 'MITx_Learner',
- notificationContent: 'Can’t find linear regression in section 3 review',
- targetUser: 'MITx_Expert’s ',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: '',
- },
- {
- type: 'question',
- respondingUser: 'MITx_Learner',
- notificationContent: 'Examples of quadratic equations in supply chains',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: '',
- },
- {
- type: 'comment',
- respondingUser: 'MITx_Learner',
- notificationContent: 'What grade does a student need to get in order to pass the course and earn a certificate?',
- targetUser: 'MITx_Expert’s ',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: 'testuser',
- },
- {
- type: 'comment',
- respondingUser: 'MITx_Learner',
- notificationContent: 'Convexity of f(x)=1/x , x>1',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '1684253736371',
- author: 'testuser',
- },
- ],
- EARLIER: [
- {
- type: 'answer',
- respondingUser: 'SCM_Lead',
- notificationContent: 'Quiz in section 3 - Please explain the F-Significance value',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: 'testuser',
- },
- {
- type: 'endorsed',
- respondingUser: '',
- notificationContent: 'Quiz in section 3 - Please explain the F-Significance value',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: 'testuser',
- },
- {
- type: 'reported',
- respondingUser: 'MITx Learner’s',
- notificationContent: '“Here are the exam answers. Question 1 - CSA stands for Compliance Safety Ac...”',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: '',
- },
- {
- type: 'postLiked',
- respondingUser: 'SCM_Lead',
- notificationContent: 'Retaking the course',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: '',
- },
- {
- type: 'commentLiked',
- respondingUser: 'MITx_Expert ',
- notificationContent: 'Final exam answers',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: '',
- },
- {
- type: 'edited',
- respondingUser: 'MITx_Expert ',
- notificationContent: 'Question 1',
- targetUser: '',
- courseName: 'Supply Chain Analytics',
- URL: '',
- status: 'unread',
- time: '15m',
- author: '',
- },
- ],
+ TODAY: today,
+ EARLIER: earlier,
},
};
const notifications = data[notificationType];
diff --git a/src/Notifications/data/selectors.js b/src/Notifications/data/selectors.js
index b0bb9d4..d62a52b 100644
--- a/src/Notifications/data/selectors.js
+++ b/src/Notifications/data/selectors.js
@@ -1,3 +1,4 @@
export const getNotificationStatus = () => state => state.notifications.notificationStatus;
export const getNotificationTotalUnseenCounts = () => state => state.notifications.totalUnseenCounts;
export const getNotifications = () => state => state.notifications.notifications;
+export const getSelectedNotificationType = () => state => state.notifications.notificationType;
diff --git a/src/__snapshots__/Header.test.jsx.snap b/src/__snapshots__/Header.test.jsx.snap
index e19fabe..3768354 100644
--- a/src/__snapshots__/Header.test.jsx.snap
+++ b/src/__snapshots__/Header.test.jsx.snap
@@ -238,7 +238,7 @@ exports[`
renders correctly for authenticated desktop 1`] = `
className="nav secondary-menu-container align-items-center ml-auto"
>