perbaikan master dan ngecek token jika ada kegiatan

This commit is contained in:
2024-07-16 11:39:44 +07:00
parent 751c36209e
commit dd1deb0812
10 changed files with 501 additions and 240 deletions

View File

@@ -86,7 +86,7 @@ export class MasterBuildingComponent {
if (result) {
if (
this.filteredRows.some(
(value) => value.name.toLowerCase() === result.name.toLowerCase()
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
@@ -127,23 +127,57 @@ export class MasterBuildingComponent {
modalRef.result.then(
(result) => {
if (result) {
console.log(result);
console.log(this.filteredRows);
if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status_id === result.statusId)) {
this.toastr.error("Warning", "Nama Gedung yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
if (
this.filteredRows.some(
(value) => value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
if (row.name.trim().toLowerCase() === result.name.trim().toLowerCase()) {
this.monitoringApiService
.putMasterBuildingParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
} else {
if (
this.filteredRows.some(
(value) =>
value.name.trim().toLowerCase() === result.name.trim().toLowerCase()
)
) {
this.toastr.error("Warning", "Data yang anda masukan double.", {
timeOut: 5000,
closeButton: true,
});
}
}
} else {
this.monitoringApiService
.putMasterBuildingParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
.putMasterBuildingParam(result, row.id)
.subscribe((res) => {
this.fetchData();
});
}
}
// if (result) {
// console.log(result);
// console.log(this.filteredRows);
// if (this.filteredRows.some(value => value.name.toLowerCase() === result.name.toLowerCase() && value.status_id === result.statusId)) {
// this.toastr.error("Warning", "Nama Gedung yang anda masukan double.", {
// timeOut: 5000,
// closeButton: true,
// });
// } else {
// this.monitoringApiService
// .putMasterBuildingParam(result, row.id)
// .subscribe((res) => {
// this.fetchData();
// });
// }
// }
// if (result) {
// this.monitoringApiService
// .putMasterBuildingParam(result, row.id)
@@ -165,6 +199,12 @@ export class MasterBuildingComponent {
.deleteMasterBuildingParam(row.id)
.subscribe((res) => {
this.fetchData();
}, (error) => {
console.error(error);
this.toastr.error("Error", "Data sedang digunakan!", {
timeOut: 2000,
closeButton: true,
});
});
}
}