Skip to content

Commit b6fca34

Browse files
committed
fix(updates): updates
1 parent a264fca commit b6fca34

28 files changed

+323
-170
lines changed

src/app/app.routes.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,19 @@ export const routes: Routes = [
125125
},
126126
{
127127
path: 'my-profile',
128-
loadComponent: () => import('./features/profile/profile.component').then((mod) => mod.ProfileComponent),
128+
loadComponent: () =>
129+
import('./features/profile/pages/my-profile/my-profile.component').then((mod) => mod.MyProfileComponent),
129130
providers: [provideStates([ProfileResourceFiltersState, ProfileResourceFiltersOptionsState, ProfileState])],
130131
canActivate: [authGuard],
131132
},
133+
{
134+
path: 'user/:id',
135+
loadComponent: () =>
136+
import('./features/profile/pages/user-profile/user-profile.component').then(
137+
(mod) => mod.UserProfileComponent
138+
),
139+
providers: [provideStates([ProfileResourceFiltersState, ProfileResourceFiltersOptionsState, ProfileState])],
140+
},
132141
{
133142
path: 'institutions',
134143
loadChildren: () => import('./features/institutions/institutions.routes').then((r) => r.routes),

src/app/core/services/user.service.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ export class UserService {
4545
.pipe(map((response) => UserMapper.fromUserSettingsGetResponse(response)));
4646
}
4747

48-
getUserById(userId: string): Observable<User> {
49-
return this.jsonApiService
50-
.get<UserGetResponse>(`${environment.apiUrl}/users/${userId}/`)
51-
.pipe(map((response) => UserMapper.fromUserGetResponse(response)));
52-
}
53-
5448
updateUserProfile(userId: string, key: string, data: ProfileSettingsUpdate): Observable<User> {
5549
const patchedData = key === ProfileSettingsKey.User ? data : { [key]: data };
5650

src/app/features/admin-institutions/pages/institutions-users/institutions-users.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ export class InstitutionsUsersComponent implements OnInit {
189189
const filters = this.buildFilters();
190190
const sortField = this.sortField();
191191
const sortOrder = this.sortOrder();
192-
console.log(sortOrder);
193192
const sortParam = sortOrder === 0 ? `-${sortField}` : sortField;
194193

195194
this.actions.fetchInstitutionUsers(
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export { MyProfileDateCreatedFilterComponent } from './my-profile-date-created-filter/my-profile-date-created-filter.component';
2-
export { MyProfileFunderFilterComponent } from './my-profile-funder-filter/my-profile-funder-filter.component';
3-
export { MyProfileInstitutionFilterComponent } from './my-profile-institution-filter/my-profile-institution-filter.component';
4-
export { MyProfileLicenseFilterComponent } from './my-profile-license-filter/my-profile-license-filter.component';
5-
export { MyProfilePartOfCollectionFilterComponent } from './my-profile-part-of-collection-filter/my-profile-part-of-collection-filter.component';
6-
export { MyProfileProviderFilterComponent } from './my-profile-provider-filter/my-profile-provider-filter.component';
7-
export { MyProfileResourceTypeFilterComponent } from './my-profile-resource-type-filter/my-profile-resource-type-filter.component';
8-
export { MyProfileSubjectFilterComponent } from './my-profile-subject-filter/my-profile-subject-filter.component';
1+
export { ProfileDateCreatedFilterComponent } from './profile-date-created-filter/profile-date-created-filter.component';
2+
export { ProfileFunderFilterComponent } from './profile-funder-filter/profile-funder-filter.component';
3+
export { ProfileInstitutionFilterComponent } from './profile-institution-filter/profile-institution-filter.component';
4+
export { ProfileLicenseFilterComponent } from './profile-license-filter/profile-license-filter.component';
5+
export { ProfilePartOfCollectionFilterComponent } from './profile-part-of-collection-filter/profile-part-of-collection-filter.component';
6+
export { ProfileProviderFilterComponent } from './profile-provider-filter/profile-provider-filter.component';
7+
export { ProfileResourceTypeFilterComponent } from './profile-resource-type-filter/profile-resource-type-filter.component';
8+
export { ProfileSubjectFilterComponent } from './profile-subject-filter/profile-subject-filter.component';
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './filters';
2-
export { MyProfileFilterChipsComponent } from './my-profile-filter-chips/my-profile-filter-chips.component';
3-
export { MyProfileResourceFiltersComponent } from './my-profile-resource-filters/my-profile-resource-filters.component';
4-
export { ProfileResourcesComponent } from './my-profile-resources/my-profile-resources.component';
5-
export { ProfileSearchComponent } from './my-profile-search/my-profile-search.component';
2+
export { ProfileFilterChipsComponent } from './profile-filter-chips/profile-filter-chips.component';
3+
export { ProfileResourceFiltersComponent } from './profile-resource-filters/profile-resource-filters.component';
4+
export { ProfileResourcesComponent } from './profile-resources/profile-resources.component';
5+
export { ProfileSearchComponent } from './profile-search/profile-search.component';

src/app/features/profile/profile.component.html renamed to src/app/features/profile/components/profile-information/profile-information.component.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="flex align-items-center">
33
<h1>{{ currentUser()?.fullName }}</h1>
44

5-
@if (isMedium()) {
5+
@if (isMedium() && showEdit()) {
66
<p-button class="ml-auto" [label]="'myProfile.editProfile' | translate" (click)="toProfileSettings()"></p-button>
77
}
88
</div>
@@ -113,7 +113,7 @@ <h3 class="font-bold">
113113
}
114114
</div>
115115

116-
@if (!isMedium()) {
116+
@if (!isMedium() && showEdit()) {
117117
<div class="btn-full-width">
118118
<p-button
119119
class="ml-auto"
@@ -145,4 +145,3 @@ <h2 class="mb-3">{{ 'settings.profileSettings.tabs.education' | translate }}</h2
145145
}
146146
</div>
147147
}
148-
<osf-profile-search></osf-profile-search>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ProfileInformationComponent } from './profile-information.component';
4+
5+
describe('ProfileInformationComponent', () => {
6+
let component: ProfileInformationComponent;
7+
let fixture: ComponentFixture<ProfileInformationComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [ProfileInformationComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(ProfileInformationComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
3+
import { Button } from 'primeng/button';
4+
5+
import { DatePipe } from '@angular/common';
6+
import { ChangeDetectionStrategy, Component, computed, inject, input, output } from '@angular/core';
7+
import { toSignal } from '@angular/core/rxjs-interop';
8+
9+
import { EducationHistoryComponent, EmploymentHistoryComponent } from '@osf/shared/components';
10+
import { IS_MEDIUM } from '@osf/shared/helpers';
11+
import { User } from '@osf/shared/models';
12+
13+
@Component({
14+
selector: 'osf-profile-information',
15+
imports: [Button, EmploymentHistoryComponent, EducationHistoryComponent, TranslatePipe, DatePipe],
16+
templateUrl: './profile-information.component.html',
17+
styleUrl: './profile-information.component.scss',
18+
changeDetection: ChangeDetectionStrategy.OnPush,
19+
})
20+
export class ProfileInformationComponent {
21+
currentUser = input<User | null>();
22+
showEdit = input(false);
23+
editProfile = output<void>();
24+
25+
readonly isMedium = toSignal(inject(IS_MEDIUM));
26+
27+
isEmploymentAndEducationVisible = computed(
28+
() => this.currentUser()?.employment?.length || this.currentUser()?.education?.length
29+
);
30+
31+
toProfileSettings() {
32+
this.editProfile.emit();
33+
}
34+
}

src/app/features/profile/components/profile-search/profile-search.component.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,24 @@ import { Tab, TabList, Tabs } from 'primeng/tabs';
66

77
import { debounceTime, skip } from 'rxjs';
88

9-
import { ChangeDetectionStrategy, Component, DestroyRef, effect, inject, signal, untracked } from '@angular/core';
9+
import {
10+
ChangeDetectionStrategy,
11+
Component,
12+
DestroyRef,
13+
effect,
14+
inject,
15+
input,
16+
signal,
17+
untracked,
18+
} from '@angular/core';
1019
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
1120
import { FormControl } from '@angular/forms';
1221

13-
import { UserSelectors } from '@osf/core/store/user';
1422
import { SearchHelpTutorialComponent, SearchInputComponent } from '@osf/shared/components';
1523
import { SEARCH_TAB_OPTIONS } from '@osf/shared/constants';
1624
import { ResourceTab } from '@osf/shared/enums';
1725
import { IS_XSMALL } from '@osf/shared/helpers';
26+
import { User } from '@osf/shared/models';
1827

1928
import { GetResources, ProfileSelectors, SetResourceTab, SetSearchText } from '../../store';
2029
import { GetAllOptions } from '../filters/store';
@@ -39,6 +48,8 @@ import { ProfileResourcesComponent } from '../profile-resources/profile-resource
3948
export class ProfileSearchComponent {
4049
readonly store = inject(Store);
4150

51+
currentUser = input<User | null>();
52+
4253
protected searchControl = new FormControl<string>('');
4354
protected readonly isMobile = toSignal(inject(IS_XSMALL));
4455

@@ -56,7 +67,6 @@ export class ProfileSearchComponent {
5667
protected resourcesTabStoreValue = select(ProfileSelectors.getResourceTab);
5768
protected sortByStoreValue = select(ProfileSelectors.getSortBy);
5869
readonly isMyProfilePage = select(ProfileSelectors.getIsMyProfile);
59-
readonly currentUser = this.store.select(UserSelectors.getCurrentUser);
6070

6171
protected readonly resourceTabOptions = SEARCH_TAB_OPTIONS.filter((x) => x.value !== ResourceTab.Users);
6272
protected selectedTab: ResourceTab = ResourceTab.All;
@@ -65,8 +75,8 @@ export class ProfileSearchComponent {
6575
private skipInitializationEffects = 0;
6676

6777
constructor() {
68-
this.currentUser.subscribe((user) => {
69-
if (user?.id) {
78+
effect(() => {
79+
if (this.currentUser()) {
7080
this.store.dispatch(GetAllOptions);
7181
this.store.dispatch(GetResources);
7282
}

0 commit comments

Comments
 (0)