Fix order locale and remake Zod def of ErrorApi

This commit is contained in:
CEC
2022-04-21 14:16:18 +02:00
parent 711832bc3a
commit bc17b86ce4
7 changed files with 95 additions and 39 deletions
+5 -5
View File
@@ -49,11 +49,11 @@ export class EntryScene extends Scene {
.catch((err) => {
const errorType = isErrorApiData.safeParse(err?.response?.data);
if (errorType.success) {
// If error from API and urlToRedirect is specified but not buttonTitle => redirect directly
if (!errorType.data.buttonTitle && errorType.data.urlToRedirect) {
if (errorType.data.urlToRedirect === "/login") void connectionManager.logout();
else window.location.assign(errorType.data.urlToRedirect);
} else errorScreenStore.setError(err.response.data);
if (errorType.data.type === 'unauthorized') {
void connectionManager.logout();
} else if (errorType.data.type === 'redirect') {
window.location.assign(errorType.data.urlToRedirect);
} else errorScreenStore.setError(err?.response?.data);
} else {
ErrorScene.showError(err, this.scene);
}