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">
{{evento.descripcion}}
</div>
<div class="discotecaEvento">
{{discotecas[idsDiscoteca.indexOf(evento.discotecaID)]?.nombre}}
</div>
</div>
</ion-item>
</ion-list>

View File

@ -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]);
})
}
)
}
}

View File

@ -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) { }

View File

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

View File

@ -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;
}
}