comanda.service.ts
1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { APP_SETTINGS } from 'src/etc/AppSettings';
import { IComanda } from 'src/app/interfaces/IComanda';
@Injectable({
providedIn: 'root'
})
export class ComandaService {
urlDeboSuite = APP_SETTINGS.apiDeboSuite;
constructor(
private http: HttpClient,
) { }
getPendientesEntrega() {
return this.http.get(`${this.urlDeboSuite}/comandas/pendientes-entrega`);
}
update(data: object) {
return this.http.post(`${this.urlDeboSuite}/comandas/update`, { data: data });
}
getAll() {
return this.http.get(`${this.urlDeboSuite}/comandas`);
}
imprimirComandaCocina(idComanda: number) {
return this.http.get(`${this.urlDeboSuite}/comandas/imprimir/${idComanda}`);
}
startTimerComanda(comanda: IComanda, tipo: string) {
let hours = 0;
let minutes = 0;
let seconds = 0;
comanda[`hours${tipo}`] = '0';
comanda[`seconds${tipo}`] = comanda[`minutes${tipo}`] = '00';
comanda[`timer${tipo}`] = setInterval(() => {
seconds++;
comanda[`seconds${tipo}`] = seconds < 10 ? `0${seconds}` : seconds.toString();
if (seconds === 60) {
minutes++;
comanda[`minutes${tipo}`] = minutes < 10 ? `0${minutes}` : minutes.toString();
seconds = 0;
comanda[`seconds${tipo}`] = '00';
}
if (minutes === 60) {
hours++;
minutes = 0;
comanda[`hours${tipo}`] = hours.toString();
comanda[`minutes${tipo}`] = '00';
}
}, 1000);
}
}