Skip to content

Commit 14e6116

Browse files
committed
fix profile
1 parent 01a67bd commit 14e6116

File tree

5 files changed

+206
-192
lines changed

5 files changed

+206
-192
lines changed

src/app/features/profile/component/updateform/profile-popup/update-profile.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@
9797
<div class="dropdown">
9898
<span class="dropdown-title">Trình độ học vấn</span>
9999
<app-dropdown-button
100-
[label]="'Trình độ học vấn'"
100+
[label]="selectedEducation ? selectedEducation.label : 'Chọn trình độ học vấn'"
101101
[options]="education"
102+
[selected]="selectedEducation"
102103
[variant]="'secondary'"
103104
[size]="'small'"
104105
[customDropField]="'main-type'"
@@ -121,8 +122,9 @@
121122
<span class="dropdown-title">Giới tính</span>
122123
@if (selectedGender) {
123124
<app-dropdown-button
124-
[label]="'Giới tính'"
125+
[label]="selectedGender.label"
125126
[options]="gender"
127+
[selected]="selectedGender"
126128
[variant]="'secondary'"
127129
[size]="'small'"
128130
[customDropField]="'main-type'"
@@ -151,7 +153,7 @@
151153
<div class="dropdown">
152154
<span class="dropdown-title">Thành phố</span>
153155
<app-dropdown-button
154-
[label]="'Chọn thành phố'"
156+
[label]="selectedCity ? selectedCity : 'Chọn thành phố'"
155157
[options]="cities"
156158
[variant]="'secondary'"
157159
[size]="'small'"

src/app/features/profile/component/updateform/profile-popup/update-profile.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import { TruncatePipe } from '../../../../../shared/pipes/format-view.pipe';
4444
FormsModule,
4545
ButtonComponent,
4646
LottieComponent,
47-
TruncatePipe
48-
],
47+
TruncatePipe,
48+
],
4949
providers: [provideLottieOptions({ player: () => import('lottie-web') })],
5050

5151
schemas: [CUSTOM_ELEMENTS_SCHEMA],
@@ -115,8 +115,8 @@ export class UpdateProfileComponent {
115115
];
116116

117117
this.gender = [
118-
{ value: 'true', label: 'Nam' },
119-
{ value: 'false', label: 'Nữ' },
118+
{ value: 'false', label: 'Nam' },
119+
{ value: 'true', label: 'Nữ' },
120120
];
121121
}
122122

@@ -147,21 +147,21 @@ export class UpdateProfileComponent {
147147
this.originalDob = this.user.dob;
148148
if (this.user.dob) {
149149
const [day, month, year] = this.user.dob.split('/');
150-
this.dob = `${year}-${month.padStart(2, '0')}-${day.padStart(
151-
2,
152-
'0'
153-
)}T00:00`;
150+
this.dob = `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`;
154151
}
155-
const genderStr = this.user.gender?.toString();
156-
this.selectedGender =
157-
this.gender.find((g) => g.value === genderStr) || null;
158152

153+
// Gán giới tính
154+
this.selectedGender =
155+
this.gender.find((g) => g.value === String(this.user.gender)) || null;
156+
console.log('selectedGender on init:', this.selectedGender);
159157
this.links = [...(this.user.links || [])];
160158
this.selectedCity = this.user.city || '';
161159

162160
const edu = this.user.education;
163161
this.selectedEducation =
164-
this.education.find((g) => g.value === edu) || null;
162+
this.education.find((e) => e.value === this.user.education) || null;
163+
164+
console.log('selectedEducation on init:', this.selectedEducation);
165165
} else {
166166
this.hasError = true;
167167
}
@@ -247,7 +247,9 @@ export class UpdateProfileComponent {
247247
const isBioChanged = (this.bio || '') !== (this.user.bio || '');
248248

249249
const isGenderChanged =
250-
(this.selectedGender === 'true') !== this.user.gender;
250+
(this.selectedGender?.value === 'true') !== this.user.gender;
251+
console.log('selectedGender:', this.selectedGender);
252+
console.log('user.gender:', this.user.gender);
251253

252254
const isDisplayNameChanged =
253255
(this.displayName || '') !== (this.user.displayName || '');
@@ -294,7 +296,7 @@ export class UpdateProfileComponent {
294296
this.lastName,
295297
formatDateToDDMMYYYY(this.dob),
296298
this.bio || '',
297-
this.selectedGender === 'true',
299+
this.selectedGender === 'false' ? false : true,
298300
this.displayName,
299301
Number(this.selectedEducation?.value ?? 0),
300302
this.links,

src/app/features/profile/page/personal-profile/personal-profile.html

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[following]="followingList"
99
></app-profile-popup>
1010
</div>
11-
<div class="learning-process">
11+
<!-- <div class="learning-process">
1212
<div class="academic-results">
1313
<div class="title-nav">
1414
<span class="title"> Thống kê kết quả học tập </span>
@@ -90,9 +90,9 @@
9090
</div>
9191
}
9292
</div>
93-
<!-- <div class="post"></div> -->
94-
</div>
95-
<div class="short-cut">
93+
<div class="post"></div>
94+
</div> -->
95+
<!-- <div class="short-cut">
9696
<div class="recent-notice">
9797
<div class="title-nav">
9898
<span class="title"> Thông báo gần đây </span>
@@ -111,25 +111,23 @@
111111
>
112112
</div>
113113
</div>
114-
</div>
114+
</div> -->
115115

116-
@if (openedUser) {
117-
<div
118-
[ngClass]="{'profile-popup-overlay': true, 'hide': isClosing}"
119-
>
120-
<div
121-
class="profile-popup-backdrop"
122-
[ngClass]="{'hide': isClosing}"
123-
(click)="closeProfilePopup()"
124-
></div>
125-
<div [ngClass]="{'profile-popup-container': true, 'hide': isClosing}">
126-
<button class="close-btn" (click)="closeProfilePopup()">×</button>
127-
<app-update-profile
128-
[user]="openedUser"
129-
[variant]="'popup'"
130-
(refresh)="refetchUserData($event)"
131-
></app-update-profile>
132-
</div>
133-
</div>
134-
}
116+
@if (openedUser) {
117+
<div [ngClass]="{'profile-popup-overlay': true, 'hide': isClosing}">
118+
<div
119+
class="profile-popup-backdrop"
120+
[ngClass]="{'hide': isClosing}"
121+
(click)="closeProfilePopup()"
122+
></div>
123+
<div [ngClass]="{'profile-popup-container': true, 'hide': isClosing}">
124+
<button class="close-btn" (click)="closeProfilePopup()">×</button>
125+
<app-update-profile
126+
[user]="openedUser"
127+
[variant]="'popup'"
128+
(refresh)="refetchUserData($event)"
129+
></app-update-profile>
130+
</div>
135131
</div>
132+
}
133+
</div>

0 commit comments

Comments
 (0)