Skip to content

Commit 402956c

Browse files
committed
fix(profile): fix profile select spec & validation for achievements fields
1 parent c1ca3d6 commit 402956c

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

projects/social_platform/src/app/api/profile/facades/edit/profile-edit-achievements-info.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export class ProfileEditAchievementsInfoService {
5050
);
5151
["title", "status", "year"].forEach(name => this.profileForm.get(name)?.markAsTouched());
5252

53+
const hasInvalid = ["title", "status", "year"].some(
54+
name => this.profileForm.get(name)?.invalid,
55+
);
56+
if (hasInvalid) return;
57+
5358
const achievementsYear =
5459
typeof this.profileForm.get("year")?.value === "string"
5560
? +this.profileForm.get("year")?.value.slice(0, 5)

projects/social_platform/src/app/api/profile/facades/edit/profile-edit-info.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class ProfileEditInfoService {
143143
const achievements = this.achievements.value.map((achievement: Achievement) => ({
144144
...(achievement.id && { id: achievement.id }),
145145
title: achievement.title,
146-
status: achievement.status,
146+
...(achievement.status ? { status: achievement.status } : {}),
147147
year: achievement.year,
148148
fileLinks:
149149
achievement.files && Array.isArray(achievement.files)
@@ -221,7 +221,13 @@ export class ProfileEditInfoService {
221221

222222
if (body.phone_number) return body.phone_number[0];
223223
if (body.language) return body.language;
224-
if (body.achievements) return body.achievements[0];
224+
if (body.achievements) {
225+
const err = body.achievements[0];
226+
if (typeof err === "string") return err;
227+
const key = Object.keys(err)[0];
228+
const val = err[key];
229+
return Array.isArray(val) ? val[0] : String(val);
230+
}
225231
if (body.work_experience?.[2]) {
226232
return body.work_experience[2].entry_year ?? body.work_experience[2].completion_year;
227233
}

projects/social_platform/src/app/ui/pages/profile/edit/edit.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export class ProfileEditComponent implements OnInit, AfterViewInit {
234234
}
235235

236236
onSelectSpec(speciality: Specialization): void {
237-
this.onboardingStageOneInfoService.onSelectSpec(speciality);
237+
this.searchesService.onSelectSpec(this.profileForm, speciality);
238238
}
239239

240240
onToggleSkill(toggledSkill: Skill): void {

0 commit comments

Comments
 (0)