forked from CenterForOpenScience/angular-osf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile-information.component.ts
More file actions
54 lines (44 loc) · 1.88 KB
/
profile-information.component.ts
File metadata and controls
54 lines (44 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { TranslatePipe } from '@ngx-translate/core';
import { Button } from 'primeng/button';
import { DatePipe, NgOptimizedImage } from '@angular/common';
import { ChangeDetectionStrategy, Component, computed, inject, input, output } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { EducationHistoryComponent } from '@osf/shared/components/education-history/education-history.component';
import { EmploymentHistoryComponent } from '@osf/shared/components/employment-history/employment-history.component';
import { SOCIAL_LINKS } from '@osf/shared/constants/social-links.const';
import { IS_MEDIUM } from '@osf/shared/helpers/breakpoints.tokens';
import { UserModel } from '@osf/shared/models/user/user.models';
import { SortByDatePipe } from '@osf/shared/pipes/sort-by-date.pipe';
import { mapUserSocials } from '../../helpers';
@Component({
selector: 'osf-profile-information',
imports: [
Button,
EmploymentHistoryComponent,
EducationHistoryComponent,
TranslatePipe,
DatePipe,
NgOptimizedImage,
SortByDatePipe,
],
templateUrl: './profile-information.component.html',
styleUrl: './profile-information.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProfileInformationComponent {
currentUser = input<UserModel | null>();
showEdit = input(false);
editProfile = output<void>();
readonly isMedium = toSignal(inject(IS_MEDIUM));
isEmploymentAndEducationVisible = computed(
() => this.currentUser()?.employment?.length || this.currentUser()?.education?.length
);
userSocials = computed(() => mapUserSocials(this.currentUser()?.social, SOCIAL_LINKS));
orcidId = computed(() => {
const orcid = this.currentUser()?.external_identity?.ORCID;
return orcid?.status?.toUpperCase() === 'VERIFIED' ? orcid.id : undefined;
});
toProfileSettings() {
this.editProfile.emit();
}
}