Si el usuario es tipo 0 (gestor de discoteca) muestra la discoteca asociada al gestor en la BD

This commit is contained in:
2021-03-18 18:04:58 +01:00
parent de5a925e38
commit 660f19932c
5 changed files with 41 additions and 10 deletions

View File

@@ -5,6 +5,9 @@ import { Discoteca } from '../discoteca'
import { Evento } from '../evento';
import { FormControl, FormGroup } from '@angular/forms';
import { NumericValueAccessor } from '@ionic/angular';
import { DiscotecaI } from '../discoteca-i';
import { ApiService } from '../api.service';
import { Router } from '@angular/router';
@Injectable({
@@ -13,13 +16,14 @@ import { NumericValueAccessor } from '@ionic/angular';
export class Tab1Service implements OnInit{
discoteca: Discoteca;
discotecaI: DiscotecaI;
galeria: string[];
eventos: Evento[];
eventoForms: FormGroup[];
eventoIndex: number;
editarEvento: boolean;
constructor() {
constructor(private apiService: ApiService, private router: Router) {
}
@@ -29,9 +33,9 @@ export class Tab1Service implements OnInit{
initValues(): void{
this.discoteca = new Discoteca();
this.discoteca.setNombre('Barraca');
this.discoteca.setTelefono(666666666);
this.discoteca.setLocalizacion('Calle del Barquillo');
this.discoteca.setNombre(this.discotecaI.nombre);
this.discoteca.setTelefono(this.discotecaI.telefono);
this.discoteca.setLocalizacion(this.discotecaI.localizacion);
this.galeria = [];
this.initEventos();
this.editarEvento = false;
@@ -73,4 +77,16 @@ export class Tab1Service implements OnInit{
return this.eventos[eventoIndex];
}
getDiscoteca(discotecaId: number){
if (discotecaId != 0){
this.apiService.getUserDiscoteca(discotecaId)
.subscribe(discoteca => {
this.discotecaI = discoteca[0];
console.log(this.discotecaI);
this.initValues();
this.router.navigate(['/tabs/tab1/perfil-discoteca']);
})
}
}
}