Skip to content

Commit

Permalink
Merge pull request #79 from Apes2getherStrong/78-dodanie-tras-przypis…
Browse files Browse the repository at this point in the history
…uje-uytkownika-jako-waciciela

Aktualny user jest przypisywany do nowo tworzonych tras
  • Loading branch information
Drillllll authored Jun 17, 2024
2 parents f96c470 + 9950cfd commit a373523
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/app/route/route.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {backendUrl} from "../shared/http.config";
import {catchError, map, Observable, of} from "rxjs";
import {AuthService} from "../auth/auth.service";
import {ActivatedRoute, Router, UrlTree} from "@angular/router";
import {User} from "../user/user.model";


@Injectable({providedIn: 'root'})
Expand All @@ -16,7 +17,7 @@ export class RouteService {
}

getRoutes(pageNumber: number, pageSize: number, name?: string) {
let params = new HttpParams()
let params = new HttpParams()
.set('pageNumber', pageNumber.toString())
.set('pageSize', pageSize.toString());

Expand Down Expand Up @@ -44,13 +45,16 @@ export class RouteService {
}

const userId = this.authService.getUserId();
const url = `${backendUrl}/routes/${userId}/routes`;
const url = `${backendUrl}/routes/${userId}/routes`;
return this.http.get<Page<Route>>(url, {params});
}

postRoute(route: Route) {
route.user = new User(this.authService.getUserId());

const url = `${backendUrl}/routes`;
return this.http.post<Route>(url, route);

}

deleteRouteById(id: string) {
Expand Down Expand Up @@ -83,7 +87,7 @@ export class RouteService {

getRouteImageById(id: string) {
const url = `${backendUrl}/routes/${id}/image`;
return this.http.get(url, { responseType: 'blob' }).pipe(
return this.http.get(url, {responseType: 'blob'}).pipe(
catchError((error: HttpErrorResponse) => {
console.error('Error fetching image:', error);
return of(null);
Expand Down
4 changes: 2 additions & 2 deletions src/app/user/user.model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export class User {
constructor(
public id: string,
public username: string,
public login: string,
public username?: string,
public login?: string,
) {}
}

0 comments on commit a373523

Please sign in to comment.