resolve datetime conflict for notifications
This commit is contained in:
@@ -14,7 +14,7 @@ function NotificationCard({ notifications, deleteNotification }: NotificationCar
|
|||||||
<div className={styles.notificationCard} key={index}>
|
<div className={styles.notificationCard} key={index}>
|
||||||
<div className={styles.cardHeader}>
|
<div className={styles.cardHeader}>
|
||||||
<span className={styles.timeTag}>
|
<span className={styles.timeTag}>
|
||||||
Le {formatDate(String(notification.created_at))} à {formatTime(String(notification.created_at))}
|
Le {formatDate(notification.created_at)} à {formatTime(notification.created_at)}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
className={styles.closeIconButton}
|
className={styles.closeIconButton}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export default function formatDate(d: string | Date): string {
|
export default function formatDate(d: string | Date | number | null | undefined): string {
|
||||||
|
if (!d) return "Date inconnue";
|
||||||
|
|
||||||
const date = d instanceof Date ? d : new Date(d);
|
const date = d instanceof Date ? d : new Date(d);
|
||||||
|
|
||||||
const jj = String(date.getUTCDate()).padStart(2, "0");
|
const jj = String(date.getUTCDate()).padStart(2, "0");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
export default function formatTime(d: string | Date | null | undefined): string {
|
export default function formatTime(d: string | Date | number | null | undefined): string {
|
||||||
if (!d) return "Heure inconnue";
|
if (!d) return "Heure inconnue";
|
||||||
|
|
||||||
const date = d instanceof Date ? d : new Date(d);
|
const date = d instanceof Date ? d : new Date(d);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const adminNotificationsListener = (echo, userData, setNotifications, set
|
|||||||
const newNotification = {
|
const newNotification = {
|
||||||
id: Date.now(),
|
id: Date.now(),
|
||||||
content,
|
content,
|
||||||
created_at: Date.now(),
|
created_at: new Date().toISOString(),
|
||||||
pivot: { unread: 1 }
|
pivot: { unread: 1 }
|
||||||
};
|
};
|
||||||
setNotifications(prev => [newNotification, ...prev]);
|
setNotifications(prev => [newNotification, ...prev]);
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ export const userNotificationsListener = (echo, userData, setNotifications, setU
|
|||||||
const channelName = `user.${userData.id}`;
|
const channelName = `user.${userData.id}`;
|
||||||
|
|
||||||
const handleNotification = (content) => {
|
const handleNotification = (content) => {
|
||||||
|
|
||||||
const newNotification = {
|
const newNotification = {
|
||||||
id: Date.now(),
|
id: Date.now(),
|
||||||
content,
|
content,
|
||||||
created_at: Date.now(),
|
created_at: new Date().toISOString(),
|
||||||
pivot: { unread: 1 }
|
pivot: { unread: 1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
setNotifications(prev => [newNotification, ...prev]);
|
setNotifications(prev => [newNotification, ...prev]);
|
||||||
setUnreadNotification(true);
|
setUnreadNotification(true);
|
||||||
};
|
};
|
||||||
@@ -25,5 +27,8 @@ export const userNotificationsListener = (echo, userData, setNotifications, setU
|
|||||||
})
|
})
|
||||||
.listen('.volunteer.unassigned.to.task', (event) => {
|
.listen('.volunteer.unassigned.to.task', (event) => {
|
||||||
handleNotification(`Vous avez été désassigné de la tâche ${event.task.name} de l'événement ${event.event.name}`);
|
handleNotification(`Vous avez été désassigné de la tâche ${event.task.name} de l'événement ${event.event.name}`);
|
||||||
|
})
|
||||||
|
.listen('.volunteer.role.updated', (event) => {
|
||||||
|
handleNotification(`Votre rôle a changé pour : ${event.role} !`);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user