import { CopyIcon, DoneIcon, OpenInNewIcon, TooltipIcon } from "@/icons"; import { defaultTheme } from "@/lib"; import { copyToClipboard, openInNewTab } from "@/utils"; import ActionIconWrapper from "../ActionIconWrapper"; import FlexContainer from "../FlexContainer"; import LogoViewer from "../LogoViewer"; import Typography, { TTypographyType } from "../Typography"; import * as S from "./styles"; import Spinner from "../Spinner"; const TOAST_TYPE_MAPPING: Record< ToastType, { color: string; icon: React.ReactNode } > = { default: { color: defaultTheme.colors.gray400, icon: }, success: { color: defaultTheme.colors.success, icon: }, error: { color: defaultTheme.colors.error, icon: , }, warning: { color: defaultTheme.colors.warning, icon: }, loading: { color: defaultTheme.colors.gray700, icon: , }, }; type ToastType = "default" | "success" | "warning" | "error" | "loading"; export type ToastProps = { title: string; customIcon?: React.ReactNode | string; type?: ToastType; textToCopy?: string; link?: string; description?: { value?: React.ReactNode | string; type?: TTypographyType; color?: string; }; }; export default function Toast({ title, description, customIcon, textToCopy, link, type = "default", }: ToastProps) { const copyHandler = (e: React.MouseEvent) => { e?.stopPropagation(); copyToClipboard(textToCopy); }; return ( {title} {description?.value && (typeof description.value === "string" ? ( {description.value} ) : ( description.value ))} {link && ( openInNewTab(link)} size="L"> )} {textToCopy && ( )} ); }