se tiene la discoteca asociada a los eventos en Feed y view Evento Cliente

This commit is contained in:
onsaliyo 2021-05-13 17:47:34 +02:00
parent 3c2976437d
commit 59f0fcc724
5 changed files with 48 additions and 2 deletions

View File

@ -22,6 +22,9 @@
<div class="eventoDesc"> <div class="eventoDesc">
{{evento.descripcion}} {{evento.descripcion}}
</div> </div>
<div class="discotecaEvento">
{{discotecas[idsDiscoteca.indexOf(evento.discotecaID)]?.nombre}}
</div>
</div> </div>
</ion-item> </ion-item>
</ion-list> </ion-list>

View File

@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { ApiService } from '../services/api.service';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
import { Tab1Service } from '../tab1/tab1.service'; import { Tab1Service } from '../tab1/tab1.service';
@ -12,16 +14,47 @@ import { Tab1Service } from '../tab1/tab1.service';
export class FeedPage implements OnInit { export class FeedPage implements OnInit {
eventos: Eventoi[]; eventos: Eventoi[];
discotecas: DiscotecaI[];
constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router ) { } idsDiscoteca: number[];
constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router, private apiService: ApiService ) { }
ngOnInit() { ngOnInit() {
this.eventos = this.feedService.eventos; this.eventos = this.feedService.eventos;
this.idsDiscoteca = [];
this.discotecas=[];
this.getDiscotecasDistintas();
} }
mostrarEvento(evento: Eventoi){ mostrarEvento(evento: Eventoi){
this.feedService.eventoIndex = this.eventos.indexOf(evento); 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']); 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]);
})
}
)
}
} }

View File

@ -1,5 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { ApiService } from './api.service'; import { ApiService } from './api.service';
@ -10,6 +11,7 @@ export class FeedService {
eventos: Eventoi[]; eventos: Eventoi[];
eventoIndex: number; eventoIndex: number;
discotecaEvento: DiscotecaI;
constructor(private apiService: ApiService, private router: Router) { } constructor(private apiService: ApiService, private router: Router) { }

View File

@ -21,6 +21,11 @@
{{evento.descripcion}} {{evento.descripcion}}
</div> </div>
</ion-row> </ion-row>
<ion-row>
<div class="discotecaEvento">
{{discoteca?.nombre}}
</div>
</ion-row>
</div> </div>
</ion-grid> </ion-grid>
</ion-content> </ion-content>

View File

@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { DiscotecaI } from '../interfaces/discoteca-i';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
@ -10,10 +11,12 @@ import { FeedService } from '../services/feed.service';
export class ViewEventoClientePage implements OnInit { export class ViewEventoClientePage implements OnInit {
evento: Eventoi; evento: Eventoi;
discoteca: DiscotecaI;
constructor(private feedService: FeedService) { } constructor(private feedService: FeedService) { }
ngOnInit() { ngOnInit() {
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex); this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
this.discoteca = this.feedService.discotecaEvento;
} }
} }