mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
refactor: Change type to ensure notifs within state are Required<>
This commit is contained in:
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
|||||||
import { Notification as NotificationType } from "./NotificationProvider";
|
import { Notification as NotificationType } from "./NotificationProvider";
|
||||||
|
|
||||||
interface NotificationProps {
|
interface NotificationProps {
|
||||||
notification: NotificationType;
|
notification: Required<NotificationType>;
|
||||||
clearNotification: (text: string) => void;
|
clearNotification: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ interface NotificationProviderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NotificationProvider = ({ children }: NotificationProviderProps) => {
|
const NotificationProvider = ({ children }: NotificationProviderProps) => {
|
||||||
const [notifications, setNotifications] = useState<Notification[]>([]);
|
const [notifications, setNotifications] = useState<Required<Notification>[]>(
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
const clearNotification = (text: string) => {
|
const clearNotification = (text: string) => {
|
||||||
return setNotifications((state) =>
|
return setNotifications((state) =>
|
||||||
@@ -44,7 +46,7 @@ const NotificationProvider = ({ children }: NotificationProviderProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newNotification: Notification = { text, type, timeoutMs };
|
const newNotification: Required<Notification> = { text, type, timeoutMs };
|
||||||
|
|
||||||
return setNotifications((state) => [...state, newNotification]);
|
return setNotifications((state) => [...state, newNotification]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Notification from "./Notification";
|
|||||||
import { Notification as NotificationType } from "./NotificationProvider";
|
import { Notification as NotificationType } from "./NotificationProvider";
|
||||||
|
|
||||||
interface NoticationsProps {
|
interface NoticationsProps {
|
||||||
notifications: NotificationType[];
|
notifications: Required<NotificationType>[];
|
||||||
clearNotification: (text: string) => void;
|
clearNotification: (text: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user