From 59f0fcc724824c75b434e9848df485eb5eebb4ea Mon Sep 17 00:00:00 2001 From: onsaliyo Date: Thu, 13 May 2021 17:47:34 +0200 Subject: [PATCH] se tiene la discoteca asociada a los eventos en Feed y view Evento Cliente --- src/app/feed/feed.page.html | 3 ++ src/app/feed/feed.page.ts | 37 ++++++++++++++++++- src/app/services/feed.service.ts | 2 + .../view-evento-cliente.page.html | 5 +++ .../view-evento-cliente.page.ts | 3 ++ 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/app/feed/feed.page.html b/src/app/feed/feed.page.html index fd150bf..9c09003 100644 --- a/src/app/feed/feed.page.html +++ b/src/app/feed/feed.page.html @@ -22,6 +22,9 @@
{{evento.descripcion}}
+
+ {{discotecas[idsDiscoteca.indexOf(evento.discotecaID)]?.nombre}} +
diff --git a/src/app/feed/feed.page.ts b/src/app/feed/feed.page.ts index e392ccc..f224008 100644 --- a/src/app/feed/feed.page.ts +++ b/src/app/feed/feed.page.ts @@ -1,6 +1,8 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { Eventoi } from '../interfaces/eventoi'; +import { DiscotecaI } from '../interfaces/discoteca-i'; +import { ApiService } from '../services/api.service'; import { FeedService } from '../services/feed.service'; import { Tab1Service } from '../tab1/tab1.service'; @@ -12,16 +14,47 @@ import { Tab1Service } from '../tab1/tab1.service'; export class FeedPage implements OnInit { eventos: Eventoi[]; - - constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router ) { } + discotecas: DiscotecaI[]; + idsDiscoteca: number[]; + constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router, private apiService: ApiService ) { } ngOnInit() { this.eventos = this.feedService.eventos; + this.idsDiscoteca = []; + this.discotecas=[]; + this.getDiscotecasDistintas(); } mostrarEvento(evento: Eventoi){ + this.feedService.eventoIndex = this.eventos.indexOf(evento); + let discotecaDelEvento: DiscotecaI = this.discotecas[this.idsDiscoteca.indexOf(evento.discotecaID)]; + console.log(discotecaDelEvento); + this.feedService.discotecaEvento = discotecaDelEvento; this.router.navigate(['/tabsUser/tab2/view-evento-cliente']); + } + getDiscotecasDistintas(){ + this.eventos.forEach( + evento => { + if(!(this.idsDiscoteca.find(id => evento.discotecaID==id))){ + this.idsDiscoteca.push(evento.discotecaID); + } + } + ) + + this.idsDiscoteca.forEach( + idDiscoteca => { + this.apiService.getUserDiscoteca(idDiscoteca) + .subscribe(discoteca => { + console.log(discoteca[0]); + this.discotecas.push(discoteca[0]); + }) + } + ) + } + + + } diff --git a/src/app/services/feed.service.ts b/src/app/services/feed.service.ts index 25e5322..62b4d40 100644 --- a/src/app/services/feed.service.ts +++ b/src/app/services/feed.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; +import { DiscotecaI } from '../interfaces/discoteca-i'; import { Eventoi } from '../interfaces/eventoi'; import { ApiService } from './api.service'; @@ -10,6 +11,7 @@ export class FeedService { eventos: Eventoi[]; eventoIndex: number; + discotecaEvento: DiscotecaI; constructor(private apiService: ApiService, private router: Router) { } diff --git a/src/app/view-evento-cliente/view-evento-cliente.page.html b/src/app/view-evento-cliente/view-evento-cliente.page.html index e44a147..83661de 100644 --- a/src/app/view-evento-cliente/view-evento-cliente.page.html +++ b/src/app/view-evento-cliente/view-evento-cliente.page.html @@ -21,6 +21,11 @@ {{evento.descripcion}} + +
+ {{discoteca?.nombre}} +
+
diff --git a/src/app/view-evento-cliente/view-evento-cliente.page.ts b/src/app/view-evento-cliente/view-evento-cliente.page.ts index de3fec9..d9edc72 100644 --- a/src/app/view-evento-cliente/view-evento-cliente.page.ts +++ b/src/app/view-evento-cliente/view-evento-cliente.page.ts @@ -1,4 +1,5 @@ import { Component, OnInit } from '@angular/core'; +import { DiscotecaI } from '../interfaces/discoteca-i'; import { Eventoi } from '../interfaces/eventoi'; import { FeedService } from '../services/feed.service'; @@ -10,10 +11,12 @@ import { FeedService } from '../services/feed.service'; export class ViewEventoClientePage implements OnInit { evento: Eventoi; + discoteca: DiscotecaI; constructor(private feedService: FeedService) { } ngOnInit() { this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex); + this.discoteca = this.feedService.discotecaEvento; } }