mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 16:28:11 +00:00
fix: clearNotification now requires string
This commit is contained in:
@@ -6,7 +6,7 @@ import { Notification as NotificationType } from "./NotificationProvider";
|
|||||||
|
|
||||||
interface NotificationProps {
|
interface NotificationProps {
|
||||||
notification: NotificationType;
|
notification: NotificationType;
|
||||||
clearNotification: (text?: string) => void;
|
clearNotification: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Notification = ({
|
const Notification = ({
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export type Notification = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type NotificationContextState = {
|
type NotificationContextState = {
|
||||||
createNotification: ({ text, type }: Notification) => void;
|
createNotification: (newNotification: Notification) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const NotificationContext = createContext<NotificationContextState>({
|
const NotificationContext = createContext<NotificationContextState>({
|
||||||
@@ -27,14 +27,10 @@ interface NotificationProviderProps {
|
|||||||
const NotificationProvider = ({ children }: NotificationProviderProps) => {
|
const NotificationProvider = ({ children }: NotificationProviderProps) => {
|
||||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
const [notifications, setNotifications] = useState<Notification[]>([]);
|
||||||
|
|
||||||
const clearNotification = (text?: string) => {
|
const clearNotification = (text: string) => {
|
||||||
if (text) {
|
return setNotifications((state) =>
|
||||||
return setNotifications((state) =>
|
state.filter((notif) => notif.text !== text)
|
||||||
state.filter((notif) => notif.text !== text)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return setNotifications([]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const createNotification = ({
|
const createNotification = ({
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Notification as NotificationType } from "./NotificationProvider";
|
|||||||
|
|
||||||
interface NoticationsProps {
|
interface NoticationsProps {
|
||||||
notifications: NotificationType[];
|
notifications: NotificationType[];
|
||||||
clearNotification: (text?: string) => void;
|
clearNotification: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Notifications = ({
|
const Notifications = ({
|
||||||
|
|||||||
Reference in New Issue
Block a user