File tree 3 files changed +27
-8
lines changed
common/user-notifications
3 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
21
21
( state ) => state . notifications ,
22
22
) ;
23
23
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
+
24
31
return (
25
32
< Menu
26
33
open = { Boolean ( anchorEl ) }
@@ -67,7 +74,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
67
74
} }
68
75
>
69
76
{ notifications . length > 0 ? (
70
- notifications . slice ( 0 , 5 ) . map ( ( notification , index ) => (
77
+ recentNotifications . map ( ( notification , index ) => (
71
78
< >
72
79
< Link
73
80
to = {
@@ -80,9 +87,9 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
80
87
className = "flex justify-between items-center mb-[3px] px-2 gap-4 $"
81
88
>
82
89
{ notification . isRead ? (
83
- < FaEnvelopeOpenText className = " min-h-[30px] min-w-[30px] " />
90
+ < FaEnvelopeOpenText className = "text-[30px] min-h-[30px] min-w-[30px] " />
84
91
) : (
85
- < FaEnvelope className = " text-[30px]" />
92
+ < FaEnvelope className = " text-[30px] min-w-[30px] min-h-[30px] " />
86
93
) }
87
94
< p className = { ` text-[13px] ` } > { notification . message } </ p >
88
95
</ Link >
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ import { useAppSelector } from "../../../redux/hooks";
7
7
import { getCurrentUser } from "../../../utils/currentuser" ;
8
8
9
9
const UserNotifications = ( ) => {
10
- const { notifications } = useAppSelector ( ( state ) => state . notifications ) ;
10
+ const { notifications, currentUser } = useAppSelector (
11
+ ( state ) => state . notifications ,
12
+ ) ;
11
13
12
14
const formatDate = ( dateString : Date ) => {
13
15
const date = new Date ( dateString ) ;
@@ -60,11 +62,17 @@ const UserNotifications = () => {
60
62
}
61
63
62
64
return (
63
- < div className = "mt-24 mb-4" >
65
+ < div
66
+ className = { ` ${ currentUser && currentUser . roleId === 2 && "mt-24" } mb-4` }
67
+ >
64
68
< div >
65
69
{ sortedNotifications . map ( ( notification , index ) => (
66
70
< Link
67
- to = { `/dashboard/notifications/${ notification . id } ` }
71
+ to = {
72
+ currentUser && currentUser . roleId === 2
73
+ ? `/dashboard/notifications/${ notification . id } `
74
+ : `/notifications/${ notification . id } `
75
+ }
68
76
key = { index }
69
77
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]" } ` }
70
78
>
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ import { readNotification } from "../../../redux/reducers/notificationSlice";
7
7
8
8
const UserNotificationDetail = ( ) => {
9
9
const { id } = useParams < { id : string } > ( ) ;
10
- const { notifications } = useAppSelector ( ( state ) => state . notifications ) ;
10
+ const { notifications, currentUser } = useAppSelector (
11
+ ( state ) => state . notifications ,
12
+ ) ;
11
13
12
14
const dispatch = useAppDispatch ( ) ;
13
15
@@ -50,7 +52,9 @@ const UserNotificationDetail = () => {
50
52
} , [ ] ) ;
51
53
52
54
return (
53
- < div className = "mt-24 mb-4" >
55
+ < div
56
+ className = { ` ${ currentUser && currentUser . roleId === 2 && "mt-24" } mb-4` }
57
+ >
54
58
< div className = "flex flex-col gap-4 p-4 rounded-md bg-[#FFFFFF] min-h-[80vh]" >
55
59
< p >
56
60
When :
You can’t perform that action at this time.
0 commit comments