toSignal via Gemini
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatRippleModule } from '@angular/material/core';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
@@ -7,8 +7,9 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { Regime } from '../../core/regime';
|
||||
import { Table } from '../../core/table';
|
||||
import { RegimeService } from '../../regimes/regime.service';
|
||||
import { TableService } from '../../tables/table.service';
|
||||
import { BillNumberComponent } from '../bill-number/bill-number.component';
|
||||
|
||||
@Component({
|
||||
@@ -17,22 +18,19 @@ import { BillNumberComponent } from '../bill-number/bill-number.component';
|
||||
styleUrls: ['./running-tables.component.sass'],
|
||||
imports: [CurrencyPipe, MatRippleModule, MatCardModule],
|
||||
})
|
||||
export class RunningTablesComponent implements OnInit {
|
||||
export class RunningTablesComponent {
|
||||
private tableService = inject(TableService);
|
||||
private regimeService = inject(RegimeService);
|
||||
private dialog = inject(MatDialog);
|
||||
private router = inject(Router);
|
||||
private route = inject(ActivatedRoute);
|
||||
private snackBar = inject(MatSnackBar);
|
||||
regimesResource = this.regimeService.list();
|
||||
|
||||
regimes: Regime[] = [];
|
||||
list: Table[] = [];
|
||||
listResource = this.tableService.running();
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Table[]; regimes: Regime[] };
|
||||
this.regimes = data.regimes;
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
regimes = computed(() => this.regimesResource.value() ?? []);
|
||||
list = computed(() => this.listResource.value() ?? []);
|
||||
|
||||
navigateToBill(table: Table): void {
|
||||
const qp = { table: table.id };
|
||||
@@ -49,7 +47,7 @@ export class RunningTablesComponent implements OnInit {
|
||||
|
||||
openBill() {
|
||||
return this.dialog
|
||||
.open(BillNumberComponent, { data: this.regimes })
|
||||
.open(BillNumberComponent, { data: this.regimes() })
|
||||
.afterClosed()
|
||||
.pipe(
|
||||
map((x) => {
|
||||
|
||||
Reference in New Issue
Block a user