Convert NotificationCard to Typescript

This commit is contained in:
T'JAMPENS QUENTIN p2406187 committed 2026-03-18 20:58:30 +01:00
1 parent 5787f941fd
commit 724ae99b29
3 files changed
+16 -12

No files matched your search

+2 -8
View File
@@ -7,17 +7,11 @@ import initEcho from "../../utils/echo/initEcho.js"
import readNotifications from "../../utils/notifications/readNotifications.js"; import readNotifications from "../../utils/notifications/readNotifications.js";
import { userCreatedListener } from "../../utils/echo/listeners/userCreatedListener"; import { userCreatedListener } from "../../utils/echo/listeners/userCreatedListener";
import { userNotificationsListener } from "../../utils/echo/listeners/userNotificationsListener.js"; import { userNotificationsListener } from "../../utils/echo/listeners/userNotificationsListener.js";
import NotificationCard from "../NotificationCard/NotificationCard.jsx"; import NotificationCard from "../NotificationCard/NotificationCard";
import { EventContext } from "../../contexts/Events/EventContext.js"; import { EventContext } from "../../contexts/Events/EventContext.js";
import { AuthContext } from "../../contexts/Auth/AuthContext.js"; import { AuthContext } from "../../contexts/Auth/AuthContext.js";
import { PendingMembersContext } from "../../contexts/PendingMembers/PendingMembersContext"; import { PendingMembersContext } from "../../contexts/PendingMembers/PendingMembersContext";
import Notification from "../../interfaces/notification.interface";
interface Notification {
id: number;
content: string;
created_at: string | number;
pivot: { unread: number };
}
function Header() { function Header() {
@@ -1,16 +1,20 @@
import formatDate from "../../utils/date/formatDate.js"; import formatDate from "../../utils/date/formatDate.js";
import formatTime from "../../utils/date/formatTime.js"; import formatTime from "../../utils/date/formatTime.js";
import styles from "./NotificationCard.module.css" import styles from "./NotificationCard.module.css"
import Notification from "../../interfaces/notification.interface";
interface NotificationCardProps {
notifications: Notification[];
deleteNotification: (id: number) => void;
}
function NotificationCard({notifications, deleteNotification}) { function NotificationCard({ notifications, deleteNotification }: NotificationCardProps) {
return ( return (
notifications.map((notification, index) => ( notifications.map((notification, index) => (
<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(notification.created_at)} à {formatTime(notification.created_at)} Le {formatDate(String(notification.created_at))} à {formatTime(String(notification.created_at))}
</span> </span>
<button <button
className={styles.closeIconButton} className={styles.closeIconButton}
@@ -31,4 +35,4 @@ function NotificationCard({notifications, deleteNotification}) {
); );
} }
export default NotificationCard; export default NotificationCard;
+6
View File
@@ -0,0 +1,6 @@
export default interface Notification {
id: number;
content: string;
created_at: string | number;
pivot: { unread: number };
}