Skip to content

Commit e3748a7

Browse files
Merge branch 'develop' into chore/mobile-feature-flag
2 parents b484b0e + 51ce6a4 commit e3748a7

File tree

10 files changed

+25
-47
lines changed

10 files changed

+25
-47
lines changed

app/components/spinner.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<i class="fa fa-spinner fa-spin spinner" ...attributes></i>
1+
<i class="fa fa-spinner fa-spin" ...attributes></i>

app/components/user-status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default class UserStatusComponent extends Component {
7070

7171
@action async cancelOOOStatus(status) {
7272
if (status === USER_STATES.OOO) {
73-
await this.args.updateStatus({ cancelOOOStatus: true });
73+
await this.args.updateStatus({ cancelOoo: true });
7474
}
7575
}
7676
}

app/constants/apis.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export const APPLICATION_ID_LINK = (id) => {
1818
return `${APPS.DASHBOARD}/applications/?id=${id}`;
1919
};
2020

21+
export const SELF_USER_STATUS_URL = `${APPS.API_BACKEND}/users/status/self`;
22+
2123
export const UPDATE_USER_STATUS = `${APPS.API_BACKEND}/users/status/self?userStatusFlag=true`;
2224

2325
export const UPDATE_USER_STATUS_FOR_DEV = `${APPS.API_BACKEND}/requests?dev=true`;

app/constants/user-status.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const FUTURE_STATUS_UPDATE_SUCCESS =
1010
'Future status updated successfully.';
1111
export const STATUS_UPDATE_FAILURE_MESSAGE =
1212
'Status Update failed. Something went wrong.';
13+
export const STATUS_NOT_EXIST_FAILURE_MESSAGE =
14+
"Your Status data doesn't exist yet. Please choose your status from the options below.";
1315
export const OOO_STATUS_REQUEST_FAILURE_MESSAGE =
1416
'OOO status request failed. Something went wrong.';
1517
export const USER_STATES = {

app/controllers/status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class StatusController extends Controller {
3131

3232
@action async updateStatus(newStatus) {
3333
this.isStatusUpdating = true;
34-
if (!('cancelOOOStatus' in newStatus)) {
34+
if (!('cancelOoo' in newStatus)) {
3535
if (newStatus.currentStatus.state !== USER_STATES.ACTIVE) {
3636
this.toggleUserStateModal();
3737
}

app/routes/status.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,33 @@ import Route from '@ember/routing/route';
22
import { inject as service } from '@ember/service';
33
import fetch from 'fetch';
44
import 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';
79
import { 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

1013
export 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
);

app/styles/app.css

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -101,31 +101,10 @@ button {
101101
}
102102

103103
.loading {
104+
width: 100%;
105+
height: 70vh;
104106
display: flex;
105-
flex-direction: column;
106107
justify-content: center;
107108
align-items: center;
108-
height: 90vh;
109-
width: 100%;
110-
text-align: center;
111-
}
112-
113-
.spinner {
114-
display: inline-block;
115-
width: 1.875 rem;
116-
height: 1.875 rem;
117-
border: 4px solid rgb(0 0 0 / 30%);
118-
border-radius: 50%;
119-
border-top: 4px solid var(--color-black);
120-
animation: spin 1s linear infinite;
121-
}
122-
123-
@keyframes spin {
124-
0% {
125-
transform: rotate(0deg);
126-
}
127-
128-
100% {
129-
transform: rotate(360deg);
130-
}
109+
font-size: 2rem;
131110
}

tests/integration/components/user-status-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ module('Integration | Component | user-status', function (hooks) {
7777
isStatusUpdating: false,
7878
changeStatus: () => {},
7979
updateStatus: (cancelOOOPayload) => {
80-
const { cancelOOOStatus } = cancelOOOPayload;
81-
assert.true(cancelOOOStatus, 'cancel OOO status');
80+
const { cancelOoo } = cancelOOOPayload;
81+
assert.true(cancelOoo, 'cancel OOO status');
8282
},
8383
});
8484
await render(hbs`

tests/unit/controllers/status-test.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { setupTest } from 'website-www/tests/helpers';
33
import { USER_STATES } from 'website-www/constants/user-status';
44
import Service from '@ember/service';
55
import sinon from 'sinon';
6-
import { APPS } from 'website-www/constants/urls';
7-
const API_BASE_URL = APPS.API_BACKEND;
6+
import { UPDATE_USER_STATUS } from 'website-www/constants/apis';
87

98
class MockToastService extends Service {
109
success() {}
@@ -60,9 +59,7 @@ module('Unit | Controller | status', function (hooks) {
6059

6160
assert.ok(this.fetchStub.calledOnce, 'Fetch was called once');
6261
assert.ok(
63-
this.fetchStub.calledWith(
64-
`${API_BASE_URL}/users/status/self?userStatusFlag=true`,
65-
),
62+
this.fetchStub.calledWith(UPDATE_USER_STATUS),
6663
'Fetch was called with the correct URL',
6764
);
6865
});

tests/unit/routes/status-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { module, test } from 'qunit';
22
import { setupTest } from 'website-www/tests/helpers';
33
import sinon from 'sinon';
44
import { USER_STATES } from 'website-www/constants/user-status';
5-
import { APPS } from 'website-www/constants/urls';
6-
const API_BASE_URL = APPS.API_BACKEND;
5+
import { SELF_USER_STATUS_URL } from 'website-www/constants/apis';
76

87
module('Unit | Route | status', function (hooks) {
98
setupTest(hooks);
@@ -38,7 +37,7 @@ module('Unit | Route | status', function (hooks) {
3837
const result = await this.route.model();
3938

4039
assert.ok(
41-
this.fetchStub.calledOnceWith(`${API_BASE_URL}/users/status/self`),
40+
this.fetchStub.calledOnceWith(SELF_USER_STATUS_URL),
4241
'Fetch called with correct URL',
4342
);
4443
assert.strictEqual(result, userStatus, 'Returns the user status from API');

0 commit comments

Comments
 (0)