Convert NotificationCard to Typescript
This commit is contained in:
1 parent
5787f941fd
commit
724ae99b29
3 files changed
+16
-12
No files matched your search
@@ -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() {
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -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;
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default interface Notification {
|
||||||
|
id: number;
|
||||||
|
content: string;
|
||||||
|
created_at: string | number;
|
||||||
|
pivot: { unread: number };
|
||||||
|
}
|
||||||
Reference in new issue
Block a user