Se pueden ver eventos desde usuario cliente. Hay código (algo) duplicado

This commit is contained in:
onsaliyo 2021-05-12 18:16:12 +02:00
parent 277ad1d88a
commit 4aa238ab9e
11 changed files with 136 additions and 2 deletions

View File

@ -37,6 +37,14 @@ const routes: Routes = [
path: 'feed', path: 'feed',
loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule) loadChildren: () => import('./feed/feed.module').then( m => m.FeedPageModule)
}, },
{
path: 'vieweventocliente',
loadChildren: () => import('./vieweventocliente/vieweventocliente.module').then( m => m.VieweventoclientePageModule)
},
{
path: 'view-evento-cliente',
loadChildren: () => import('./view-evento-cliente/view-evento-cliente.module').then( m => m.ViewEventoClientePageModule)
},

View File

@ -18,7 +18,6 @@
{{evento.fecha}} · {{evento.fecha}} ·
<ion-icon name="cash-outline"></ion-icon> <ion-icon name="cash-outline"></ion-icon>
{{evento.precio1}},{{evento.precio2}} {{evento.precio1}},{{evento.precio2}}
<ion-button (click)="editarEvento(evento);$event.stopPropagation();"><ion-icon name="pencil-outline"></ion-icon></ion-button>
</div> </div>
<div class="eventoDesc"> <div class="eventoDesc">
{{evento.descripcion}} {{evento.descripcion}}

View File

@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Eventoi } from '../interfaces/eventoi'; import { Eventoi } from '../interfaces/eventoi';
import { FeedService } from '../services/feed.service'; import { FeedService } from '../services/feed.service';
import { Tab1Service } from '../tab1/tab1.service';
@Component({ @Component({
selector: 'app-feed', selector: 'app-feed',
@ -11,10 +13,15 @@ export class FeedPage implements OnInit {
eventos: Eventoi[]; eventos: Eventoi[];
constructor(private feedService:FeedService) { } constructor(private feedService:FeedService, private tab1Service: Tab1Service, private router:Router ) { }
ngOnInit() { ngOnInit() {
this.eventos = this.feedService.eventos; this.eventos = this.feedService.eventos;
} }
mostrarEvento(evento: Eventoi){
this.feedService.eventoIndex = this.eventos.indexOf(evento);
this.router.navigate(['/tabs/tab2/view-evento-cliente']);
}
} }

View File

@ -9,6 +9,7 @@ import { ApiService } from './api.service';
export class FeedService { export class FeedService {
eventos: Eventoi[]; eventos: Eventoi[];
eventoIndex: number;
constructor(private apiService: ApiService, private router: Router) { } constructor(private apiService: ApiService, private router: Router) { }
@ -19,4 +20,10 @@ export class FeedService {
this.router.navigate(['/tabsUser']) this.router.navigate(['/tabsUser'])
}) })
} }
getEventoByIndex(eventoIndex: number):Eventoi{
return this.eventos[eventoIndex];
}
} }

View File

@ -2,11 +2,18 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router'; import { RouterModule, Routes } from '@angular/router';
import { FeedPage } from '../feed/feed.page'; import { FeedPage } from '../feed/feed.page';
import { Tab2Page } from './tab2.page'; import { Tab2Page } from './tab2.page';
import { ViewEventoClientePage } from '../view-evento-cliente/view-evento-cliente.page';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', path: '',
component: FeedPage, component: FeedPage,
},
{
path: 'view-evento-cliente',
component: ViewEventoClientePage
} }
]; ];

View File

@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ViewEventoClientePage } from './view-evento-cliente.page';
const routes: Routes = [
{
path: '',
component: ViewEventoClientePage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ViewEventoClientePageRoutingModule {}

View 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 { ViewEventoClientePageRoutingModule } from './view-evento-cliente-routing.module';
import { ViewEventoClientePage } from './view-evento-cliente.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ViewEventoClientePageRoutingModule
],
declarations: [ViewEventoClientePage]
})
export class ViewEventoClientePageModule {}

View File

@ -0,0 +1,26 @@
<ion-header>
<ion-toolbar>
<ion-title>ViewEvento</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-grid>
<div class="evento">
<ion-row>
<div class="eventoHeader">
{{evento.nombre}} ·
<ion-icon name="calendar-outline"></ion-icon>
{{evento.fecha}} ·
<ion-icon name="cash-outline"></ion-icon>
{{evento.precio1}},{{evento.precio2}}
</div>
</ion-row>
<ion-row>
<div class="eventoDesc">
{{evento.descripcion}}
</div>
</ion-row>
</div>
</ion-grid>
</ion-content>

View File

@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ViewEventoClientePage } from './view-evento-cliente.page';
describe('ViewEventoClientePage', () => {
let component: ViewEventoClientePage;
let fixture: ComponentFixture<ViewEventoClientePage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ViewEventoClientePage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ViewEventoClientePage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { Eventoi } from '../interfaces/eventoi';
import { FeedService } from '../services/feed.service';
@Component({
selector: 'app-view-evento-cliente',
templateUrl: './view-evento-cliente.page.html',
styleUrls: ['./view-evento-cliente.page.scss'],
})
export class ViewEventoClientePage implements OnInit {
evento: Eventoi;
constructor(private feedService: FeedService) { }
ngOnInit() {
this.evento = this.feedService.getEventoByIndex(this.feedService.eventoIndex);
}
}