Commit 6fdce7ecdcb69b63b0ba41e8937688daa01bb2e2
1 parent
4d78c3d7a3
Exists in
develop
and in
1 other branch
agrego servicio de pedidos-salientes
Showing
4 changed files
with
75 additions
and
8 deletions
Show diff stats
src/app/modules/pedidos-salientes/pedidos-salientes.component.html
... | ... | @@ -9,11 +9,11 @@ |
9 | 9 | <h5 class="pt-3">ESTAMOS</h5> |
10 | 10 | <h3 class="font-weight-bold text-secondary">preparando</h3> |
11 | 11 | <h5>TU PEDIDO</h5> |
12 | - <div class="font-weight-bold mb-2 text-muted"> | |
13 | - <h1 class="display-4">47</h1> | |
14 | - <h1 class="display-4">48</h1> | |
15 | - <h1 class="display-4">49</h1> | |
16 | - <h1 class="display-4">50</h1> | |
12 | + <div | |
13 | + *ngFor="let pedido of pedidosPendientes; let i = index" | |
14 | + [hidden]="i == 0 || i > 4" | |
15 | + class="font-weight-bold mb-2 text-muted"> | |
16 | + <h1 class="display-4">{{rellenar(pedido.id.toString().slice(0), 3)}}</h1> | |
17 | 17 | </div> |
18 | 18 | </div> |
19 | 19 | </div> |
... | ... | @@ -21,8 +21,11 @@ |
21 | 21 | <div class="p-3 bg-white shadow-lg rounded text-center h-100"> |
22 | 22 | <h5 class="pt-3">LISTO PARA</h5> |
23 | 23 | <h3 class="font-weight-bold text-primary">retirar</h3> |
24 | - <h1 class="display-1 mt-4 text-primary">46</h1> | |
25 | - <h3 class="font-weight-bold text-info" style="color: yellowgreen;">¡Que lo disfrutes!</h3> | |
24 | + <div *ngIf="pedidosPendientes.length"> | |
25 | + | |
26 | + <h1 class="display-1 mt-4 text-primary">{{rellenar(pedidosPendientes[0].id.toString().slice(0), 3)}}</h1> | |
27 | + </div> | |
28 | + <h3 class="font-weight-bold text-info mt-4" style="color: yellowgreen;">¡Que lo disfrutes!</h3> | |
26 | 29 | </div> |
27 | 30 | </div> |
28 | 31 | </div> |
src/app/modules/pedidos-salientes/pedidos-salientes.component.ts
1 | 1 | import { Component, OnInit } from '@angular/core'; |
2 | +import { ComandaService } from 'src/app/services/comanda/comanda.service'; | |
2 | 3 | |
3 | 4 | @Component({ |
4 | 5 | selector: 'app-pedidos-salientes', |
... | ... | @@ -6,10 +7,42 @@ import { Component, OnInit } from '@angular/core'; |
6 | 7 | styleUrls: ['./pedidos-salientes.component.scss'] |
7 | 8 | }) |
8 | 9 | export class PedidosSalientesComponent implements OnInit { |
10 | + pedidosPendientes = []; | |
11 | + cicloTime; | |
9 | 12 | |
10 | - constructor() { } | |
13 | + constructor( | |
14 | + private comandaServices: ComandaService | |
15 | + ) { } | |
11 | 16 | |
12 | 17 | ngOnInit() { |
18 | + this.buscarPedidosPendientes(); | |
19 | + this.ciclo() | |
20 | + } | |
21 | + | |
22 | + ngOnDestroy() { | |
23 | + clearTimeout(this.cicloTime); | |
24 | + } | |
25 | + | |
26 | + buscarPedidosPendientes() { | |
27 | + this.comandaServices.getPendientesEntrega() | |
28 | + .subscribe((pedidos: []) => { | |
29 | + this.pedidosPendientes = pedidos | |
30 | + }) | |
31 | + } | |
32 | + | |
33 | + ciclo() { | |
34 | + this.cicloTime = setTimeout(() => { | |
35 | + this.buscarPedidosPendientes(); | |
36 | + this.ciclo(); | |
37 | + }, 5000) | |
38 | + } | |
39 | + | |
40 | + rellenar(relleno, longitud) { | |
41 | + relleno = '' + relleno; | |
42 | + while (relleno.length < longitud) { | |
43 | + relleno = '0' + relleno; | |
44 | + } | |
45 | + return relleno; | |
13 | 46 | } |
14 | 47 | |
15 | 48 | } |
src/app/services/comanda/comanda.service.spec.ts
... | ... | @@ -0,0 +1,12 @@ |
1 | +import { TestBed } from '@angular/core/testing'; | |
2 | + | |
3 | +import { ComandaService } from './comanda.service'; | |
4 | + | |
5 | +describe('ComandaService', () => { | |
6 | + beforeEach(() => TestBed.configureTestingModule({})); | |
7 | + | |
8 | + it('should be created', () => { | |
9 | + const service: ComandaService = TestBed.get(ComandaService); | |
10 | + expect(service).toBeTruthy(); | |
11 | + }); | |
12 | +}); |
src/app/services/comanda/comanda.service.ts
... | ... | @@ -0,0 +1,19 @@ |
1 | +import { Injectable } from '@angular/core'; | |
2 | +import { HttpClient } from "@angular/common/http"; | |
3 | +import { APP_SETTINGS } from "src/etc/AppSettings"; | |
4 | + | |
5 | +@Injectable({ | |
6 | + providedIn: 'root' | |
7 | +}) | |
8 | +export class ComandaService { | |
9 | + urlDeboSuite = APP_SETTINGS.apiDeboSuite; | |
10 | + | |
11 | + constructor( | |
12 | + private http: HttpClient, | |
13 | + ) { } | |
14 | + | |
15 | + getPendientesEntrega() { | |
16 | + return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`); | |
17 | + } | |
18 | + | |
19 | +} |