Skip to content

Commit

Permalink
Fixing reflecting changes without page reload
Browse files Browse the repository at this point in the history
Fix bug: A system should pick changes of the prices immediately after edit instead waiting to refresh page

How we fixed it:
we find where the method responsible to save the changes that called onSaveItem() method that found inside price-list.component.ts, we modified in such a way that it reflect the changes both in console and on the webpage without reload

Members

SIMON SELELI 2022-04-12519
IBRAHIM MBWATE 2022-04-07053
RAMADHANI BOKWA 2022-04-00838
KEFLINE MADUHU 2022-04-04118
EPHRANCINA EMILLY 2022-04-00782
  • Loading branch information
EPHRANCINA committed Jan 17, 2025
1 parent 4ed6402 commit 32860e4
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions ui/src/app/shared/components/price-list/price-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,27 +237,23 @@ export class PriceListComponent implements OnInit, OnChanges {
}

onSaveItem(itemPrice): void {
// this.store.dispatch(saveItemPrice({ itemPrice }));
this.pricingService.saveItemPrice(itemPrice).subscribe((response) => {
if (response && !response?.error) {
this.loadData();
if (
(this.itemSearchTerm && this.itemSearchTerm.length >= 3) ||
this.itemSearchTerm === ""
) {
this.store.dispatch(clearPricingItems());
this.store.dispatch(
loadPricingItems({
filterInfo: {
limit: 25,
startIndex: this.currentPage,
searchTerm:
this.itemSearchTerm !== "" ? this.itemSearchTerm : null,
conceptSet: this.currentDepartmentId,
},
})
);
console.log('Price saved successfully');

// Find the item in the local data and update it
const index = this.priceList.findIndex(
(item) => item.uuid === itemPrice.uuid
);
if (index > -1) {
// Update the specific item
this.priceList[index] = { ...this.priceList[index], ...response };
} else {
// If not found, optionally add it to the list (for new entries)
this.priceList = [...this.priceList, response];
}
} else {
console.error('Error saving item price:', response);
}
});
}
Expand Down

0 comments on commit 32860e4

Please sign in to comment.