From f98e040d0db5afeaf6546325a43c3d7c21606f19 Mon Sep 17 00:00:00 2001 From: migudel <miguel.moras@estudiantes.uva.es> Date: Sun, 3 Nov 2024 13:00:17 +0100 Subject: [PATCH] Agregado tipo UserStateFilter --- .../core/features/user/main-page/main-page.component.html | 2 +- .../app/core/features/user/main-page/main-page.component.ts | 6 +++--- angular/RestClient/src/types/User.d.ts | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/angular/RestClient/src/app/core/features/user/main-page/main-page.component.html b/angular/RestClient/src/app/core/features/user/main-page/main-page.component.html index 0685752..03dd10b 100644 --- a/angular/RestClient/src/app/core/features/user/main-page/main-page.component.html +++ b/angular/RestClient/src/app/core/features/user/main-page/main-page.component.html @@ -4,7 +4,7 @@ <div class="filter-container"> <label for="filter">Filtrar por estado:</label> <select id="filter" [(ngModel)]="selectedStatus" (change)="filterUsers()"> - <option value="all">Todos</option> + <option value="All">Todos</option> <option value="NO_BOOKINGS">Sin reservas</option> <option value="WITH_ACTIVE_BOOKINGS">Con reservas activas</option> <option value="WITH_INACTIVE_BOOKING">Con reservas inactivas</option> diff --git a/angular/RestClient/src/app/core/features/user/main-page/main-page.component.ts b/angular/RestClient/src/app/core/features/user/main-page/main-page.component.ts index e1f7201..b13b352 100644 --- a/angular/RestClient/src/app/core/features/user/main-page/main-page.component.ts +++ b/angular/RestClient/src/app/core/features/user/main-page/main-page.component.ts @@ -1,7 +1,7 @@ // main-page.component.ts import { Component, OnInit } from '@angular/core'; import { ClienteApiRestService } from '../../../../shared/cliente-api-rest.service'; -import { User } from '../../../../../types'; +import { User, UserStateFilter } from '../../../../../types'; import { FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import users from '../../../../../mocks/users.json'; @@ -16,7 +16,7 @@ import { RouterModule } from '@angular/router'; export class MainPageComponent implements OnInit { users: User[] = []; filteredUsers: User[] = []; - selectedStatus: string = 'all'; + selectedStatus: UserStateFilter = 'All'; constructor(private ClienteApiRestService: ClienteApiRestService) {} @@ -29,7 +29,7 @@ export class MainPageComponent implements OnInit { } filterUsers(): void { - if (this.selectedStatus === 'all') { + if (this.selectedStatus === 'All') { this.filteredUsers = this.users; } else { this.filteredUsers = this.users.filter( diff --git a/angular/RestClient/src/types/User.d.ts b/angular/RestClient/src/types/User.d.ts index 09a0ec8..1ecc3d7 100644 --- a/angular/RestClient/src/types/User.d.ts +++ b/angular/RestClient/src/types/User.d.ts @@ -6,6 +6,8 @@ export interface User { status: UserState; } +export type UserStateFilter = 'All' | UserState; + export type UserState = | 'NO_BOOKINGS' | 'WITH_ACTIVE_BOOKINGS' -- GitLab