fix: text split try catch

This commit is contained in:
Ibrahima G. Coulibaly
2024-06-21 22:35:56 +01:00
parent 8b58361e1f
commit 94aa86e4db
7 changed files with 161 additions and 57 deletions

View File

@@ -0,0 +1,35 @@
import { createContext, FC, ReactNode } from 'react';
import { Zoom } from '@mui/material';
import { useSnackbar } from 'notistack';
type CustomSnackBarContext = {
showSnackBar: (message: string, type: 'error' | 'success') => void;
};
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const CustomSnackBarContext = createContext<CustomSnackBarContext>(
{} as CustomSnackBarContext
);
interface Props {
children: ReactNode;
}
export const CustomSnackBarProvider: FC<Props> = ({ children }) => {
const { enqueueSnackbar } = useSnackbar();
const showSnackBar = (message: string, type: 'error' | 'success') => {
enqueueSnackbar(message, {
variant: type,
anchorOrigin: {
vertical: 'top',
horizontal: 'right'
},
TransitionComponent: Zoom
});
};
return (
<CustomSnackBarContext.Provider value={{ showSnackBar }}>
{children}
</CustomSnackBarContext.Provider>
);
};