"use client" import { RestErrorResponse } from "@/back-api"; import { Toaster as ChakraToaster, Portal, Spinner, Stack, Toast, createToaster, } from "@chakra-ui/react" import { useCallback } from "react"; export const toaster = createToaster({ duration: 3000, placement: 'top-end', // offset: { top: '50px' }, // variant: 'solid', }) export const toasterAPIError = (error: RestErrorResponse) => { toaster.create({ title: `[${error.status}] ${error.statusMessage}`, description: error.message, }); }; export const Toaster = () => { return ( {(toast) => ( {toast.type === "loading" ? ( ) : ( )} {toast.title && {toast.title}} {toast.description && ( {toast.description} )} {toast.action && ( {toast.action.label} )} {toast.meta?.closable && } )} ) }