Updated to angular 11
Now compiling with strict mode in typescript Need to error checking now
This commit is contained in:
@ -17,10 +17,10 @@ import { CashierReportService } from './cashier-report.service';
|
||||
styleUrls: ['./cashier-report.component.css'],
|
||||
})
|
||||
export class CashierReportComponent implements OnInit {
|
||||
dataSource: CashierReportDataSource;
|
||||
activeCashiers: User[] = [];
|
||||
info: CashierReport = new CashierReport();
|
||||
dataSource: CashierReportDataSource = new CashierReportDataSource(this.info.amounts);
|
||||
form: FormGroup;
|
||||
activeCashiers: User[];
|
||||
info: CashierReport;
|
||||
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
@ -33,11 +33,17 @@ export class CashierReportComponent implements OnInit {
|
||||
private toaster: ToasterService,
|
||||
private ser: CashierReportService,
|
||||
) {
|
||||
this.createForm();
|
||||
// Create form
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
cashier: '',
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((data: { cashiers: User[]; info: CashierReport }) => {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { cashiers: User[]; info: CashierReport };
|
||||
this.activeCashiers = data.cashiers;
|
||||
this.info = data.info;
|
||||
this.form.setValue({
|
||||
@ -64,7 +70,7 @@ export class CashierReportComponent implements OnInit {
|
||||
}
|
||||
|
||||
print() {
|
||||
this.ser.print(this.info.cashier.id, this.info.startDate, this.info.finishDate).subscribe(
|
||||
this.ser.print(this.info.cashier.id as string, this.info.startDate, this.info.finishDate).subscribe(
|
||||
() => {
|
||||
this.toaster.show('', 'Successfully Printed');
|
||||
},
|
||||
@ -74,23 +80,15 @@ export class CashierReportComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
startDate: '',
|
||||
finishDate: '',
|
||||
cashier: '',
|
||||
});
|
||||
}
|
||||
|
||||
getInfo(): CashierReport {
|
||||
const formModel = this.form.value;
|
||||
|
||||
return {
|
||||
return new CashierReport({
|
||||
cashier: new User({ id: formModel.cashier }),
|
||||
cashiers: this.info.cashiers,
|
||||
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
|
||||
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY'),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
exportCsv() {
|
||||
|
||||
Reference in New Issue
Block a user