Skip to content

Commit

Permalink
Merge pull request #43 from DLL-S/desenvolvimento
Browse files Browse the repository at this point in the history
Correções na ordenação e listagem
  • Loading branch information
lucasdemoraesc authored Jul 24, 2022
2 parents 2e4348a + 5ba02d7 commit e99980a
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export class ComandaViewComponent implements OnInit {
}

getValorToral(pedido: Pedido) {
return pedido.produtosDoPedido.reduce((partialSum, a) => partialSum + (a.produto.preco * a.quantidade), 0);
return pedido.produtosDoPedido.reduce((partialSum, a) => partialSum + (a.valorUnitario * a.quantidade), 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class ComandasListComponent implements OnInit, OnDestroy, AfterViewInit {
return this.comandasService.pesquisar(
this.paginator?.pageIndex + 1,
this.paginator?.pageSize || this.tamanhosPaginacao[ 0 ],
(this.sort?.direction === "desc" ? 1 : -1) || -1
(this.sort?.direction === "asc" ? 1 : -1) || 1
);
}

Expand All @@ -111,15 +111,6 @@ export class ComandasListComponent implements OnInit, OnDestroy, AfterViewInit {
this.comandasService.pesquisarV2(this.termoBuscado, termoDeBusca).subscribe();
}

paginar(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
this.comandasService.pesquisar(
this.paginator?.pageIndex || 0,
this.paginator?.pageSize || 10,
(this.sort?.direction == "asc" ? 1 : -1) || 1,
).subscribe();
}

abrirDialogoDeVisualizacao(comanda?: Comanda) {
const dialogRef = this.dialog.open(ComandaViewComponent, {
width: "640px",
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/comandas/services/comandas.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ComandasService extends GenericApi<Comanda> {
}

public pesquisarV2(termoBuscado: string, termoDeBusca: string) {
return this.http.get<ResponseModel<Comanda>>(`${ this.apiBaseUrl }/v2?termoBuscado=${ termoBuscado }&termoDeBusca=${ termoDeBusca }&ordem=-1`)
return this.http.get<ResponseModel<Comanda>>(`${ this.apiBaseUrl }/v2?termoBuscado=${ termoBuscado }&termoDeBusca=${ termoDeBusca }&ordem=1`)
.pipe(
take(1),
tap(next => this.state.set(next?.resultados, "comandas"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class MesasEditDialogComponent implements OnInit {
this.formMesa = this.formBuilder.group({
id: [ { value: this.data?.id, disabled: true }, [ Validators.required ] ],
numero: [ this.data?.numero, [ Validators.required, Validators.min(1) ] ],
disponivel: [ this.data?.disponivel || false, [ Validators.required ] ]
disponivel: [ this.data?.disponivel || true, [ Validators.required ] ]
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class PedidosListComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.scheduler = setInterval(() => {
this.atualizarDados();
}, 60000);
}, 30000);
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export class ProdutoEditDialogComponent implements OnInit {
next: result => {
this.produtoService.atualizaState(result);
this.notificationService.exibir(`Produto ${ produtoEditado.id } atualizado com sucesso!`);
this.dialogRef.close();
this.dialogRef.close(result);
}
});
else
this.produtoService.criar(produtoEditado).subscribe({
next: result => {
this.produtoService.adicionaState(result);
this.notificationService.exibir(`Produto cadastrado com o ID ${ result.id }!`);
this.dialogRef.close();
this.dialogRef.close(result);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ export class ProdutosListComponent implements OnInit, OnDestroy, AfterViewInit {

dialogRef.afterClosed()
.pipe(take(1))
.subscribe(result => { });
.subscribe(result => {
if (result)
this.produtoService.atualizaState(result);
});
}

toggleRowExpanded(produtoClicado: Produto) {
Expand Down

0 comments on commit e99980a

Please sign in to comment.