diff --git a/src/app/content/hemat-app/cost-management/cost-management.component.ts b/src/app/content/hemat-app/cost-management/cost-management.component.ts index e5b1586..66b0f09 100644 --- a/src/app/content/hemat-app/cost-management/cost-management.component.ts +++ b/src/app/content/hemat-app/cost-management/cost-management.component.ts @@ -6,6 +6,7 @@ import { ModalAddActualComponent } from "./modal-add-actual/modal-add-actual.com import "chartist-plugin-tooltips"; import { ModalExportComponent } from "./modal-export/modal-export.component"; import { TableexcelService } from "src/app/_services/tableexcel.service"; +import { ToastrService } from "ngx-toastr"; @Component({ selector: "app-cost-management", @@ -46,7 +47,8 @@ export class CostManagementComponent implements OnInit { private monitoringApiService: BuildingService, private costService: CostManagementService, private modalService: NgbModal, - private tableexcelService: TableexcelService + private tableexcelService: TableexcelService, + private toastr: ToastrService, ) {} ngOnInit() { @@ -102,7 +104,6 @@ export class CostManagementComponent implements OnInit { roomId: item.room_id, })); console.log(this.data_cost); - }); } @@ -354,24 +355,22 @@ export class CostManagementComponent implements OnInit { } doFilter() { - // const requestData = { - // building: this.buildingSelected, - // category: this.categorySelected, - // date: this.dateSelected, - // searchTerm: this.searchTerm, - // }; - this.spinnerFilterActive = true; - setTimeout(() => { - this.spinnerFilterActive = false; - this.fetchData( - this.buildingSelected, - this.dateSelected, - this.categorySelected - ); - // this.dataCompWaterElectCost(this.buildingSelected); - // this.dataCompPrevMonthCost(this.buildingSelected); - // this.dataCompActEstCost(this.buildingSelected); - }, 3000); + if (this.dateSelected) { + this.spinnerFilterActive = true; + setTimeout(() => { + this.spinnerFilterActive = false; + this.fetchData( + this.buildingSelected, + this.dateSelected, + this.categorySelected + ); + }, 3000); + } else { + this.toastr.error("Warning", "Format date tidak valid.", { + timeOut: 5000, + closeButton: true, + }); + } } addFieldValue() {