Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : extended notification component #37

Merged
merged 5 commits into from
Aug 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/dev' into fix-notification
soleil00 committed Jul 30, 2024
commit c5613c98cec60001e5903950ff650da4d4bd4d6c
13 changes: 10 additions & 3 deletions src/components/cards/Notification.tsx
Original file line number Diff line number Diff line change
@@ -21,6 +21,13 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
(state) => state.notifications,
);

const recentNotifications = [...notifications]
.sort(
(a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(),
)
.slice(0, 5);

return (
<Menu
open={Boolean(anchorEl)}
@@ -67,7 +74,7 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
}}
>
{notifications.length > 0 ? (
notifications.slice(0, 5).map((notification, index) => (
recentNotifications.map((notification, index) => (
<>
<Link
to={
@@ -80,9 +87,9 @@ export const NotificationPopup: React.FC<INotificationPop> = ({
className="flex justify-between items-center mb-[3px] px-2 gap-4 $"
>
{notification.isRead ? (
<FaEnvelopeOpenText className=" min-h-[30px] min-w-[30px] " />
<FaEnvelopeOpenText className="text-[30px] min-h-[30px] min-w-[30px] " />
) : (
<FaEnvelope className=" text-[30px]" />
<FaEnvelope className=" text-[30px] min-w-[30px] min-h-[30px]" />
)}
<p className={` text-[13px] `}>{notification.message}</p>
</Link>
14 changes: 11 additions & 3 deletions src/components/common/user-notifications/UserNotifcations.tsx
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ import { useAppSelector } from "../../../redux/hooks";
import { getCurrentUser } from "../../../utils/currentuser";

const UserNotifications = () => {
const { notifications } = useAppSelector((state) => state.notifications);
const { notifications, currentUser } = useAppSelector(
(state) => state.notifications,
);

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

return (
<div className="mt-24 mb-4">
<div
className={` ${currentUser && currentUser.roleId === 2 && "mt-24"} mb-4`}
>
<div>
{sortedNotifications.map((notification, index) => (
<Link
to={`/dashboard/notifications/${notification.id}`}
to={
currentUser && currentUser.roleId === 2
? `/dashboard/notifications/${notification.id}`
: `/notifications/${notification.id}`
}
key={index}
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]"}`}
>
Original file line number Diff line number Diff line change
@@ -7,7 +7,9 @@ import { readNotification } from "../../../redux/reducers/notificationSlice";

const UserNotificationDetail = () => {
const { id } = useParams<{ id: string }>();
const { notifications } = useAppSelector((state) => state.notifications);
const { notifications, currentUser } = useAppSelector(
(state) => state.notifications,
);

const dispatch = useAppDispatch();

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

return (
<div className="mt-24 mb-4">
<div
className={` ${currentUser && currentUser.roleId === 2 && "mt-24"} mb-4`}
>
<div className="flex flex-col gap-4 p-4 rounded-md bg-[#FFFFFF] min-h-[80vh]">
<p>
When :
You are viewing a condensed version of this merge commit. You can view the full changes here.