60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
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';
|
|
|
|
@Component({
|
|
selector: 'app-feed',
|
|
templateUrl: './feed.page.html',
|
|
styleUrls: ['./feed.page.scss'],
|
|
})
|
|
export class FeedPage implements OnInit {
|
|
|
|
eventos: Eventoi[];
|
|
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)];
|
|
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]);
|
|
})
|
|
}
|
|
)
|
|
}
|
|
|
|
|
|
|
|
}
|