Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added onClose functio to toast #13087

5 changes: 4 additions & 1 deletion frontend/packages/shared/src/contexts/ServicesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ const handleError = (
const errorCode = error?.response?.data?.errorCode;
const unAuthorizedErrorCode = error?.response?.status === ServerCodes.Unauthorized;

const LogOutUser = () => logout().then(() => window.location.assign(userLogoutAfterPath()));

if (unAuthorizedErrorCode) {
renderToast(errorCode || 'Unauthorized', {
onClose: LogOutUser,
autoClose: LOG_OUT_TIMER_MS,
});
setTimeout(() => {
logout().then(() => window.location.assign(userLogoutAfterPath()));
LogOutUser();
}, LOG_OUT_TIMER_MS);
return;
}
Expand Down