Skip to content

Commit

Permalink
fix: clearNotification now requires string
Browse files Browse the repository at this point in the history
  • Loading branch information
asharonbaltazar committed Dec 7, 2022
1 parent add3075 commit 349865e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/components/context/Notifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Notification as NotificationType } from "./NotificationProvider";

interface NotificationProps {
notification: NotificationType;
clearNotification: (text?: string) => void;
clearNotification: (text: string) => void;
}

const Notification = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type Notification = {
};

type NotificationContextState = {
createNotification: ({ text, type }: Notification) => void;
createNotification: (newNotification: Notification) => void;
};

const NotificationContext = createContext<NotificationContextState>({
Expand All @@ -27,14 +27,10 @@ interface NotificationProviderProps {
const NotificationProvider = ({ children }: NotificationProviderProps) => {
const [notifications, setNotifications] = useState<Notification[]>([]);

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 = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Notification as NotificationType } from "./NotificationProvider";

interface NoticationsProps {
notifications: NotificationType[];
clearNotification: (text?: string) => void;
clearNotification: (text: string) => void;
}

const Notifications = ({
Expand Down

0 comments on commit 349865e

Please sign in to comment.