Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: separate components from Notification Provider

asharonbaltazarf60e0cf7ee32
diff --git a/frontend/components/context/Notifications/Notification.tsx b/frontend/components/context/Notifications/Notification.tsx
new file mode 100644
index 0000000000..974843cf6f
--- /dev/null
+++ b/frontend/components/context/Notifications/Notification.tsx
@@ -0,0 +1,38 @@
+import { faXmarkCircle } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import classnames from "classnames";
+
+import { Notification as NotificationType } from "./NotificationProvider";
+
+interface NotificationProps {
+ notification: NotificationType;
+ clearNotification: (text?: string) => void;
+}
+
+const Notification = ({
+ notification,
+ clearNotification,
+}: NotificationProps) => {
+ return (
+ <div
+ className={classnames(
+ "w-full flex items-center justify-between px-4 py-3 rounded pointer-events-auto",
+ {
+ "bg-green-600": notification.type === "success",
+ "bg-red-500": notification.type === "error",
+ }
+ )}
+ role="alert"
+ >
+ <p className="text-white text-sm font-bold">{notification.text}</p>
+ <button
+ className="bg-white/5 rounded-lg p-3"
+ onClick={() => clearNotification(notification.text)}
+ >
+ <FontAwesomeIcon className="text-white" icon={faXmarkCircle} />
+ </button>
+ </div>
+ );
+};
+
+export default Notification;
diff --git a/frontend/components/context/Notifications/Notifications.tsx b/frontend/components/context/Notifications/Notifications.tsx
new file mode 100644
index 0000000000..856331e24b
--- /dev/null
+++ b/frontend/components/context/Notifications/Notifications.tsx
@@ -0,0 +1,28 @@
+import Notification from "./Notification";
+import { Notification as NotificationType } from "./NotificationProvider";
+
+interface NoticationsProps {
+ notifications: NotificationType[];
+ clearNotification: (text?: string) => void;
+}
+
+const Notifications = ({
+ notifications,
+ clearNotification,
+}: NoticationsProps) => {
+ return (
+ <div className="hidden fixed z-50 top-1 w-full inset-x-0 pointer-events-none md:flex justify-center">
+ <div className="flex flex-col gap-y-2 w-96">
+ {notifications.map((notif) => (
+ <Notification
+ key={notif.text}
+ notification={notif}
+ clearNotification={clearNotification}
+ />
+ ))}
+ </div>
+ </div>
+ );
+};
+
+export default Notifications;