Skip to content

Commit 032a1a6

Browse files
Merge branch 'develop' into feat/image-upload
2 parents 3a396b7 + 52e48cf commit 032a1a6

36 files changed

Lines changed: 890 additions & 377 deletions

app/components/application/detail-header.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
@text="Edit"
7373
@variant="light"
7474
@class="btn--xs"
75+
@disabled={{this.isEditDisabled}}
7576
@onClick={{this.editApplication}}
7677
@test="edit-button"
7778
/>

app/components/application/detail-header.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,21 @@ import { TOAST_OPTIONS } from '../../constants/toast-options';
66
import { NUDGE_APPLICATION_URL } from '../../constants/apis';
77
import apiRequest from '../../utils/api-request';
88

9+
const TWENTY_FOUR_HOURS = 24 * 60 * 60 * 1000;
10+
11+
function isWithinCooldown(timestamp, cooldownMs = TWENTY_FOUR_HOURS) {
12+
if (!timestamp) {
13+
return false;
14+
}
15+
16+
const now = Date.now();
17+
const time = new Date(timestamp).getTime();
18+
19+
return now - time < cooldownMs;
20+
}
21+
922
export default class DetailHeader extends Component {
23+
@service router;
1024
@service toast;
1125

1226
@tracked isLoading = false;
@@ -56,17 +70,22 @@ export default class DetailHeader extends Component {
5670
return this.args.lastNudgeAt ?? this.application?.lastNudgeAt ?? null;
5771
}
5872

73+
get lastEditAt() {
74+
return this.application?.lastEditAt ?? null;
75+
}
76+
5977
get isNudgeDisabled() {
6078
if (this.isLoading || this.status !== 'pending') {
6179
return true;
6280
}
63-
if (!this.lastNudgeAt) {
64-
return false;
81+
return isWithinCooldown(this.lastNudgeAt);
82+
}
83+
84+
get isEditDisabled() {
85+
if (this.isLoading) {
86+
return true;
6587
}
66-
const now = Date.now();
67-
const lastNudgeTime = new Date(this.lastNudgeAt).getTime();
68-
const TWENTY_FOUR_HOURS = 24 * 60 * 60 * 1000;
69-
return now - lastNudgeTime < TWENTY_FOUR_HOURS;
88+
return isWithinCooldown(this.lastEditAt);
7089
}
7190

7291
get socialLinks() {
@@ -129,13 +148,17 @@ export default class DetailHeader extends Component {
129148

130149
@action
131150
editApplication() {
132-
//ToDo: Implement logic for edit application here
133-
console.log('edit application');
151+
this.router.transitionTo('join', {
152+
queryParams: {
153+
edit: true,
154+
dev: true,
155+
step: 1,
156+
},
157+
});
134158
}
135159

136160
@action
137161
navigateToDashboard() {
138-
//ToDo: Navigate to dashboard site for admin actions
139-
console.log('navigate to dashboard');
162+
this.router.transitionTo(`/intro?id=${this.userDetails?.id}`);
140163
}
141164
}

app/components/new-join-steps/base-step.js

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,85 @@
11
import { action } from '@ember/object';
22
import Component from '@glimmer/component';
3+
import { service } from '@ember/service';
34
import { tracked } from '@glimmer/tracking';
45
import { debounceTask, runTask } from 'ember-lifeline';
56
import { JOIN_DEBOUNCE_TIME } from '../../constants/join';
7+
import { USER_ROLE_MAP } from '../../constants/new-join-form';
68
import { validateWordCount } from '../../utils/validator';
79
import { getLocalStorageItem, setLocalStorageItem } from '../../utils/storage';
810

911
export default class BaseStepComponent extends Component {
12+
@service onboarding;
13+
1014
stepValidation = {};
1115

1216
@tracked data = {};
1317
@tracked errorMessage = {};
1418
@tracked wordCount = {};
1519

16-
get storageKey() {
17-
return '';
18-
}
19-
2020
postLoadInitialize() {}
2121

22+
STEP_FORM_DATA_MAPPING = {
23+
newStepOneData: (app) => ({
24+
firstName: app.biodata?.firstName || '',
25+
lastName: app.biodata?.lastName || '',
26+
city: app.location?.city || '',
27+
state: app.location?.state || '',
28+
country: app.location?.country || '',
29+
role:
30+
Object.keys(USER_ROLE_MAP).find(
31+
(key) => USER_ROLE_MAP[key] === app.role,
32+
) || '',
33+
imageUrl: app.imageUrl || '',
34+
}),
35+
newStepTwoData: (app) => ({
36+
institution: app.professional?.institution || '',
37+
skills: app.professional?.skills || '',
38+
introduction: app.intro?.introduction || '',
39+
}),
40+
newStepThreeData: (app) => ({
41+
forFun: app.intro?.forFun || '',
42+
funFact: app.intro?.funFact || '',
43+
}),
44+
newStepFourData: (app) => ({
45+
phoneNo: app.socialLink?.phoneNo || '',
46+
twitter: app.socialLink?.twitter || '',
47+
linkedin: app.socialLink?.linkedin || '',
48+
instagram: app.socialLink?.instagram || '',
49+
github: app.socialLink?.github || '',
50+
peerlist: app.socialLink?.peerlist || '',
51+
behance: app.socialLink?.behance || '',
52+
dribble: app.socialLink?.dribble || '',
53+
}),
54+
newStepFiveData: (app) => ({
55+
whyRds: app.intro?.whyRds || '',
56+
foundFrom: app.foundFrom || '',
57+
numberOfHours: app.intro?.numberOfHours || '',
58+
}),
59+
};
60+
2261
constructor(...args) {
2362
super(...args);
2463
this.initializeFormState();
2564
}
2665

2766
initializeFormState() {
28-
let saved = {};
29-
try {
30-
const stored = getLocalStorageItem(this.storageKey, '{}');
31-
saved = stored ? JSON.parse(stored) : {};
32-
} catch (e) {
33-
console.warn('Failed to parse stored form data:', e);
34-
saved = {};
67+
const storedData = getLocalStorageItem(this.storageKey, '{}');
68+
let initialFormData = storedData ? JSON.parse(storedData) : {};
69+
70+
if (
71+
Object.keys(initialFormData).length === 0 &&
72+
this.onboarding.applicationData
73+
) {
74+
const stepDataMapper = this.STEP_FORM_DATA_MAPPING[this.storageKey];
75+
76+
if (stepDataMapper) {
77+
initialFormData = stepDataMapper(this.onboarding.applicationData);
78+
setLocalStorageItem(this.storageKey, JSON.stringify(initialFormData));
79+
}
3580
}
36-
this.data = saved;
81+
82+
this.data = initialFormData;
3783

3884
this.errorMessage = Object.fromEntries(
3985
Object.keys(this.stepValidation).map((k) => [k, '']),

app/components/new-join-steps/new-step-five.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
import { heardFrom } from '../../constants/social-data';
77

88
export default class NewStepFiveComponent extends BaseStepComponent {
9-
storageKey = STEP_DATA_STORAGE_KEY.stepFive;
9+
get storageKey() {
10+
return STEP_DATA_STORAGE_KEY.stepFive;
11+
}
1012
heardFrom = heardFrom;
1113

1214
stepValidation = {

app/components/new-join-steps/new-step-four.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
import { phoneNumberRegex } from '../../constants/regex';
77

88
export default class NewStepFourComponent extends BaseStepComponent {
9-
storageKey = STEP_DATA_STORAGE_KEY.stepFour;
9+
get storageKey() {
10+
return STEP_DATA_STORAGE_KEY.stepFour;
11+
}
1012

1113
stepValidation = {
1214
phoneNo: NEW_STEP_LIMITS.stepFour.phoneNo,

app/components/new-join-steps/new-step-six.hbs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,13 @@
9191
<span class="review-field__label">Institution/Company:</span>
9292
<span
9393
class="review-field__value
94-
{{unless this.stepData.two.college 'review-field__value--missing'}}"
94+
{{unless
95+
this.stepData.two.institution
96+
'review-field__value--missing'
97+
}}"
9598
>
96-
{{#if this.stepData.two.college}}
97-
{{this.stepData.two.college}}
99+
{{#if this.stepData.two.institution}}
100+
{{this.stepData.two.institution}}
98101
{{else}}
99102
Not provided
100103
{{/if}}

app/components/new-join-steps/new-step-three.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {
55
} from '../../constants/new-join-form';
66

77
export default class NewStepThreeComponent extends BaseStepComponent {
8-
storageKey = STEP_DATA_STORAGE_KEY.stepThree;
8+
get storageKey() {
9+
return STEP_DATA_STORAGE_KEY.stepThree;
10+
}
911
stepValidation = {
1012
forFun: NEW_STEP_LIMITS.stepThree.forFun,
1113
funFact: NEW_STEP_LIMITS.stepThree.funFact,

app/components/new-join-steps/new-step-two.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
<div class="form-grid__item">
2828
<Reusables::InputBox
2929
@field="Your institution/company"
30-
@name="college"
30+
@name="institution"
3131
@placeHolder="Institution or company name"
3232
@type="text"
3333
@required={{true}}
34-
@value={{this.data.college}}
34+
@value={{this.data.institution}}
3535
@onInput={{this.inputHandler}}
3636
/>
37-
{{#if this.errorMessage.college}}
37+
{{#if this.errorMessage.institution}}
3838
<div
3939
class="error__message"
40-
data-test-error="college"
41-
>{{this.errorMessage.college}}</div>
40+
data-test-error="institution"
41+
>{{this.errorMessage.institution}}</div>
4242
{{/if}}
4343
</div>
4444
</div>

app/components/new-join-steps/new-step-two.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import {
55
} from '../../constants/new-join-form';
66

77
export default class NewStepTwoComponent extends BaseStepComponent {
8-
storageKey = STEP_DATA_STORAGE_KEY.stepTwo;
8+
get storageKey() {
9+
return STEP_DATA_STORAGE_KEY.stepTwo;
10+
}
911
stepValidation = {
1012
skills: NEW_STEP_LIMITS.stepTwo.skills,
11-
college: NEW_STEP_LIMITS.stepTwo.college,
13+
institution: NEW_STEP_LIMITS.stepTwo.institution,
1214
introduction: NEW_STEP_LIMITS.stepTwo.introduction,
1315
};
1416
}

app/components/new-signup/checkbox.hbs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
data-test-checkbox-label={{data.name}}
1111
>
1212
<input
13-
type="checkbox"
14-
name={{data.name}}
15-
checked={{false}}
16-
{{on "change" this.checkboxFieldChanged}}
13+
type="radio"
14+
name="role"
15+
value={{data.name}}
16+
checked={{eq @signupDetails.role data.name}}
17+
{{on "change" (fn this.checkboxFieldChanged data.name)}}
1718
class="user-details__checkbox-input"
1819
data-test-checkbox-input={{data.name}}
1920
/>

0 commit comments

Comments
 (0)