diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 12c8013..c466810 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,47 +1,48 @@ -import { NgModule } from '@angular/core'; -import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; -import { LoginPage } from './login/login.page'; - - -const routes: Routes = [ - - { - path: 'login', - component: LoginPage - }, - { - path: 'tabs', - loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule) - }, - { - path: 'tabsUser', - loadChildren: () => import('./tabs-user/tabs-user.module').then(m => m.TabsUserPageModule) - }, - { - path: 'view-evento', - loadChildren: () => import('./view-evento/view-evento.module').then( m => m.ViewEventoPageModule) - }, - { - path: 'galeriamodal', - loadChildren: () => import('./galeriamodal/galeriamodal.module').then( m => m.GaleriamodalPageModule) - }, - { - path:'', - redirectTo: 'login', - pathMatch: 'full' - }, - { - path: 'tabs-user', - loadChildren: () => import('./tabs-user/tabs-user.module').then( m => m.TabsUserPageModule) - }, - { - path: 'feed', - loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule) - }, - { - path: 'view-evento-cliente', - loadChildren: () => import('./view-evento-cliente/view-evento-cliente.module').then( m => m.ViewEventoClientePageModule) - }, { +import { NgModule } from '@angular/core'; +import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; +import { LoginPage } from './login/login.page'; + + +const routes: Routes = [ + + { + path: 'login', + component: LoginPage + }, + { + path: 'tabs', + loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule) + }, + { + path: 'tabsUser', + loadChildren: () => import('./tabs-user/tabs-user.module').then(m => m.TabsUserPageModule) + }, + { + path: 'view-evento', + loadChildren: () => import('./view-evento/view-evento.module').then( m => m.ViewEventoPageModule) + }, + { + path: 'galeriamodal', + loadChildren: () => import('./galeriamodal/galeriamodal.module').then( m => m.GaleriamodalPageModule) + }, + { + path:'', + redirectTo: 'login', + pathMatch: 'full' + }, + { + path: 'tabs-user', + loadChildren: () => import('./tabs-user/tabs-user.module').then( m => m.TabsUserPageModule) + }, + { + path: 'feed', + loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule) + }, + { + path: 'view-evento-cliente', + loadChildren: () => import('./view-evento-cliente/view-evento-cliente.module').then( m => m.ViewEventoClientePageModule) + }, + { path: 'view-discoteca-cliente', loadChildren: () => import('./view-discoteca-cliente/view-discoteca-cliente.module').then( m => m.ViewDiscotecaClientePageModule) }, @@ -49,18 +50,22 @@ const routes: Routes = [ path: 'reservamodal', loadChildren: () => import('./reservamodal/reservamodal.module').then( m => m.ReservamodalPageModule) }, + { + path: 'perfil-usuario', + loadChildren: () => import('./perfil-usuario/perfil-usuario.module').then( m => m.PerfilUsuarioPageModule) + }, - - - - - - -]; -@NgModule({ - imports: [ - RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) - ], - exports: [RouterModule] -}) -export class AppRoutingModule {} + + + + + + +]; +@NgModule({ + imports: [ + RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) + ], + exports: [RouterModule] +}) +export class AppRoutingModule {} diff --git a/src/app/interfaces/codigo.ts b/src/app/interfaces/codigo.ts new file mode 100644 index 0000000..8ecc3a2 --- /dev/null +++ b/src/app/interfaces/codigo.ts @@ -0,0 +1,5 @@ +export interface Codigo { + UserID: number, + codigo: string, + numReservas: number +} diff --git a/src/app/perfil-usuario/perfil-usuario-routing.module.ts b/src/app/perfil-usuario/perfil-usuario-routing.module.ts new file mode 100644 index 0000000..9009800 --- /dev/null +++ b/src/app/perfil-usuario/perfil-usuario-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { Routes, RouterModule } from '@angular/router'; + +import { PerfilUsuarioPage } from './perfil-usuario.page'; + +const routes: Routes = [ + { + path: '', + component: PerfilUsuarioPage + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class PerfilUsuarioPageRoutingModule {} diff --git a/src/app/perfil-usuario/perfil-usuario.module.ts b/src/app/perfil-usuario/perfil-usuario.module.ts new file mode 100644 index 0000000..287a384 --- /dev/null +++ b/src/app/perfil-usuario/perfil-usuario.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import { IonicModule } from '@ionic/angular'; + +import { PerfilUsuarioPageRoutingModule } from './perfil-usuario-routing.module'; + +import { PerfilUsuarioPage } from './perfil-usuario.page'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + PerfilUsuarioPageRoutingModule + ], + declarations: [PerfilUsuarioPage] +}) +export class PerfilUsuarioPageModule {} diff --git a/src/app/perfil-usuario/perfil-usuario.page.html b/src/app/perfil-usuario/perfil-usuario.page.html new file mode 100644 index 0000000..7b109bf --- /dev/null +++ b/src/app/perfil-usuario/perfil-usuario.page.html @@ -0,0 +1,14 @@ + + + Mi perfil + + + + + 0"> + + Tu código: {{codigo.codigo}} + + + + diff --git a/src/app/perfil-usuario/perfil-usuario.page.scss b/src/app/perfil-usuario/perfil-usuario.page.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/perfil-usuario/perfil-usuario.page.spec.ts b/src/app/perfil-usuario/perfil-usuario.page.spec.ts new file mode 100644 index 0000000..0fb6f7e --- /dev/null +++ b/src/app/perfil-usuario/perfil-usuario.page.spec.ts @@ -0,0 +1,24 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { IonicModule } from '@ionic/angular'; + +import { PerfilUsuarioPage } from './perfil-usuario.page'; + +describe('PerfilUsuarioPage', () => { + let component: PerfilUsuarioPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ PerfilUsuarioPage ], + imports: [IonicModule.forRoot()] + }).compileComponents(); + + fixture = TestBed.createComponent(PerfilUsuarioPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/perfil-usuario/perfil-usuario.page.ts b/src/app/perfil-usuario/perfil-usuario.page.ts new file mode 100644 index 0000000..e11eb02 --- /dev/null +++ b/src/app/perfil-usuario/perfil-usuario.page.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import { Codigo } from '../interfaces/codigo'; +import { ApiService } from '../services/api.service'; +import { LoginService } from '../services/login.service'; + +@Component({ + selector: 'app-perfil-usuario', + templateUrl: './perfil-usuario.page.html', + styleUrls: ['./perfil-usuario.page.scss'], +}) +export class PerfilUsuarioPage implements OnInit { + + codigos: Codigo[]; + + constructor(private apiService: ApiService, private loginService: LoginService) { } + + ngOnInit() { + this.apiService.getCodigosUsuario(this.loginService.user) + .subscribe(codigos => { + this.codigos = codigos; + console.log(this.codigos); + }) + } + +} diff --git a/src/app/services/api.service.ts b/src/app/services/api.service.ts index d4553f4..45d1d1f 100644 --- a/src/app/services/api.service.ts +++ b/src/app/services/api.service.ts @@ -3,6 +3,7 @@ import { HttpClient } from '@angular/common/http'; import { Observable, throwError, BehaviorSubject } from 'rxjs'; import { catchError, retry, map, tap } from 'rxjs/operators'; import { User } from '../interfaces/user'; +import { Codigo } from '../interfaces/codigo' import { Discoteca } from '../discoteca'; import { UserLogin } from '../interfaces/user-login'; import { DiscotecaI } from '../interfaces/discoteca-i'; @@ -56,6 +57,10 @@ export class ApiService { return this.http.post(this.baseUrl+"/reserva", reserva); } + getCodigosUsuario(user: User){ + return this.http.post(this.baseUrl+"/codigosUsuario", user); + } + diff --git a/src/app/tab3/tab3-routing.module.ts b/src/app/tab3/tab3-routing.module.ts index 5d6abde..e79e200 100644 --- a/src/app/tab3/tab3-routing.module.ts +++ b/src/app/tab3/tab3-routing.module.ts @@ -1,11 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { PerfilUsuarioPage } from '../perfil-usuario/perfil-usuario.page'; import { Tab3Page } from './tab3.page'; const routes: Routes = [ { path: '', - component: Tab3Page, + component: PerfilUsuarioPage, } ]; diff --git a/src/app/tabs-user/tabs-user.page.html b/src/app/tabs-user/tabs-user.page.html index b0982d7..710aeac 100644 --- a/src/app/tabs-user/tabs-user.page.html +++ b/src/app/tabs-user/tabs-user.page.html @@ -8,7 +8,7 @@ - Me + Mi Perfil