Skip to content

Commit 866b053

Browse files
committed
Merge branch 'refs/heads/main' into chore/101-setup-primeng-design-system
# Conflicts: # src/app/app.component.ts # src/app/app.config.ts # src/app/core/components/footer/footer.component.html # src/app/core/components/footer/footer.component.scss # src/app/core/components/footer/footer.component.ts # src/app/core/components/header/header.component.html # src/app/core/components/header/header.component.scss # src/app/core/components/header/header.component.ts # src/app/core/components/main-content/main-content.component.html # src/app/core/components/main-content/main-content.component.scss # src/app/core/components/sidenav/sidenav.component.html # src/app/core/components/sidenav/sidenav.component.scss # src/app/core/components/sidenav/sidenav.component.ts # src/app/features/auth/sign-up/sign-up.component.html # src/app/features/auth/sign-up/sign-up.component.ts
2 parents 77d8953 + 59359df commit 866b053

File tree

9 files changed

+87
-1
lines changed

9 files changed

+87
-1
lines changed

src/app/app.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { withNgxsReduxDevtoolsPlugin } from '@ngxs/devtools-plugin';
66
import { providePrimeNG } from 'primeng/config';
77
import Aura from '@primeng/themes/aura';
88
import { provideNoopAnimations } from '@angular/platform-browser/animations';
9+
import { provideHttpClient } from '@angular/common/http';
910

1011
export const appConfig: ApplicationConfig = {
1112
providers: [
@@ -18,11 +19,12 @@ export const appConfig: ApplicationConfig = {
1819
options: {
1920
cssLayer: {
2021
name: 'primeng',
21-
// order: 'base, primeng, reset',
22+
order: 'base, primeng, reset',
2223
},
2324
},
2425
},
2526
}),
2627
provideNoopAnimations(),
28+
provideHttpClient(),
2729
],
2830
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface JsonApiResponse<T> {
2+
data: ApiData<T> | ApiData<T>[];
3+
}
4+
5+
export interface ApiData<T> {
6+
id: string | number;
7+
attributes: T;
8+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Injectable } from '@angular/core';
2+
import { HttpClient } from '@angular/common/http';
3+
import { map, Observable } from 'rxjs';
4+
import {
5+
ApiData,
6+
JsonApiResponse,
7+
} from '@core/services/json-api/json-api.entity';
8+
9+
@Injectable({
10+
providedIn: 'root',
11+
})
12+
export class JsonApiService {
13+
constructor(private http: HttpClient) {}
14+
15+
get<T>(url: string): Observable<T> {
16+
return this.http
17+
.get<JsonApiResponse<T>>(url)
18+
.pipe(map((response) => (response.data as ApiData<T>).attributes));
19+
}
20+
21+
getArray<T>(url: string): Observable<T[]> {
22+
return this.http
23+
.get<JsonApiResponse<T>>(url)
24+
.pipe(
25+
map((response) =>
26+
(response.data as ApiData<T>[]).map((item) => item.attributes),
27+
),
28+
);
29+
}
30+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface UserUS {
2+
full_name: string;
3+
given_name: string;
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { User } from '@core/services/user/user.entity';
2+
import { UserUS } from '@core/services/json-api/underscore-entites/user/user-us.entity';
3+
4+
export function mapUserUStoUser(user: UserUS): User {
5+
return {
6+
fullName: user.full_name,
7+
givenName: user.given_name,
8+
};
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface User {
2+
fullName: string;
3+
givenName: string;
4+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { inject, Injectable } from '@angular/core';
2+
import { map, Observable } from 'rxjs';
3+
import { JsonApiService } from '@core/services/json-api/json-api.service';
4+
import { User } from '@core/services/user/user.entity';
5+
import { UserUS } from '@core/services/json-api/underscore-entites/user/user-us.entity';
6+
import { mapUserUStoUser } from '@core/services/mappers/users/users.mapper';
7+
8+
@Injectable({
9+
providedIn: 'root',
10+
})
11+
export class UserService {
12+
jsonApiService = inject(JsonApiService);
13+
14+
getMe(): Observable<User> {
15+
return this.jsonApiService
16+
.get<UserUS>('https://api.test.osf.io/v2/users/me')
17+
.pipe(map((user) => mapUserUStoUser(user)));
18+
}
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>sign-in works!</p>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'osf-sign-in',
5+
imports: [],
6+
templateUrl: './sign-in.component.html',
7+
styleUrl: './sign-in.component.scss',
8+
})
9+
export class SignInComponent {}

0 commit comments

Comments
 (0)