mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 01:52:22 +00:00
feat(ui): changed to a better toast for ui and a global error handler for all server error messages
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { ReactNode } from "react";
|
||||
import { Id, toast, ToastContainer, ToastOptions, TypeOptions } from "react-toastify";
|
||||
|
||||
export type TNotification = {
|
||||
title?: string;
|
||||
text: ReactNode;
|
||||
};
|
||||
|
||||
export const NotificationContent = ({ title, text }: TNotification) => {
|
||||
return (
|
||||
<div className="msg-container">
|
||||
{title && <div className="text-md mb-1 font-medium">{title}</div>}
|
||||
<div className={title ? "text-sm" : "text-md"}>{text}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const createNotification = (
|
||||
myProps: TNotification & { type?: TypeOptions },
|
||||
toastProps: ToastOptions = {}
|
||||
): Id =>
|
||||
toast(<NotificationContent {...myProps} />, {
|
||||
position: "bottom-right",
|
||||
...toastProps,
|
||||
theme: "dark",
|
||||
type: myProps?.type || "info"
|
||||
});
|
||||
|
||||
export const NotificationContainer = () => <ToastContainer hideProgressBar />;
|
||||
@@ -0,0 +1 @@
|
||||
export { createNotification, NotificationContainer } from "./Notifications";
|
||||
Reference in New Issue
Block a user