File tree 3 files changed +20
-7
lines changed
common/user-notifications
3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
21
21
( state ) => state . notifications ,
22
22
) ;
23
23
24
+ const recentNotifications = [ ...notifications ] . reverse ( ) . slice ( 0 , 5 ) ;
24
25
return (
25
26
< Menu
26
27
open = { Boolean ( anchorEl ) }
@@ -67,7 +68,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
67
68
} }
68
69
>
69
70
{ notifications . length > 0 ? (
70
- notifications . slice ( 0 , 5 ) . map ( ( notification , index ) => (
71
+ recentNotifications . map ( ( notification , index ) => (
71
72
< >
72
73
< Link
73
74
to = {
@@ -82,7 +83,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
82
83
{ notification . isRead ? (
83
84
< FaEnvelopeOpenText className = " min-h-[30px] min-w-[30px] " />
84
85
) : (
85
- < FaEnvelope className = " text-[30px]" />
86
+ < FaEnvelope className = " text-[30px] min-w-[30px] " />
86
87
) }
87
88
< p className = { ` text-[13px] ` } > { notification . message } </ p >
88
89
</ 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