Skip to content

Commit c5613c9

Browse files
committed
Merge remote-tracking branch 'origin/dev' into fix-notification
2 parents cdd6a0e + ee7d51f commit c5613c9

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

Diff for: src/components/cards/Notification.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
2121
(state) => state.notifications,
2222
);
2323

24+
const recentNotifications = [...notifications]
25+
.sort(
26+
(a, b) =>
27+
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
28+
)
29+
.slice(0, 5);
30+
2431
return (
2532
<Menu
2633
open={Boolean(anchorEl)}
@@ -67,7 +74,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
6774
}}
6875
>
6976
{notifications.length > 0 ? (
70-
notifications.slice(0, 5).map((notification, index) => (
77+
recentNotifications.map((notification, index) => (
7178
<>
7279
<Link
7380
to={
@@ -80,9 +87,9 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
8087
className="flex justify-between items-center mb-[3px] px-2 gap-4 $"
8188
>
8289
{notification.isRead ? (
83-
<FaEnvelopeOpenText className=" min-h-[30px] min-w-[30px] " />
90+
<FaEnvelopeOpenText className="text-[30px] min-h-[30px] min-w-[30px] " />
8491
) : (
85-
<FaEnvelope className=" text-[30px]" />
92+
<FaEnvelope className=" text-[30px] min-w-[30px] min-h-[30px]" />
8693
)}
8794
<p className={` text-[13px] `}>{notification.message}</p>
8895
</Link>

Diff for: src/components/common/user-notifications/UserNotifcations.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { useAppSelector } from "../../../redux/hooks";
77
import { getCurrentUser } from "../../../utils/currentuser";
88

99
const UserNotifications = () => {
10-
const { notifications } = useAppSelector((state) => state.notifications);
10+
const { notifications, currentUser } = useAppSelector(
11+
(state) => state.notifications,
12+
);
1113

1214
const formatDate = (dateString: Date) => {
1315
const date = new Date(dateString);
@@ -60,11 +62,17 @@ const UserNotifications = () => {
6062
}
6163

6264
return (
63-
<div className="mt-24 mb-4">
65+
<div
66+
className={` ${currentUser && currentUser.roleId === 2 && "mt-24"} mb-4`}
67+
>
6468
<div>
6569
{sortedNotifications.map((notification, index) => (
6670
<Link
67-
to={`/dashboard/notifications/${notification.id}`}
71+
to={
72+
currentUser && currentUser.roleId === 2
73+
? `/dashboard/notifications/${notification.id}`
74+
: `/notifications/${notification.id}`
75+
}
6876
key={index}
6977
className={`flex sm:flex-row flex-col justify-between items-center mb-[3px] p-4 rounded-md gap-4 ${notification.isRead ? "bg-[#FFFFFF]" : "bg-[#E1ECF4]"}`}
7078
>

Diff for: src/components/common/user-notifications/UserNotificationDetail.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { readNotification } from "../../../redux/reducers/notificationSlice";
77

88
const UserNotificationDetail = () => {
99
const { id } = useParams<{ id: string }>();
10-
const { notifications } = useAppSelector((state) => state.notifications);
10+
const { notifications, currentUser } = useAppSelector(
11+
(state) => state.notifications,
12+
);
1113

1214
const dispatch = useAppDispatch();
1315

@@ -50,7 +52,9 @@ const UserNotificationDetail = () => {
5052
}, []);
5153

5254
return (
53-
<div className="mt-24 mb-4">
55+
<div
56+
className={` ${currentUser && currentUser.roleId === 2 && "mt-24"} mb-4`}
57+
>
5458
<div className="flex flex-col gap-4 p-4 rounded-md bg-[#FFFFFF] min-h-[80vh]">
5559
<p>
5660
When :

0 commit comments

Comments
 (0)