fix: redux structure updates

This commit is contained in:
Awais Ansari
2023-06-01 19:57:45 +05:00
parent 72e82005c0
commit 7ab55175b5
6 changed files with 169 additions and 219 deletions

View File

@@ -0,0 +1,24 @@
export const splitNotificationsByTime = (notificationList) => {
const currentTime = Date.now();
const twentyFourHoursAgo = currentTime - (24 * 60 * 60 * 1000);
const { today, earlier } = notificationList.reduce(
(result, notification) => {
const objectTime = new Date(notification.createdAt).getTime();
if (objectTime >= twentyFourHoursAgo && objectTime <= currentTime) {
result.today.push(notification);
} else {
result.earlier.push(notification);
}
return result;
},
{ today: [], earlier: [] },
);
return { today, earlier };
};
export const getNotificationCount = (notificationCounts, appName) => {
const { countByAppName } = notificationCounts;
return countByAppName[appName] || 0;
};