Skip to content

Commit 6f77105

Browse files
committed
fix profile-edit save, courses-routes & adapters & shared components from courses
1 parent 24146bb commit 6f77105

26 files changed

Lines changed: 86 additions & 80 deletions

.claude/commands/explain.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.claude/commands/push.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

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

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -142,52 +142,86 @@ export class ProfileEditInfoService {
142142
: [],
143143
}));
144144

145-
const newProfile = {
146-
...this.profileForm.value,
147-
achievements,
148-
[this.userTypeMap[this.profileForm.value.userType]]: this.typeSpecific.value,
149-
typeSpecific: undefined,
150-
birthday: this.profileForm.value.birthday
151-
? dayjs(this.profileForm.value.birthday, "DD.MM.YYYY").format("YYYY-MM-DD")
152-
: undefined,
153-
skillsIds: this.profileForm.value.skills.map((s: Skill) => s.id),
154-
phoneNumber:
145+
// Построение объекта профиля с только необходимыми полями
146+
const newProfile: any = {
147+
id: this.profileId(),
148+
first_name: this.profileForm.value.firstName,
149+
last_name: this.profileForm.value.lastName,
150+
email: this.profileForm.value.email,
151+
user_type: this.profileForm.value.userType,
152+
city: this.profileForm.value.city,
153+
about_me: this.profileForm.value.aboutMe || "",
154+
avatar: this.profileForm.value.avatar || null,
155+
cover_image_address: this.profileForm.value.coverImageAddress || null,
156+
phone_number:
155157
typeof this.profileForm.value.phoneNumber === "string"
156158
? this.profileForm.value.phoneNumber.replace(/^([87])/, "+7")
157159
: this.profileForm.value.phoneNumber,
160+
speciality: this.profileForm.value.speciality,
161+
skills_ids: this.profileForm.value.skills?.map((s: Skill) => s.id) || [],
158162
};
159163

164+
// Добавляем birthday если он указан
165+
if (this.profileForm.value.birthday) {
166+
newProfile.birthday = dayjs(this.profileForm.value.birthday, "DD.MM.YYYY").format(
167+
"YYYY-MM-DD"
168+
);
169+
}
170+
171+
// Добавляем специфичные для типа пользователя поля
172+
if (this.userTypeMap[this.profileForm.value.userType]) {
173+
newProfile[this.userTypeMap[this.profileForm.value.userType]] = this.typeSpecific.value;
174+
}
175+
176+
// Добавляем связанные данные если они были отредактированы
177+
if (this.achievements.length > 0) {
178+
newProfile.achievements = achievements;
179+
}
180+
if (this.profileForm.value.education?.length > 0) {
181+
newProfile.education = this.profileForm.value.education;
182+
}
183+
if (this.profileForm.value.workExperience?.length > 0) {
184+
newProfile.work_experience = this.profileForm.value.workExperience;
185+
}
186+
if (this.profileForm.value.userLanguages?.length > 0) {
187+
newProfile.user_languages = this.profileForm.value.userLanguages;
188+
}
189+
190+
console.log("Saving profile:", newProfile);
191+
160192
this.authRepository
161193
.updateProfile(newProfile)
162194
.pipe(
163195
concatMap(() => this.authRepository.fetchProfile()),
164196
takeUntil(this.destroy$)
165197
)
166198
.subscribe({
167-
next: () => {
199+
next: profile => {
168200
this.profileFormSubmitting$.set(success(undefined));
169-
this.navigationService.profileRedirect(this.profileId());
201+
this.navigationService.profileRedirect(profile.id);
170202
},
171203
error: error => {
172204
this.profileFormSubmitting$.set(failure("profile_edit_error"));
173205
this.isModalErrorSkillsChoose.set(true);
174-
if (error.error.phone_number) {
206+
if (error.error?.phone_number) {
175207
this.isModalErrorSkillChooseText.set(error.error.phone_number[0]);
176-
} else if (error.error.language) {
208+
} else if (error.error?.language) {
177209
this.isModalErrorSkillChooseText.set(error.error.language);
178-
} else if (error.error.achievements) {
210+
} else if (error.error?.achievements) {
179211
this.isModalErrorSkillChooseText.set(error.error.achievements[0]);
180-
} else if (error.error.work_experience?.[2]) {
212+
} else if (error.error?.work_experience?.[2]) {
181213
const errorText = error.error.work_experience[2].entry_year
182214
? error.error.work_experience[2].entry_year
183215
: error.error.work_experience[2].completion_year;
184216
this.isModalErrorSkillChooseText.set(errorText);
185-
} else if (error.error.first_name?.[0]) {
217+
} else if (error.error?.first_name?.[0]) {
186218
this.isModalErrorSkillChooseText.set(error.error.first_name?.[0]);
187-
} else if (error.error.last_name?.[0]) {
219+
} else if (error.error?.last_name?.[0]) {
188220
this.isModalErrorSkillChooseText.set(error.error.last_name?.[0]);
189-
} else {
221+
} else if (error.error?.[0]) {
190222
this.isModalErrorSkillChooseText.set(error.error[0]);
223+
} else {
224+
this.isModalErrorSkillChooseText.set("Ошибка при сохранении профиля");
191225
}
192226
},
193227
});

projects/social_platform/src/app/ui/pages/courses/courses.service.ts renamed to projects/social_platform/src/app/infrastructure/adapters/courses/courses-http.adapter.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @format */
22

3-
import { Injectable } from "@angular/core";
4-
import { ApiService } from "@corelib";
3+
import { inject, Injectable } from "@angular/core";
4+
import { ApiService } from "@core/public-api";
55
import {
66
CourseCard,
77
CourseDetail,
@@ -11,19 +11,10 @@ import {
1111
} from "@domain/project/courses.model";
1212
import { Observable } from "rxjs";
1313

14-
/**
15-
* Сервис Курсов
16-
*
17-
* Управляет всеми операциями, связанными с курсами, включая:
18-
* - Отслеживание прогресса пользователя по курсу
19-
*/
20-
@Injectable({
21-
providedIn: "root",
22-
})
23-
export class CoursesService {
14+
@Injectable({ providedIn: "root" })
15+
export class CoursesHttpAdapter {
2416
private readonly COURSE_URL = "/courses";
25-
26-
constructor(private readonly apiService: ApiService) {}
17+
private readonly apiService = inject(ApiService);
2718

2819
/**
2920
* Получает доступные курсов

projects/social_platform/src/app/ui/pages/courses/shared/course-module-card/course-module-card.component.html renamed to projects/social_platform/src/app/ui/components/course-module-card/course-module-card.component.html

File renamed without changes.

projects/social_platform/src/app/ui/pages/courses/shared/course-module-card/course-module-card.component.scss renamed to projects/social_platform/src/app/ui/components/course-module-card/course-module-card.component.scss

File renamed without changes.

projects/social_platform/src/app/ui/pages/courses/shared/course-module-card/course-module-card.component.spec.ts renamed to projects/social_platform/src/app/ui/components/course-module-card/course-module-card.component.spec.ts

File renamed without changes.

projects/social_platform/src/app/ui/pages/courses/shared/course-module-card/course-module-card.component.ts renamed to projects/social_platform/src/app/ui/components/course-module-card/course-module-card.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { CommonModule } from "@angular/common";
55
import { AvatarComponent } from "@uilib";
66
import { PluralizePipe } from "@corelib";
77
import { IconComponent } from "@ui/components";
8-
import { CircleProgressBarComponent } from "../circle-progress-bar/circle-progress-bar.component";
8+
import { CircleProgressBarComponent } from "../../shared/circle-progress-bar/circle-progress-bar.component";
99
import { CourseDetail, CourseModule } from "@domain/project/courses.model";
1010
import { RouterLink } from "@angular/router";
1111

projects/social_platform/src/app/ui/pages/courses/shared/course/course.component.html renamed to projects/social_platform/src/app/ui/components/course/course.component.html

File renamed without changes.

projects/social_platform/src/app/ui/pages/courses/shared/course/course.component.scss renamed to projects/social_platform/src/app/ui/components/course/course.component.scss

File renamed without changes.

0 commit comments

Comments
 (0)