diff --git a/apps/client/src/services/toast.ts b/apps/client/src/services/toast.ts index abbbfff42..3e81bf6e1 100644 --- a/apps/client/src/services/toast.ts +++ b/apps/client/src/services/toast.ts @@ -9,6 +9,10 @@ export interface ToastOptions { message: string; timeout?: number; progress?: number; + buttons?: { + text: string; + onClick: (api: { dismissToast: () => void }) => void; + }[]; } export type ToastOptionsWithRequiredId = Omit & Required>; diff --git a/apps/client/src/widgets/Toast.tsx b/apps/client/src/widgets/Toast.tsx index 62bfe78fd..9630836e1 100644 --- a/apps/client/src/widgets/Toast.tsx +++ b/apps/client/src/widgets/Toast.tsx @@ -6,6 +6,7 @@ import { useEffect } from "preact/hooks"; import { removeToastFromStore, ToastOptionsWithRequiredId, toasts } from "../services/toast"; import Icon from "./react/Icon"; import { RawHtmlBlock } from "./react/RawHtml"; +import Button from "./react/Button"; export default function ToastContainer() { return ( @@ -15,7 +16,7 @@ export default function ToastContainer() { ) } -function Toast({ id, title, timeout, progress, message, icon }: ToastOptionsWithRequiredId) { +function Toast({ id, title, timeout, progress, message, icon, buttons }: ToastOptionsWithRequiredId) { // Autohide. useEffect(() => { if (!timeout || timeout <= 0) return; @@ -23,10 +24,14 @@ function Toast({ id, title, timeout, progress, message, icon }: ToastOptionsWith return () => clearTimeout(timerId); }, [ id, timeout ]); + function dismissToast() { + removeToastFromStore(id); + } + const closeButton = (