update notifications css
This commit is contained in:
@@ -11,6 +11,8 @@ import readNotifications from "../../utils/notifications/readNotifications.js";
|
||||
import getUser from "../../utils/getUser.js";
|
||||
import { userCreatedListener } from "../../utils/echo/listeners/userCreatedListener";
|
||||
import { userNotificationsListener } from "../../utils/echo/listeners/userNotificationsListener.js";
|
||||
import NotificationCard from "../NotificationCard/NotificationCard.jsx";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -176,17 +178,7 @@ function Header() {
|
||||
{notifications.length === 0 ? (
|
||||
<p className={styles.notification}>Vous n'avez aucune notification !</p>
|
||||
) : (
|
||||
notifications.map((notification, index) => (
|
||||
<div className={styles.notification} key={index}>
|
||||
<p>{notification.content}</p>
|
||||
<button
|
||||
className={styles.closeBtn}
|
||||
onClick={() => deleteNotification(notification.id)}
|
||||
>
|
||||
<img src="close.svg" alt="supprimer la notification"/>
|
||||
</button>
|
||||
</div>
|
||||
))
|
||||
<NotificationCard notifications={notifications} deleteNotification={deleteNotification} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
|
||||
.notificationDiv {
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
width: 300px;
|
||||
top: 105%;
|
||||
right: 2rem;
|
||||
opacity: 0;
|
||||
@@ -186,16 +186,6 @@
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.closeBtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
background: none;
|
||||
margin: 0;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.closeBtn:focus {
|
||||
outline: none;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import formatDate from "../../utils/date/formatDate.js";
|
||||
import formatTime from "../../utils/date/formatTime.js";
|
||||
|
||||
import styles from "./NotificationCard.module.css"
|
||||
|
||||
|
||||
function NotificationCard({notifications, deleteNotification}) {
|
||||
return (
|
||||
notifications.map((notification, index) => (
|
||||
<div className={styles.notificationCard} key={index}>
|
||||
<div className={styles.cardHeader}>
|
||||
<span className={styles.timeTag}>
|
||||
Le {formatDate(notification.created_at)} à {formatTime(notification.created_at)}
|
||||
</span>
|
||||
<button
|
||||
className={styles.closeIconButton}
|
||||
onClick={() => deleteNotification(notification.id)}
|
||||
title="Supprimer"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className={styles.cardContent}>
|
||||
<p className={styles.message}>
|
||||
{notification.content}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
export default NotificationCard;
|
||||
@@ -0,0 +1,46 @@
|
||||
.notificationCard {
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.timeTag {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
color: #019AFF;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.message {
|
||||
margin: 0;
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.5;
|
||||
color: #2c3e50;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.closeIconButton {
|
||||
background: none;
|
||||
border: none;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
font-size: 1.1rem;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.closeIconButton:hover {
|
||||
color: #cc0000;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export default function formatTime(d) {
|
||||
const date = new Date(d);
|
||||
|
||||
const hh = String(date.getUTCHours()).padStart(2, '0');
|
||||
const min = String(date.getUTCMinutes()).padStart(2, '0');
|
||||
|
||||
return `${hh}:${min}`;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import formatDateTime from '../../date/formatTime.js';
|
||||
|
||||
export const userNotificationsListener = (echo, userData, setNotifications, setunreadNotification) => {
|
||||
if (!userData?.id) return null;
|
||||
|
||||
@@ -8,6 +10,7 @@ export const userNotificationsListener = (echo, userData, setNotifications, setu
|
||||
const newNotification = {
|
||||
id: Date.now(),
|
||||
content: `L'événement ${event.event.name} a été supprimé ! Vous n'y participez donc plus.`,
|
||||
created_at: formatDateTime(Date.now()),
|
||||
pivot: { unread: 1 }
|
||||
};
|
||||
setNotifications(prev => [newNotification, ...prev]);
|
||||
@@ -17,6 +20,7 @@ export const userNotificationsListener = (echo, userData, setNotifications, setu
|
||||
const newNotification = {
|
||||
id: Date.now(),
|
||||
content: `La tâche ${event.task.name} de l'événement ${event.event.name} a été supprimé ! Vous n'y participez donc plus.`,
|
||||
created_at: formatDateTime(Date.now()),
|
||||
pivot: { unread: 1 }
|
||||
};
|
||||
setNotifications(prev => [newNotification, ...prev]);
|
||||
@@ -26,6 +30,7 @@ export const userNotificationsListener = (echo, userData, setNotifications, setu
|
||||
const newNotification = {
|
||||
id: Date.now(),
|
||||
content: `Vous avez été assigné à la tâche ${event.task.name} de l'événement ${event.event.name}`,
|
||||
created_at: formatDateTime(Date.now()),
|
||||
pivot: { unread: 1 }
|
||||
};
|
||||
setNotifications(prev => [newNotification, ...prev]);
|
||||
@@ -35,6 +40,7 @@ export const userNotificationsListener = (echo, userData, setNotifications, setu
|
||||
const newNotification = {
|
||||
id: Date.now(),
|
||||
content: `Vous avez été désassigné de la tâche ${event.task.name} de l'événement ${event.event.name}`,
|
||||
created_at: formatDateTime(Date.now()),
|
||||
pivot: { unread: 1 }
|
||||
};
|
||||
setNotifications(prev => [newNotification, ...prev]);
|
||||
|
||||
Reference in New Issue
Block a user