Skip to content

Commit f5d28b5

Browse files
committed
add profile progress to profile & avatar
1 parent a9c5214 commit f5d28b5

10 files changed

Lines changed: 137 additions & 23 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/** @format */
2+
3+
export const fieldsProfile = [
4+
{ key: "education", type: "array" },
5+
{ key: "workExperience", type: "array" },
6+
{ key: "userLanguages", type: "array" },
7+
{ key: "achievements", type: "array" },
8+
{ key: "skills", type: "array" },
9+
{ key: "birthday", type: "string" },
10+
{ key: "phoneNumber", type: "string" },
11+
{ key: "speciality", type: "string" },
12+
{ key: "aboutMe", type: "string" },
13+
{ key: "avatar", type: "string" },
14+
{ key: "city", type: "string" },
15+
{ key: "firstName", type: "string" },
16+
{ key: "lastName", type: "string" },
17+
];

projects/social_platform/src/app/auth/models/user.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class User {
4646
skillsIds!: number[];
4747
isOnline!: boolean;
4848
isActive!: boolean;
49+
progress?: number;
4950
v2Speciality!: {
5051
id: number;
5152
name: string;

projects/social_platform/src/app/office/profile/detail/profile-detail.component.html

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<app-avatar
4242
class="info__avatar"
4343
[url]="user.avatar"
44+
[progress]="user.progress"
4445
[size]="(desktopMode$ | async) ? 165 : 140"
4546
[hasBorder]="true"
4647
[onlineBadgeSize]="30"
@@ -90,8 +91,8 @@ <h2 class="info__name">{{ user.firstName }} {{ user.lastName }}</h2>
9091
</a>
9192
} @else {
9293
<div class="profile__btns">
93-
<a class="profile__cv">
94-
@if(isSubscriptionActive){
94+
<!-- <a class="profile__cv">
95+
@if(isSubscriptionActive()){
9596
<app-button
9697
(click)="sendCVEmail()"
9798
customTypographyClass="text-body-12"
@@ -100,15 +101,25 @@ <h2 class="info__name">{{ user.firstName }} {{ user.lastName }}</h2>
100101
Скачать CV
101102
</app-button>
102103
}
103-
</a>
104+
</a> -->
104105

105106
<a
106107
class="profile__edit"
107108
routerLink="/office/profile/edit"
108109
[queryParams]="{ editingStep: 'main' }"
109110
>
110111
<app-button customTypographyClass="text-body-12" color="grey">
111-
Редактировать профиль
112+
{{
113+
user.progress! === 100 ? "Редактировать профиль" : "Закончить заполнение резюме"
114+
}}
115+
@if (user.progress !== 100) {
116+
<i
117+
appIcon
118+
icon="color-error"
119+
appSquare="16"
120+
style="color: var(--accent); margin-left: 5px"
121+
></i>
122+
}
112123
</app-button>
113124
</a>
114125
</div>
@@ -148,6 +159,28 @@ <h2 class="info__name">{{ user.firstName }} {{ user.lastName }}</h2>
148159
</div>
149160
</app-modal>
150161

162+
<app-modal [open]="isProfileFill" (openChange)="isProfileFill = !isProfileFill">
163+
<div class="cancel">
164+
<div class="cancel__top">
165+
<i (click)="isProfileFill = false" appIcon icon="cross" class="cancel__cross"></i>
166+
<img
167+
alt="profile unfill image"
168+
class="cancel__image"
169+
src="/assets/images/profile/profile-unfill.png"
170+
/>
171+
<p class="cancel__title text-heading-4">Профиль не завершён</p>
172+
</div>
173+
<p class="text-body-14 cancel__text">
174+
Заполни все поля, чтобы использовать<br />
175+
Procollab на максимум
176+
</p>
177+
178+
<a routerLink="/office/profile/edit" [queryParams]="{ editingStep: 'main' }">
179+
<app-button customTypographyClass="text-body-12">Продолжить заполнение</app-button>
180+
</a>
181+
</div>
182+
</app-modal>
183+
151184
<div class="outlet">
152185
<router-outlet></router-outlet>
153186
</div>

projects/social_platform/src/app/office/profile/detail/profile-detail.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ $detail-bar-mb: 12px;
281281

282282
@include responsive.apply-desktop {
283283
width: 50%;
284+
min-width: 700px;
284285
}
285286

286287
&__cross {
@@ -297,11 +298,23 @@ $detail-bar-mb: 12px;
297298
}
298299
}
299300

301+
&__image {
302+
margin-bottom: 20px;
303+
}
304+
300305
&__title {
306+
margin-bottom: 10px;
301307
text-align: center;
302308
}
303309

304310
&__text {
305311
text-align: center;
306312
}
313+
314+
::ng-deep {
315+
app-button {
316+
display: block;
317+
margin-top: 20px;
318+
}
319+
}
307320
}

projects/social_platform/src/app/office/profile/detail/profile-detail.component.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { AvatarComponent } from "@ui/components/avatar/avatar.component";
1414
import { BackComponent } from "@uilib";
1515
import { AsyncPipe, CommonModule } from "@angular/common";
1616
import { ModalComponent } from "@ui/components/modal/modal.component";
17+
import { calculateProfileProgress } from "@utils/calculateProgress";
1718

1819
@Component({
1920
selector: "app-profile-detail",
@@ -45,14 +46,18 @@ export class ProfileDetailComponent implements OnInit {
4546
public readonly breakpointObserver: BreakpointObserver
4647
) {}
4748

48-
user$: Observable<User> = this.route.data.pipe(map(r => r["data"][0]));
49-
loggedUserId$: Observable<number> = this.authService.profile.pipe(map(user => user.id));
49+
user$: Observable<User> = this.route.data.pipe(
50+
map(r => r["data"][0]),
51+
map(user => ({ ...user, progress: calculateProfileProgress(user) }))
52+
);
5053

51-
linkData = "";
54+
loggedUserId$: Observable<number> = this.authService.profile.pipe(map(user => user.id));
5255

5356
isDelayModalOpen = false;
5457
isSended = false;
55-
isSubscriptionActive = false;
58+
isSubscriptionActive = signal(false);
59+
60+
isProfileFill = false;
5661

5762
errorMessageModal = signal("");
5863
desktopMode$: Observable<boolean> = this.breakpointObserver
@@ -62,19 +67,10 @@ export class ProfileDetailComponent implements OnInit {
6267
ngOnInit(): void {
6368
this.navService.setNavTitle("Профиль");
6469

65-
this.subscriptionPlansService
66-
.getSubscriptions()
67-
.pipe(
68-
map(r => {
69-
if (typeof r === "string") {
70-
return !!r;
71-
}
72-
return false;
73-
})
74-
)
75-
.subscribe(r => {
76-
this.isSubscriptionActive = r!;
77-
});
70+
this.user$.subscribe(r => {
71+
this.isProfileFill =
72+
r.progress! < 100 ? (this.isProfileFill = true) : (this.isProfileFill = false);
73+
});
7874
}
7975

8076
downloadCV() {

projects/social_platform/src/app/ui/components/avatar/avatar.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
[style.width]="size + 'px'"
77
[style.height]="size + 'px'"
88
>
9+
@if (progress) {
10+
<div
11+
class="avatar__progress"
12+
[style.--progress]="progress + '%'"
13+
[style.--progress-width]="'-18px'"
14+
[style.--progress-color]="'var(--accent)'"
15+
></div>
16+
}
17+
918
<img
1019
[src]="url || placeholderUrl"
1120
[style.width]="size + 'px'"

projects/social_platform/src/app/ui/components/avatar/avatar.component.scss

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,40 @@
33
.avatar {
44
position: relative;
55

6+
&__progress {
7+
position: absolute;
8+
top: 0;
9+
left: 0;
10+
z-index: 3;
11+
width: 100%;
12+
height: 100%;
13+
background:
14+
conic-gradient(
15+
var(--progress-color) 0 var(--progress),
16+
transparent var(--progress) 100%
17+
);
18+
border-radius: 50%;
19+
mask:
20+
radial-gradient(
21+
circle,
22+
transparent calc(50% - var(--progress-width)),
23+
white calc(50% - var(--progress-width))
24+
);
25+
}
26+
627
img {
28+
position: relative;
29+
z-index: 1;
30+
border-radius: 50%;
731
object-fit: cover;
832
object-position: center;
9-
border-radius: 50%;
1033
}
1134

1235
&__online {
1336
position: absolute;
1437
right: 0;
1538
bottom: -1.5px;
16-
z-index: 1;
39+
z-index: 3;
1740
width: 16px;
1841
height: 16px;
1942
background-color: var(--green);

projects/social_platform/src/app/ui/components/avatar/avatar.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export class AvatarComponent implements OnInit {
1414
@Input() hasBorder = false;
1515
@Input() isOnline = false;
1616

17+
@Input() progress?: number;
18+
1719
@Input() onlineBadgeSize = 16;
1820
@Input() onlineBadgeBorder = 3;
1921
@Input() onlineBadgeOffset = 0;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/** @format */
2+
3+
import { User } from "@auth/models/user.model";
4+
import { fieldsProfile } from "projects/core/src/consts/fieldsProfile";
5+
6+
export const calculateProfileProgress = (user: User) => {
7+
let filledCount = 0;
8+
9+
fieldsProfile.forEach(({ key, type }) => {
10+
const value = user[key as keyof User];
11+
12+
if (type === "array") {
13+
if (Array.isArray(value) && value.length > 0) filledCount++;
14+
} else {
15+
if (typeof value === "string" && value.trim() !== "") filledCount++;
16+
}
17+
});
18+
19+
return Math.round((filledCount / fieldsProfile.length) * 100);
20+
};
10.2 KB
Loading

0 commit comments

Comments
 (0)