Skip to content

Commit f101b88

Browse files
Merge branch 'develop' into migrate/profile_view_PR-3
2 parents 0411c73 + 681bae2 commit f101b88

39 files changed

+1362
-128
lines changed

app/components/header.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
</LinkTo>
132132
<a
133133
data-test-dropdown-status
134-
href={{this.MY_STATUS_URL}}
134+
href={{if @dev "/status?dev=true" this.MY_STATUS_URL}}
135135
class="menu__link"
136136
rel="noopener noreferrer"
137137
target="_blank"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div class='identity-box-heading' data-test-blocked-heading>Status Blocked</div>
2+
<div class='identity-box-desc' data-test-blocked-desc>The system failed to link
3+
your profile service with the Identity service,
4+
<span class='identity-box-desc-bold'>Please try again!</span></div>
5+
<button
6+
class='identity-box-button'
7+
data-test-blocked-button type="button" {{on 'click' (fn @setState 'step1')}}
8+
>Retry</button>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div class='identity-box-heading' data-test-verified-heading>Verified</div>
2+
<div class='identity-box-desc' data-test-verified-desc><span
3+
class='identity-box-desc-bold'
4+
>Congratulations!!!</span>
5+
You did it, go ahead and tell in the community that you verified your profile
6+
service.</div>

