feat(client): Toast Provider to show Toasts from higher on the DOM tree (#1110)

This commit is contained in:
Danny Avila 2023-10-27 17:10:07 -04:00 committed by GitHub
parent 81a90d245b
commit 5cafe0900c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 11 deletions

View file

@ -0,0 +1,17 @@
import { createContext } from 'react';
import type { TShowToast } from '~/common';
import { useToast } from '~/hooks';
type ToastContextType = {
showToast: ({ message, severity, showIcon }: TShowToast) => void;
};
export const ToastContext = createContext<ToastContextType>({
showToast: () => ({}),
});
export default function ToastProvider({ children }) {
const { showToast } = useToast();
return <ToastContext.Provider value={{ showToast }}>{children}</ToastContext.Provider>;
}

View file

@ -0,0 +1,2 @@
export { default as ToastProvider } from './ToastContext';
export * from './ToastContext';