Skip to content

Commit

Permalink
refactor: use new toast options
Browse files Browse the repository at this point in the history
  • Loading branch information
MayankBansal12 committed Jan 20, 2025
1 parent d7a22ca commit 5d820e0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/routes/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { inject as service } from '@ember/service';
import fetch from 'fetch';
import redirectAuth from '../utils/redirect-auth';
import { USER_STATES } from '../constants/user-status';
import { toastNotificationTimeoutOptions } from '../constants/toast-notification';
import { APPS } from '../constants/urls';
import { TOAST_OPTIONS } from '../constants/toast-options';
const BASE_URL = APPS.API_BACKEND;

export default class StatusRoute extends Route {
Expand All @@ -26,21 +26,26 @@ export default class StatusRoute extends Route {
} else if (response.status === 401) {
this.toast.error(
'You are not logged in. Please login to continue.',
'',
toastNotificationTimeoutOptions,
'Error!',
TOAST_OPTIONS,
);
// added setTimeout here because before new page opens user should be notified of error by toast
setTimeout(redirectAuth, 2000);
} else if (response.status === 404) {
this.toast.error(
"Your Status data doesn't exist yet. Please choose your status from the options below.",
'',
toastNotificationTimeoutOptions,
'Error!',
TOAST_OPTIONS,
);
return USER_STATES.DNE;
}
} catch (error) {
console.error(error.message);
this.toast.error(
'Something went wrong. ' + error.message,
'Error!',
TOAST_OPTIONS,
);
}
}
}

0 comments on commit 5d820e0

Please sign in to comment.