diff --git a/packages/ui/components/toast/showToast.tsx b/packages/ui/components/toast/showToast.tsx
index 16b43a9f5b..3a1d17a737 100644
--- a/packages/ui/components/toast/showToast.tsx
+++ b/packages/ui/components/toast/showToast.tsx
@@ -6,14 +6,16 @@ import { Check, Info } from "../icon";
type IToast = {
message: string;
toastVisible: boolean;
+ onClose: () => void;
};
-export const SuccessToast = ({ message, toastVisible }: IToast) => (
+export const SuccessToast = ({ message, toastVisible, onClose }: IToast) => (
+ toastVisible && "animate-fade-in-up cursor-pointer"
+ )}
+ onClick={onClose}>
@@ -21,12 +23,13 @@ export const SuccessToast = ({ message, toastVisible }: IToast) => (
);
-export const ErrorToast = ({ message, toastVisible }: IToast) => (
+export const ErrorToast = ({ message, toastVisible, onClose }: IToast) => (
+ toastVisible && "animate-fade-in-up cursor-pointer"
+ )}
+ onClick={onClose}>
@@ -34,12 +37,13 @@ export const ErrorToast = ({ message, toastVisible }: IToast) => (
);
-export const WarningToast = ({ message, toastVisible }: IToast) => (
+export const WarningToast = ({ message, toastVisible, onClose }: IToast) => (
+ toastVisible && "animate-fade-in-up cursor-pointer"
+ )}
+ onClick={onClose}>
@@ -47,12 +51,13 @@ export const WarningToast = ({ message, toastVisible }: IToast) => (
);
-export const DefaultToast = ({ message, toastVisible }: IToast) => (
+export const DefaultToast = ({ message, toastVisible, onClose }: IToast) => (
+ toastVisible && "animate-fade-in-up cursor-pointer"
+ )}
+ onClick={onClose}>
@@ -67,14 +72,29 @@ export function showToast(
variant: "success" | "warning" | "error",
duration = TOAST_VISIBLE_DURATION
) {
+ const onClose = () => {
+ toast.dismiss();
+ };
switch (variant) {
case "success":
- return toast.custom((t) => , { duration });
+ return toast.custom(
+ (t) => ,
+ { duration }
+ );
case "error":
- return toast.custom((t) => , { duration });
+ return toast.custom(
+ (t) => ,
+ { duration }
+ );
case "warning":
- return toast.custom((t) => , { duration });
+ return toast.custom(
+ (t) => ,
+ { duration }
+ );
default:
- return toast.custom((t) => , { duration });
+ return toast.custom(
+ (t) => ,
+ { duration }
+ );
}
}