refactor: refactor components
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
|
||||
export const getApiBaseUrl = () => getConfig().LMS_BASE_URL;
|
||||
import { camelCaseObject } from '@edx/frontend-platform';
|
||||
|
||||
const parseNotificationList = (notificationList) => {
|
||||
const currentTime = Date.now();
|
||||
@@ -17,190 +15,185 @@ 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',
|
||||
responding_user: 'SCM_Lead',
|
||||
notification_content: 'Hello and welcome to SC0x!',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685361282018',
|
||||
},
|
||||
{
|
||||
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',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'What grade does a student need to get in order to pass the course and earn a certificate?',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685361282018',
|
||||
},
|
||||
{
|
||||
type: 'post',
|
||||
respondingUser: 'SCM_Lead',
|
||||
notificationContent: 'Hello and welcome to SC0x!',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
responding_user: 'SCM_Lead',
|
||||
notification_content: 'Hello and welcome to SC0x!',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
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',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'What grade does a student need to get in order to pass the course and earn a certificate?',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
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',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'Can’t find linear regression in section 3 review',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
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',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'Can’t find linear regression in section 3 review',
|
||||
target_user: 'MITx_Expert’s ',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1684253736371',
|
||||
author: '',
|
||||
},
|
||||
{
|
||||
type: 'question',
|
||||
respondingUser: 'MITx_Learner',
|
||||
notificationContent: 'Examples of quadratic equations in supply chains',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'Examples of quadratic equations in supply chains',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
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',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'What grade does a student need to get in order to pass the course and earn a certificate?',
|
||||
target_user: 'MITx_Expert’s ',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
time: '1684253736371',
|
||||
is_seen: false,
|
||||
author: 'testuser',
|
||||
},
|
||||
{
|
||||
type: 'comment',
|
||||
respondingUser: 'MITx_Learner',
|
||||
notificationContent: 'Convexity of f(x)=1/x , x>1',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
responding_user: 'MITx_Learner',
|
||||
notification_content: 'Convexity of f(x)=1/x , x>1',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
time: '1684253736371',
|
||||
is_seen: false,
|
||||
author: 'testuser',
|
||||
},
|
||||
{
|
||||
type: 'answer',
|
||||
respondingUser: 'SCM_Lead',
|
||||
notificationContent: 'Quiz in section 3 - Please explain the F-Significance value',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
responding_user: 'SCM_Lead',
|
||||
notification_content: 'Quiz in section 3 - Please explain the F-Significance value',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
time: '1685096268835',
|
||||
is_seen: false,
|
||||
author: 'testuser',
|
||||
},
|
||||
{
|
||||
type: 'endorsed',
|
||||
respondingUser: '',
|
||||
notificationContent: 'Quiz in section 3 - Please explain the F-Significance value',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
responding_user: '',
|
||||
notification_content: 'Quiz in section 3 - Please explain the F-Significance value',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685096268835',
|
||||
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: '1685096268835',
|
||||
responding_user: 'MITx Learner’s',
|
||||
notification_content: '“Here are the exam answers. Question 1 - CSA stands for Compliance Safety Ac...”',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685212056931',
|
||||
author: '',
|
||||
},
|
||||
{
|
||||
type: 'postLiked',
|
||||
respondingUser: 'SCM_Lead',
|
||||
notificationContent: 'Retaking the course',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
time: '1685096268835',
|
||||
responding_user: 'SCM_Lead',
|
||||
notification_content: 'Retaking the course',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685212056931',
|
||||
author: '',
|
||||
},
|
||||
{
|
||||
type: 'commentLiked',
|
||||
respondingUser: 'MITx_Expert ',
|
||||
notificationContent: 'Final exam answers',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
time: '1685096268835',
|
||||
responding_user: 'MITx_Expert ',
|
||||
notification_content: 'Final exam answers',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685212056931',
|
||||
author: '',
|
||||
},
|
||||
{
|
||||
type: 'edited',
|
||||
respondingUser: 'MITx_Expert ',
|
||||
notificationContent: 'Question 1',
|
||||
targetUser: '',
|
||||
courseName: 'Supply Chain Analytics',
|
||||
URL: '',
|
||||
status: 'unread',
|
||||
time: '1685096268835',
|
||||
responding_user: 'MITx_Expert ',
|
||||
notification_content: 'Question 1',
|
||||
target_user: '',
|
||||
course_name: 'Supply Chain Analytics',
|
||||
content_url: '',
|
||||
is_read: false,
|
||||
is_seen: false,
|
||||
time: '1685212056931',
|
||||
author: '',
|
||||
},
|
||||
];
|
||||
|
||||
const { today, earlier } = parseNotificationList(notificationData);
|
||||
const { today, earlier } = parseNotificationList(camelCaseObject(notificationData));
|
||||
|
||||
const data = {
|
||||
discussions: {
|
||||
@@ -233,11 +226,13 @@ export async function getNotifications(notificationType, notificationCount) {
|
||||
|
||||
export async function getNotificationCounts() {
|
||||
const data = {
|
||||
Total: 25,
|
||||
Reminders: 10,
|
||||
Discussions: 5,
|
||||
Grades: 4,
|
||||
Authoring: 6,
|
||||
count: 25,
|
||||
count_by_app_name: {
|
||||
reminders: 10,
|
||||
discussions: 5,
|
||||
grades: 4,
|
||||
authoring: 6,
|
||||
},
|
||||
};
|
||||
return data;
|
||||
return camelCaseObject(data);
|
||||
}
|
||||
|
||||
10
src/Notifications/data/hook.js
Normal file
10
src/Notifications/data/hook.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { breakpoints, useWindowSize } from '@edx/paragon';
|
||||
|
||||
export function useIsOnDesktop() {
|
||||
const windowSize = useWindowSize();
|
||||
return windowSize.width >= breakpoints.medium.minWidth;
|
||||
}
|
||||
export function useIsOnXLDesktop() {
|
||||
const windowSize = useWindowSize();
|
||||
return windowSize.width >= breakpoints.extraLarge.minWidth;
|
||||
}
|
||||
Reference in New Issue
Block a user