import React from "react"; import classes from "./classes.module.scss"; import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography"; import CloseIcon from "@Assets/Icons/cross.svg"; import Image from "next/image"; import ToastHandler from "@Front/Components/DesignSystem/Toasts/ToastsHandler"; import Toasts, { IToast } from "@Front/Stores/Toasts"; import Check from "@Front/Components/Elements/Icons/Check"; type IProps = { isOpen: boolean; closeModal: () => void; }; type IState = { toastList: IToast[] | null; }; export default class NotificationModal extends React.Component { private removeOnToastChange: () => void = () => {}; constructor(props: IProps) { super(props); this.state = { toastList: Toasts.getInstance().toasts, }; this.handleToastChange = this.handleToastChange.bind(this); this.readAllNotifications = this.readAllNotifications.bind(this); } public override render(): JSX.Element | null { if (!this.props.isOpen) return null; return ( <>
Notifications
Close notification modal
Tout marquer comme lu
<> {!this.state.toastList || this.state.toastList.length === 0 ? (
Vous n'avez pas de notifications.
) : ( )}
); } public override componentDidMount() { this.removeOnToastChange = Toasts.getInstance().onChange(this.handleToastChange); } public override componentWillUnmount() { this.removeOnToastChange(); } private readAllNotifications() { Toasts.getInstance().closeAll(); this.props.closeModal(); } private handleToastChange(toastList: IToast[] | null) { this.setState({ toastList, }); } }