Compare commits
5 Commits
FrontEndDe
...
e31ded9eb9
| Author | SHA1 | Date | |
|---|---|---|---|
| e31ded9eb9 | |||
| 9817883235 | |||
| 024f768da9 | |||
| 287f457a11 | |||
| ff4645dd58 |
@@ -45,6 +45,10 @@ const routes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'view-discoteca-cliente',
|
path: 'view-discoteca-cliente',
|
||||||
loadChildren: () => import('./view-discoteca-cliente/view-discoteca-cliente.module').then( m => m.ViewDiscotecaClientePageModule)
|
loadChildren: () => import('./view-discoteca-cliente/view-discoteca-cliente.module').then( m => m.ViewDiscotecaClientePageModule)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'reservamodal',
|
||||||
|
loadChildren: () => import('./reservamodal/reservamodal.module').then( m => m.ReservamodalPageModule)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
8
src/app/interfaces/reservai.ts
Normal file
8
src/app/interfaces/reservai.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
export interface Reservai {
|
||||||
|
UserID: number,
|
||||||
|
EventoID: number,
|
||||||
|
codigoDescuento: string,
|
||||||
|
codigoUnico: string,
|
||||||
|
codigoUnicoID: number,
|
||||||
|
descuentoPorciento: number
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
export interface User {
|
export interface User {
|
||||||
id: number;
|
userID: number;
|
||||||
discotecaID: number;
|
discotecaID: number;
|
||||||
userType: number;
|
userType: number;
|
||||||
username: string;
|
username: string;
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|||||||
import { Tab1Service } from '../tab1/tab1.service';
|
import { Tab1Service } from '../tab1/tab1.service';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Eventoi } from '../interfaces/eventoi';
|
import { Eventoi } from '../interfaces/eventoi';
|
||||||
import { DatePipe } from '@angular/common'
|
|
||||||
import { ViewEventoPageRoutingModule } from '../view-evento/view-evento-routing.module';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-prompt-evento',
|
selector: 'app-prompt-evento',
|
||||||
|
|||||||
17
src/app/reservamodal/reservamodal-routing.module.ts
Normal file
17
src/app/reservamodal/reservamodal-routing.module.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { Routes, RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import { ReservamodalPage } from './reservamodal.page';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: ReservamodalPage
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule],
|
||||||
|
})
|
||||||
|
export class ReservamodalPageRoutingModule {}
|
||||||
20
src/app/reservamodal/reservamodal.module.ts
Normal file
20
src/app/reservamodal/reservamodal.module.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
import { IonicModule } from '@ionic/angular';
|
||||||
|
|
||||||
|
import { ReservamodalPageRoutingModule } from './reservamodal-routing.module';
|
||||||
|
|
||||||
|
import { ReservamodalPage } from './reservamodal.page';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
FormsModule,
|
||||||
|
IonicModule,
|
||||||
|
ReservamodalPageRoutingModule
|
||||||
|
],
|
||||||
|
declarations: [ReservamodalPage]
|
||||||
|
})
|
||||||
|
export class ReservamodalPageModule {}
|
||||||
9
src/app/reservamodal/reservamodal.page.html
Normal file
9
src/app/reservamodal/reservamodal.page.html
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<ion-header>
|
||||||
|
<ion-toolbar>
|
||||||
|
<ion-title>reservamodal</ion-title>
|
||||||
|
</ion-toolbar>
|
||||||
|
</ion-header>
|
||||||
|
|
||||||
|
<ion-content>
|
||||||
|
{{codigoReserva}}
|
||||||
|
</ion-content>
|
||||||
0
src/app/reservamodal/reservamodal.page.scss
Normal file
0
src/app/reservamodal/reservamodal.page.scss
Normal file
24
src/app/reservamodal/reservamodal.page.spec.ts
Normal file
24
src/app/reservamodal/reservamodal.page.spec.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { IonicModule } from '@ionic/angular';
|
||||||
|
|
||||||
|
import { ReservamodalPage } from './reservamodal.page';
|
||||||
|
|
||||||
|
describe('ReservamodalPage', () => {
|
||||||
|
let component: ReservamodalPage;
|
||||||
|
let fixture: ComponentFixture<ReservamodalPage>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ ReservamodalPage ],
|
||||||
|
imports: [IonicModule.forRoot()]
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(ReservamodalPage);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
18
src/app/reservamodal/reservamodal.page.ts
Normal file
18
src/app/reservamodal/reservamodal.page.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { NavParams } from '@ionic/angular';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-reservamodal',
|
||||||
|
templateUrl: './reservamodal.page.html',
|
||||||
|
styleUrls: ['./reservamodal.page.scss'],
|
||||||
|
})
|
||||||
|
export class ReservamodalPage implements OnInit {
|
||||||
|
|
||||||
|
codigoReserva: string;
|
||||||
|
constructor(private navParams: NavParams) { }
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.codigoReserva = this.navParams.get('codigo');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import { Discoteca } from '../discoteca';
|
|||||||
import { UserLogin } from '../interfaces/user-login';
|
import { UserLogin } from '../interfaces/user-login';
|
||||||
import { DiscotecaI } from '../interfaces/discoteca-i';
|
import { DiscotecaI } from '../interfaces/discoteca-i';
|
||||||
import { Eventoi } from '../interfaces/eventoi';
|
import { Eventoi } from '../interfaces/eventoi';
|
||||||
|
import { Reservai } from '../interfaces/reservai';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@@ -51,6 +52,10 @@ export class ApiService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
creaReserva(reserva: Reservai): Observable<Reservai>{
|
||||||
|
return this.http.post<Reservai>(this.baseUrl+"/reserva", reserva);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
src/app/services/codigoreserva.service.spec.ts
Normal file
16
src/app/services/codigoreserva.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { CodigoreservaService } from './codigoreserva.service';
|
||||||
|
|
||||||
|
describe('CodigoreservaService', () => {
|
||||||
|
let service: CodigoreservaService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(CodigoreservaService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
27
src/app/services/codigoreserva.service.ts
Normal file
27
src/app/services/codigoreserva.service.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CodigoreservaService {
|
||||||
|
|
||||||
|
codigo: string;
|
||||||
|
length: number;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
generarAleatorio(){
|
||||||
|
this.length = 7;
|
||||||
|
var result = [];
|
||||||
|
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||||
|
var charactersLength = characters.length;
|
||||||
|
for ( var i = 0; i < this.length; i++ ) {
|
||||||
|
result.push(characters.charAt(Math.floor(Math.random() *
|
||||||
|
charactersLength)));
|
||||||
|
}
|
||||||
|
return result.join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ export class LoginService {
|
|||||||
|
|
||||||
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
|
constructor(private apiService: ApiService, private router: Router, private tab1service: Tab1Service, private feedService: FeedService) {
|
||||||
this.user = {
|
this.user = {
|
||||||
id: 0,
|
userID: 0,
|
||||||
discotecaID: 0,
|
discotecaID: 0,
|
||||||
userType: 0,
|
userType: 0,
|
||||||
username: '',
|
username: '',
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export class ViewDiscotecaClientePage implements OnInit {
|
|||||||
constructor(private feedService: FeedService) { }
|
constructor(private feedService: FeedService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.eventos = [];
|
||||||
this.discoteca = this.feedService.discotecaEvento;
|
this.discoteca = this.feedService.discotecaEvento;
|
||||||
this.feedService.eventos.forEach(evento => {
|
this.feedService.eventos.forEach(evento => {
|
||||||
if (this.discoteca.discotecaID == evento.discotecaID){
|
if (this.discoteca.discotecaID == evento.discotecaID){
|
||||||
|
|||||||
@@ -26,6 +26,14 @@
|
|||||||
<a [routerLink]="['/tabsUser/tab2/view-discoteca-cliente']">{{discoteca?.nombre}}</a>
|
<a [routerLink]="['/tabsUser/tab2/view-discoteca-cliente']">{{discoteca?.nombre}}</a>
|
||||||
</div>
|
</div>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<ion-button (click)="openReserva()">
|
||||||
|
Reserva
|
||||||
|
</ion-button>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row>
|
||||||
|
<span>Código de descuento: </span><input type="text" id="codigoDescuento">
|
||||||
|
</ion-row>
|
||||||
</div>
|
</div>
|
||||||
</ion-grid>
|
</ion-grid>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
|
import { stringify } from '@angular/compiler/src/util';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { ModalController } from '@ionic/angular';
|
||||||
import { DiscotecaI } from '../interfaces/discoteca-i';
|
import { DiscotecaI } from '../interfaces/discoteca-i';
|
||||||
import { Eventoi } from '../interfaces/eventoi';
|
import { Eventoi } from '../interfaces/eventoi';
|
||||||
|
import { Reservai } from '../interfaces/reservai';
|
||||||
|
import { ReservamodalPage } from '../reservamodal/reservamodal.page';
|
||||||
|
import { ApiService } from '../services/api.service';
|
||||||
|
import { CodigoreservaService } from '../services/codigoreserva.service';
|
||||||
import { FeedService } from '../services/feed.service';
|
import { FeedService } from '../services/feed.service';
|
||||||
|
import { LoginService } from '../services/login.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-view-evento-cliente',
|
selector: 'app-view-evento-cliente',
|
||||||
@@ -12,11 +19,60 @@ export class ViewEventoClientePage implements OnInit {
|
|||||||
|
|
||||||
evento: Eventoi;
|
evento: Eventoi;
|
||||||
discoteca: DiscotecaI;
|
discoteca: DiscotecaI;
|
||||||
constructor(private feedService: FeedService) { }
|
reserva: Reservai;
|
||||||
|
codigoReserva: string;
|
||||||
|
reservaRealizada: boolean;
|
||||||
|
|
||||||
|
constructor(private feedService: FeedService, private modalController: ModalController,
|
||||||
|
private codigoReservaService: CodigoreservaService, private loginService: LoginService, private apiService: ApiService) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.reservaRealizada = false;
|
||||||
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
|
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
|
||||||
this.discoteca = this.feedService.discotecaEvento;
|
this.discoteca = this.feedService.discotecaEvento;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generarCodigo(){
|
||||||
|
return stringify(this.codigoReservaService.generarAleatorio());
|
||||||
|
}
|
||||||
|
|
||||||
|
initReserva(){
|
||||||
|
this.reserva = {
|
||||||
|
UserID: this.loginService.user.userID,
|
||||||
|
EventoID: this.evento.id,
|
||||||
|
codigoDescuento: null,
|
||||||
|
codigoUnico: '',
|
||||||
|
codigoUnicoID: null,
|
||||||
|
descuentoPorciento: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openReserva(){
|
||||||
|
this.initReserva();
|
||||||
|
this.reserva.codigoDescuento = (<HTMLInputElement>document.getElementById("codigoDescuento")).value;
|
||||||
|
this.reserva.codigoUnico = this.generarCodigo();
|
||||||
|
this.creaReserva(this.reserva);
|
||||||
|
}
|
||||||
|
|
||||||
|
creaReserva(reserva){
|
||||||
|
this.apiService.creaReserva(reserva)
|
||||||
|
.subscribe(
|
||||||
|
data => {
|
||||||
|
console.log(data);
|
||||||
|
this.reserva = data;
|
||||||
|
this.reservaRealizada = true;
|
||||||
|
this.modalController.create({
|
||||||
|
component: ReservamodalPage,
|
||||||
|
componentProps : {
|
||||||
|
codigo: this.reserva.codigoUnico
|
||||||
|
}
|
||||||
|
|
||||||
|
}).then(modal => modal.present());
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user