From 1686c9bace0cbe1773de8b3a72191c7de6c8ed2f Mon Sep 17 00:00:00 2001 From: Hugo <hugo.cubino@estudiantes.uva.es> Date: Fri, 27 Dec 2024 13:00:11 +0100 Subject: [PATCH] Arregladas cosas de angular --- angular/RestClient/src/app/app.routes.ts | 2 +- angular/RestClient/src/app/core/guards/rol.guard.ts | 3 ++- .../core/services/api/hotels/hotel-client.service.ts | 5 ++++- .../app/core/services/api/users/user-client.service.ts | 10 ++++++++-- .../src/app/features/hotels/hotels.routes.ts | 2 +- .../src/app/features/users/types/User.interface.ts | 2 +- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/angular/RestClient/src/app/app.routes.ts b/angular/RestClient/src/app/app.routes.ts index 0f07bf5..8a24a51 100644 --- a/angular/RestClient/src/app/app.routes.ts +++ b/angular/RestClient/src/app/app.routes.ts @@ -1,5 +1,5 @@ import { UnauthorizedComponent } from './page/unauthorized/unauthorized.component'; -import { AppRoute } from './core/models'; +import { AppRoute } from './core/models/Route.interface'; import { rolGuard, rolGuardChild } from '@core/guards'; export const routes: AppRoute[] = [ // Auth diff --git a/angular/RestClient/src/app/core/guards/rol.guard.ts b/angular/RestClient/src/app/core/guards/rol.guard.ts index b6d67d2..f63b9bc 100644 --- a/angular/RestClient/src/app/core/guards/rol.guard.ts +++ b/angular/RestClient/src/app/core/guards/rol.guard.ts @@ -5,7 +5,8 @@ import { CanActivateFn, Router, } from '@angular/router'; -import { Session, UserRol } from '@core/models'; +import { Session } from '@core/models/Session.interface'; +import { UserRol } from '../../features/users/types/User.interface'; import { SessionService } from '@core/services'; import { map } from 'rxjs'; diff --git a/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts b/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts index 5b5336c..e71cb6d 100644 --- a/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts +++ b/angular/RestClient/src/app/core/services/api/hotels/hotel-client.service.ts @@ -1,9 +1,12 @@ import { Injectable } from '@angular/core'; import { environment } from '../../../../../environments/environment'; import { HttpClient } from '@angular/common/http'; -import { Hotel, Room } from '../../../models'; import { SessionService } from '../../session/session.service'; import { catchError, map, switchMap, throwError } from 'rxjs'; +import { Hotel, Room } from '@features/hotels'; + +let hotel:Hotel; +let rooms:Room; @Injectable({ providedIn: 'root', diff --git a/angular/RestClient/src/app/core/services/api/users/user-client.service.ts b/angular/RestClient/src/app/core/services/api/users/user-client.service.ts index ec9e5d7..37b34a8 100644 --- a/angular/RestClient/src/app/core/services/api/users/user-client.service.ts +++ b/angular/RestClient/src/app/core/services/api/users/user-client.service.ts @@ -1,9 +1,15 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { environment } from '../../../../../environments/environment'; -import { Client, Session, User, UserState } from '../../../models'; import { SessionService } from '../../session/session.service'; import { tap } from 'rxjs'; +import { Client, ClientState, User } from '@features/users'; +import { Session } from 'inspector'; + +let user:User; +let session:Session; +let client:Client; +let userstate:ClientState; @Injectable({ providedIn: 'root', @@ -29,7 +35,7 @@ export class UserClientService { } // Cambiar estado de un usuario - alterUserStatus(userId: number, status: UserState) { + alterUserStatus(userId: number, status: ClientState) { return this.http.patch( `${this.URI}/${userId}`, { diff --git a/angular/RestClient/src/app/features/hotels/hotels.routes.ts b/angular/RestClient/src/app/features/hotels/hotels.routes.ts index d054f0a..bf57124 100644 --- a/angular/RestClient/src/app/features/hotels/hotels.routes.ts +++ b/angular/RestClient/src/app/features/hotels/hotels.routes.ts @@ -1,4 +1,4 @@ -import { AppRoute } from '@core/models'; +import { AppRoute } from '@core/models/Route.interface'; import { HotelRegisterComponent } from './hotel-register/hotel-register.component'; import { HotelListComponent } from './hotel-list/hotel-list.component'; import { rolGuard } from '@core/guards'; diff --git a/angular/RestClient/src/app/features/users/types/User.interface.ts b/angular/RestClient/src/app/features/users/types/User.interface.ts index 955e323..f2eb354 100644 --- a/angular/RestClient/src/app/features/users/types/User.interface.ts +++ b/angular/RestClient/src/app/features/users/types/User.interface.ts @@ -9,7 +9,7 @@ export interface User { } export const UserRolesArray = ['CLIENT', 'HOTEL_ADMIN', 'ADMIN'] as const; -export type UserRol = typeof UserRolesArray; +export type UserRol = 'CLIENT' | 'HOTEL_ADMIN' | 'ADMIN'; export interface Client extends User { status: ClientState; -- GitLab