Skip to content

Commit a211547

Browse files
refactor: removed backend api calls
1 parent 784e9af commit a211547

4 files changed

Lines changed: 12 additions & 16 deletions

File tree

src/Notifications/NotificationTabs.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const NotificationTabs = () => {
3030
eventKey={appName}
3131
title={appName}
3232
notification={notificationUnseenCounts[appName]}
33-
tabClassName="pt-0 pb-2.5 px-2.5 d-flex border-top-0 mb-0 align-items-center line-height-24 text-capitalize"
33+
tabClassName="pt-0 pb-10px px-2.5 d-flex border-top-0 mb-0 align-items-center line-height-24 text-capitalize"
3434
>
3535
{appName === selectedAppName && (<NotificationSections />)}
3636
</Tab>
@@ -41,7 +41,7 @@ const NotificationTabs = () => {
4141
variant="tabs"
4242
defaultActiveKey={selectedAppName}
4343
onSelect={handleActiveTab}
44-
className="px-2.5 border-0 text-primary-500"
44+
className="px-2.5 text-primary-500"
4545
>
4646
{tabArray}
4747
</Tabs>

src/Notifications/data/api.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import { camelCaseObject, getConfig } from '@edx/frontend-platform';
2-
1+
import { camelCaseObject } from '@edx/frontend-platform';
32
import notificationsList from './notifications.json';
43

5-
export const getNotificationsCountApiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/count/`;
6-
export const getNotificationsApiUrl = () => `${getConfig().LMS_BASE_URL}/api/notifications/`;
7-
export const markNotificationsSeenApiUrl = (appName) => `${getConfig().LMS_BASE_URL}/api/notifications/mark-notifications-unseen/${appName}/`;
8-
94
export async function getNotifications(appName, page, pageSize) {
105
const { data } = notificationsList;
116
const startIndex = (page - 1) * pageSize;
@@ -24,7 +19,7 @@ export async function getNotificationCounts() {
2419
grades: 10,
2520
authoring: 5,
2621
},
27-
show_notification_tray: true,
22+
show_notification_tray: false,
2823
};
2924
return camelCaseObject(data);
3025
}

src/Notifications/data/slice.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ const slice = createSlice({
8787
state.notificationStatus = LOADING;
8888
},
8989
markAllNotificationsAsReadSuccess: (state) => {
90-
const date = new Date().toISOString();
91-
const updatedNotifications = Object.entries(state.notifications)
92-
.filter(([key]) => state.apps[state.appName].includes(key))
93-
.map(([, value]) => ({ ...value, lastRead: date }));
94-
90+
const updatedNotifications = Object.fromEntries(
91+
Object.entries(state.notifications).map(([key, notification]) => [
92+
key, { ...notification, lastRead: new Date().toISOString() },
93+
]),
94+
);
9595
state.notifications = updatedNotifications;
9696
state.notificationStatus = LOADED;
9797
},
@@ -116,12 +116,10 @@ const slice = createSlice({
116116
state.notificationStatus = FAILED;
117117
},
118118
resetNotificationStateRequest: () => initialState,
119-
120119
updateAppNameRequest: (state, { payload }) => {
121120
state.appName = payload.appName;
122121
state.pagination.currentPage = 1;
123122
},
124-
125123
updatePaginationRequest: (state) => {
126124
state.pagination.currentPage += 1;
127125
},

src/index.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ $white: #fff;
145145
padding-top: 10px;
146146
padding-bottom: 10px;
147147
}
148+
.pb-10px{
149+
padding-bottom: 10px;
150+
}
148151

149152
.line-height-24{
150153
line-height: 24px;

0 commit comments

Comments
 (0)