Skip to content

Commit 1b8cb53

Browse files
committed
Merge with main
Removed some redundant files and fix with new api url.
1 parent 1c3d593 commit 1b8cb53

File tree

9 files changed

+26
-139
lines changed

9 files changed

+26
-139
lines changed

frontend/src/_helpers/interceptors/error.interceptor.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

frontend/src/_helpers/interceptors/jwt.interceptor.spec.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

frontend/src/_helpers/interceptors/jwt.interceptor.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

frontend/src/_interceptors/error.interceptor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export class ErrorInterceptor implements HttpInterceptor {
99
return next.handle(request).pipe(
1010
catchError(err => {
1111
console.error(err);
12-
1312
const errorMessage = err.error.message;
1413
return throwError(() => new Error(errorMessage, { cause: err }));
1514
}),

frontend/src/_interceptors/jwt.interceptor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
33
import { Observable } from 'rxjs';
4+
45
import { AuthenticationService } from '../_services/authentication.service';
56

67
@Injectable()

frontend/src/_services/authentication.service.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,26 @@ export class AuthenticationService extends ApiService {
7171

7272
// get user details from user service for authentication
7373
getUserDetails() {
74-
return this.http
75-
.get<UServRes>(`${environment.UserServiceApiUrl}/users/${this.userValue?.id}`, { observe: 'response' })
76-
.pipe(
77-
map(response => {
78-
if (response.status === 200) {
79-
let user: User = {};
80-
if (response.body) {
81-
const body: UServRes = response.body;
82-
const data = body.data;
83-
user = {
84-
id: data.id,
85-
username: data.username,
86-
email: data.email,
87-
accessToken: data.accessToken,
88-
isAdmin: data.isAdmin,
89-
createdAt: data.createdAt,
90-
};
91-
}
92-
return user;
74+
return this.http.get<UServRes>(`${this.apiUrl}/users/${this.userValue?.id}`, { observe: 'response' }).pipe(
75+
map(response => {
76+
if (response.status === 200) {
77+
let user: User = {} as User;
78+
if (response.body) {
79+
const body: UServRes = response.body;
80+
const data = body.data;
81+
user = {
82+
id: data.id,
83+
username: data.username,
84+
email: data.email,
85+
accessToken: data.accessToken,
86+
isAdmin: data.isAdmin,
87+
createdAt: data.createdAt,
88+
};
9389
}
94-
return null;
95-
}),
96-
);
90+
return user;
91+
}
92+
return null;
93+
}),
94+
);
9795
}
9896
}

frontend/src/app/app.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { provideRouter } from '@angular/router';
33
import { HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
44
import { routes } from './app.routes';
55
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
6+
import { JwtInterceptor } from '../_interceptors/jwt.interceptor';
7+
import { ErrorInterceptor } from '../_interceptors/error.interceptor';
8+
import { AuthGuardService } from '../_services/auth.guard.service';
69

710
export const appConfig: ApplicationConfig = {
811
providers: [

frontend/src/app/questions/questions.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
[disabled]="!selectedQuestions || !selectedQuestions.length" />
2525
</div>
2626
</p-toolbar>
27-
<div class="table-container" style="max-width: 1000px; margin: 0 auto;">
27+
<div class="table-container" style="max-width: 1000px; margin: 0 auto">
2828
<p-table
2929
sortField="id"
3030
[sortOrder]="1"
3131
[columns]="cols"
3232
[value]="questions"
3333
[(selection)]="selectedQuestions"
3434
datakey="id"
35-
[tableStyle]="{ 'table-layout': 'fixed', 'width': '100%', 'text-align': 'center' }"
35+
[tableStyle]="{ 'table-layout': 'fixed', width: '100%', 'text-align': 'center' }"
3636
[paginator]="true"
3737
[rows]="10"
3838
[rowsPerPageOptions]="[10, 25, 50]"

frontend/src/app/questions/questions.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { HttpErrorResponse } from '@angular/common/http';
1818
import { QuestionDialogComponent } from './question-dialog.component';
1919
import { Column } from './column.model';
2020
import { AuthenticationService } from '../../_services/authentication.service';
21-
import { UServRes } from '../../_models/user.service.response.interface';
2221
import { User } from '../../_models/user.model';
2322

2423
@Component({

0 commit comments

Comments
 (0)