app/components/user-status.hbs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{{#if @isStatusUpdating}}
2+
loading...
3+
{{else}}
4+
<div class="heading">
5+
{{#each this.currentUserStatus as |currentStatus|}}
6+
{{#if (eq @status currentStatus.status)}}
7+
{{#if (eq currentStatus.status "ONBOARDING")}}
8+
<div data-test-onboarding-details class="onboarding-details">
9+
<h2 data-test-status>You are undergoing onboarding</h2>
10+
<p data-test-details>
11+
If you are a Developer, please complete your submission for
12+
<a href="https://github.com/Real-Dev-Squad/lift-simulation">Lift
13+
Simulation</a>, and ask for doubts in the team chat on Discord.
14+
</p>
15+
<p data-test-details>If you are not a developer, please contact
16+
Ankush for next steps.</p>
17+
</div>
18+
{{else}}
19+
<h2 data-test-status>{{currentStatus.message}}</h2>
20+
{{/if}}
21+
{{/if}}
22+
{{/each}}
23+
</div>
24+
25+
<div class="buttons">
26+
{{#each this.currentUserStatus as |currentStatus|}}
27+
{{#if (eq @status currentStatus.status)}}
28+
{{#if @dev}}
29+
<button
30+
data-test-request-status-OOO
31+
class="buttons__request--ooo"
32+
type="button"
33+
{{on "click" this.changeStatus}}
34+
>
35+
<span>Request OOO Status</span>
36+
</button>
37+
{{else}}
38+
{{#if (eq currentStatus.status "OOO")}}
39+
<button
40+
data-test-cancel-status-OOO
41+
class="buttons__cancel--ooo"
42+
type="button"
43+
disabled={{@isStatusUpdating}}
44+
{{on "click" (fn this.cancelOOOStatus currentStatus.status)}}
45+
>
46+
<span>Cancel OOO</span>
47+
</button>
48+
{{else}}
49+
{{#each
50+
currentStatus.otherAvailableStatus
51+
as |otherPossibleStatus|
52+
}}
53+
<button
54+
data-test-update-status-OOO
55+
class={{otherPossibleStatus.class}}
56+
type="button"
57+
disabled={{@isStatusUpdating}}
58+
{{on "click" (fn this.changeStatus otherPossibleStatus.status)}}
59+
>
60+
<span>{{otherPossibleStatus.message}}</span>
61+
</button>
62+
{{/each}}
63+
{{/if}}
64+
{{/if}}
65+
{{/if}}
66+
{{/each}}
67+
</div>
68+
{{/if}}

app/components/user-status.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import Component from '@glimmer/component';
2+
import { action } from '@ember/object';
3+
import { USER_STATES } from '../constants/user-status';
4+
import { getUTCMidnightTimestampFromDate } from '../utils/date-conversion';
5+
6+
export default class UserStatusComponent extends Component {
7+
ALL_FEASIBLE_STATUS = {
8+
[USER_STATES.ACTIVE]: {
9+
status: USER_STATES.ACTIVE,
10+
message: 'Change your status to Active',
11+
class: 'buttons__active',
12+
},
13+
[USER_STATES.IDLE]: {
14+
status: USER_STATES.IDLE,
15+
message: 'Change your status to Idle',
16+
class: 'buttons__idle',
17+
},
18+
[USER_STATES.OOO]: {
19+
status: USER_STATES.OOO,
20+
message: 'Change your status to OOO',
21+
class: 'buttons__ooo',
22+
},
23+
};
24+
currentUserStatus = [
25+
{
26+
status: USER_STATES.ACTIVE,
27+
message: 'You are Active',
28+
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
29+
},
30+
{
31+
status: USER_STATES.IDLE,
32+
message: 'You are Idle',
33+
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
34+
},
35+
{
36+
status: USER_STATES.OOO,
37+
message: 'You are OOO',
38+
otherAvailableStatus: [],
39+
},
40+
{
41+
status: USER_STATES.ONBOARDING,
42+
},
43+
{
44+
status: USER_STATES.DNE,
45+
message: `Your Status doesn't exist`,
46+
otherAvailableStatus: [this.ALL_FEASIBLE_STATUS.OOO],
47+
},
48+
];
49+
50+
@action async changeStatus(status) {
51+
if (status === USER_STATES.ACTIVE) {
52+
const currentDate = new Date();
53+
const currentDateString = currentDate.toISOString().slice(0, 10);
54+
const from = getUTCMidnightTimestampFromDate(currentDateString);
55+
const updatedAt = Date.now();
56+
const activeStateData = {
57+
updatedAt,
58+
from,
59+
until: undefined,
60+
message: undefined,
61+
state: USER_STATES.ACTIVE,
62+
};
63+
await this.args.updateStatus({ currentStatus: activeStateData });
64+
} else {
65+
this.args.changeStatus(status);
66+
}
67+
}
68+
69+
@action async cancelOOOStatus(status) {
70+
if (status === USER_STATES.OOO) {
71+
await this.args.updateStatus({ cancelOoo: true });
72+
}
73+
}
74+
}

app/constants/profile-field.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export const profile_fields = [
2+
{
3+
id: 'first_name',
4+
label: 'First Name*',
5+
type: 'text',
6+
required: true,
7+
placeholder: 'First Name',
8+
icon_url: '/assets/icons/user.svg',
9+
showError: false,
10+
errorMessage: 'First name is required',
11+
},
12+
{
13+
id: 'last_name',
14+
label: 'Last Name*',
15+
type: 'text',
16+
required: true,
17+
placeholder: 'Last Name',
18+
icon_url: '/assets/icons/user.svg',
19+
showError: false,
20+
errorMessage: 'Last name is required',
21+
},
22+
{
23+
id: 'company',
24+
label: 'Company or College name*',
25+
type: 'text',
26+
required: true,
27+
placeholder: 'e.g Google or Dr. Kalam University',
28+
icon_url: '/assets/icons/company.svg',
29+
showError: false,
30+
errorMessage: 'Company name is required',
31+
},
32+
{
33+
id: 'designation',
34+
label: 'Designation*',
35+
type: 'text',
36+
required: true,
37+
placeholder: 'e.g SDE - 2 or 3rd Year CSE Student',
38+
icon_url: '/assets/icons/user.svg',
39+
showError: false,
40+
errorMessage: 'Designation is required',
41+
},
42+
{
43+
id: 'linkedin_id',
44+
label: 'LinkedIn ID*',
45+
type: 'text',
46+
required: true,
47+
placeholder: 'e.g johndoe',
48+
icon_url: '/assets/icons/linkedin.svg',
49+
showError: false,
50+
errorMessage: 'Linkedin handle is required',
51+
},
52+
{
53+
id: 'twitter_id',
54+
label: 'Twitter Username*',
55+
type: 'text',
56+
required: true,
57+
placeholder: 'e.g johndoe',
58+
icon_url: '/assets/icons/twitter.svg',
59+
showError: false,
60+
errorMessage: 'Twitter handle is required',
61+
},
62+
{
63+
id: 'website',
64+
label: 'Personal Website',
65+
type: 'text',
66+
required: false,
67+
placeholder: 'e.g mysite.com',
68+
icon_url: '/assets/icons/website.svg',
69+
showError: false,
70+
errorMessage: '',
71+
},
72+
];

app/constants/user-status.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const WARNING_MESSAGE_FOR_FROM_FIELD = 'From field is mandatory.';
2+
export const WARNING_MESSAGE_FOR_UNTIL_FIELD = 'Until field is mandatory.';
3+
export const WARNING_MESSAGE_FOR_OOO =
4+
'The Reason Field is mandatory. Please mention the reason for going OOO.';
5+
export const WARNING_MESSAGE_FOR_IDLE =
6+
'The Missing Skills Field is mandatory. Please mention the skills you are lagging in.';
7+
export const USER_STATES = {
8+
IDLE: 'IDLE',
9+
ACTIVE: 'ACTIVE',
10+
OOO: 'OOO',
11+
ONBOARDING: 'ONBOARDING',
12+
DNE: 'DNE',
13+
};
14+
export const WARNING_INVALID_NEW_ETA =
15+
'The newEndsOn value cannot be smaller than the oldEndsOn value';
16+
export const WARNING_FROM_DATE_EXCEEDS_UNTIL_DATE =
17+
'Until date cant lie before the From date. Please recheck the dates again.';
18+
export const THREE_DAYS_TIME_DIFFERENCE_MS = 172800000;
19+
export const FROM_DATE = 'fromDate';
20+
export const UNTIL_DATE = 'untilDate';
21+
export const REASON = 'reason';

app/controllers/discord.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Controller from '@ember/controller';
2+
import { TOAST_OPTIONS } from '../constants/toast-options';
3+
import { APPS } from '../constants/urls';
4+
import { inject as service } from '@ember/service';
5+
import { tracked } from '@glimmer/tracking';
6+
import { action } from '@ember/object';
7+
8+
export default class DiscordController extends Controller {
9+
queryParams = ['token'];
10+
@service router;
11+
@service toast;
12+
@tracked discordId =
13+
this.model.externalAccountData.attributes.discordId || '';
14+
@tracked linkStatus = 'not-linked';
15+
@tracked isLinkingInProgress = false;
16+
@tracked consent = false;
17+
@tracked token = '';
18+
19+
async model() {
20+
this.token = this.paramsFor('discord').token;
21+
}
22+
@action setConsent() {
23+
this.consent = !this.consent;
24+
}
25+
26+
@action async linkDiscordAccount() {
27+
if (!this.consent) {
28+
this.toast.error(
29+
'Please provide consent by checking the checkbox',
30+
'ERROR',
31+
TOAST_OPTIONS,
32+
);
33+
return;
34+
}
35+
36+
try {
37+
this.isLinkingInProgress = true;
38+
39+
const response = await fetch(
40+
`${APPS.API_BACKEND}/external-accounts/link/${this.token}`,
41+
{
42+
method: 'PATCH',
43+
headers: {
44+
'Content-Type': 'application/json',
45+
},
46+
credentials: 'include',
47+
},
48+
);
49+
50+
this.linkStatus = response.status === 204 ? 'linked' : 'failure';
51+
} catch (error) {
52+
this.linkStatus = 'failure';
53+
console.error('Failed to link Discord account:', error.message);
54+
} finally {
55+
this.isLinkingInProgress = false;
56+
}
57+
}
58+
}

app/controllers/identity.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ export default class IdentityController extends Controller {
1818
}
1919

2020
get initialState() {
21-
if (this.userData?.profileStatus === 'PENDING') {
22-
return 'reload';
23-
} else if (this.userData?.profileStatus === 'VERIFIED') {
24-
return 'verified';
25-
} else if (this.userData?.profileStatus === 'BLOCKED') {
26-
return 'blocked';
21+
const profileStatus = this.model?.profileStatus;
22+
switch (profileStatus) {
23+
case 'PENDING':
24+
return 'reload';
25+
case 'VERIFIED':
26+
return 'verified';
27+
case 'BLOCKED':
28+
return 'blocked';
29+
default:
30+
return 'getStarted';
2731
}
28-
return 'getStarted';
2932
}
3033

3134
@action

0 commit comments

Comments
 (0)