{props.variant === Variant.success ? (
) : props.variant === Variant.warning ? (
) : null}
{props.variant === Variant.danger ? (
) : null}
{props.text}
{props.onUndo || props.dispatchableAction ? (
{
if (props.dispatchableAction) {
dispatch(props.dispatchableAction);
props.undoAction && props.undoAction();
} else {
props.undoAction && props.undoAction();
}
}}
>
UNDO
) : null}
);
};
export const Toaster = {
show: (config: ToastProps) => {
if (typeof config.text !== "string") {
console.error("Toast message needs to be a string");
return;
}
if (config.variant && !Object.values(Variant).includes(config.variant)) {
console.error(
"Toast type needs to be a one of " + Object.values(Variant).join(", "),
);
return;
}
// Stringified JSON is a long, but valid key :shrug:
const toastId = JSON.stringify(config);
toast(