request list + structure
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
interface Toast {
|
||||
id: string;
|
||||
message: string;
|
||||
type?: "success" | "error" | "info";
|
||||
isExiting?: boolean;
|
||||
}
|
||||
|
||||
let addToast: (toast: Toast) => void;
|
||||
|
||||
export const toast = (
|
||||
message?: string,
|
||||
type: "success" | "error" | "info" = "info"
|
||||
) => {
|
||||
if (addToast) {
|
||||
addToast({ id: Date.now().toString(), message: message || "", type });
|
||||
}
|
||||
};
|
||||
|
||||
export const setAddToast = (fn: (toast: Toast) => void) => {
|
||||
addToast = fn;
|
||||
};
|
||||
Reference in New Issue
Block a user