@@ -2,34 +2,33 @@ import Route from '@ember/routing/route';
22import { inject as service } from '@ember/service' ;
33import fetch from 'fetch' ;
44import redirectAuth from '../utils/redirect-auth' ;
5- import { USER_STATES } from '../constants/user-status' ;
6- import { APPS } from '../constants/urls' ;
5+ import {
6+ STATUS_NOT_EXIST_FAILURE_MESSAGE ,
7+ USER_STATES ,
8+ } from '../constants/user-status' ;
79import { TOAST_OPTIONS } from '../constants/toast-options' ;
8- const BASE_URL = APPS . API_BACKEND ;
10+ import { ERROR_MESSAGES } from '../constants/error-messages' ;
11+ import { SELF_USER_STATUS_URL } from '../constants/apis' ;
912
1013export default class StatusRoute extends Route {
1114 @service toast ;
1215 @service router ;
1316
1417 async model ( ) {
1518 try {
16- const response = await fetch ( ` ${ BASE_URL } /users/status/self` , {
19+ const response = await fetch ( SELF_USER_STATUS_URL , {
1720 credentials : 'include' ,
1821 } ) ;
1922 const userData = await response . json ( ) ;
2023 if ( response . status === 200 ) {
2124 return userData ?. data ?. currentStatus ?. state ?? USER_STATES . DNE ;
2225 } else if ( response . status === 401 ) {
23- this . toast . error (
24- 'You are not logged in. Please login to continue.' ,
25- 'Error!' ,
26- TOAST_OPTIONS ,
27- ) ;
26+ this . toast . error ( ERROR_MESSAGES . notLoggedIn , 'Error!' , TOAST_OPTIONS ) ;
2827 // added setTimeout here because before new page opens user should be notified of error by toast
2928 setTimeout ( redirectAuth , 2000 ) ;
3029 } else if ( response . status === 404 ) {
3130 this . toast . error (
32- "Your Status data doesn't exist yet. Please choose your status from the options below." ,
31+ STATUS_NOT_EXIST_FAILURE_MESSAGE ,
3332 'Error!' ,
3433 TOAST_OPTIONS ,
3534 ) ;
0 commit comments