From 349865e6efa4d78930debd86548a7ec8fe089ddf Mon Sep 17 00:00:00 2001 From: asharonbaltazar Date: Wed, 7 Dec 2022 11:52:51 -0500 Subject: [PATCH] fix: clearNotification now requires string --- .../context/Notifications/Notification.tsx | 2 +- .../context/Notifications/NotificationProvider.tsx | 14 +++++--------- .../context/Notifications/Notifications.tsx | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx index 974843cf6..1ee52d797 100644 --- a/frontend/components/context/Notifications/Notification.tsx +++ b/frontend/components/context/Notifications/Notification.tsx @@ -6,7 +6,7 @@ import { Notification as NotificationType } from "./NotificationProvider"; interface NotificationProps { notification: NotificationType; - clearNotification: (text?: string) => void; + clearNotification: (text: string) => void; } const Notification = ({ diff --git a/frontend/components/context/Notifications/NotificationProvider.tsx b/frontend/components/context/Notifications/NotificationProvider.tsx index 644cb4fa9..0f5c174d0 100644 --- a/frontend/components/context/Notifications/NotificationProvider.tsx +++ b/frontend/components/context/Notifications/NotificationProvider.tsx @@ -11,7 +11,7 @@ export type Notification = { }; type NotificationContextState = { - createNotification: ({ text, type }: Notification) => void; + createNotification: (newNotification: Notification) => void; }; const NotificationContext = createContext({ @@ -27,14 +27,10 @@ interface NotificationProviderProps { const NotificationProvider = ({ children }: NotificationProviderProps) => { const [notifications, setNotifications] = useState([]); - const clearNotification = (text?: string) => { - if (text) { - return setNotifications((state) => - state.filter((notif) => notif.text !== text) - ); - } - - return setNotifications([]); + const clearNotification = (text: string) => { + return setNotifications((state) => + state.filter((notif) => notif.text !== text) + ); }; const createNotification = ({ diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx index 856331e24..947032730 100644 --- a/frontend/components/context/Notifications/Notifications.tsx +++ b/frontend/components/context/Notifications/Notifications.tsx @@ -3,7 +3,7 @@ import { Notification as NotificationType } from "./NotificationProvider"; interface NoticationsProps { notifications: NotificationType[]; - clearNotification: (text?: string) => void; + clearNotification: (text: string) => void; } const Notifications = ({