Merged PR 1228: #3104 Improved Error Handling of Removing Items from Shipping Document

#3104 Improved Error Handling of Removing Items from Shipping Document
This commit is contained in:
Nino Righi
2022-05-10 15:12:34 +00:00
committed by Andreas Schickinger
parent 913ffbda97
commit e99d669086

View File

@@ -72,7 +72,7 @@ export class SharedShippingDocumentDetailsComponent {
async removeItem(item: ReceiptItemDTO) {
try {
this.loading = true;
await this._remissionService
const response = await this._remissionService
.removeReturnItemFromReceipt({
returnId: this.return.id,
receiptId: this.firstReceipt.id,
@@ -80,8 +80,12 @@ export class SharedShippingDocumentDetailsComponent {
})
.toPromise();
this.loading = false;
this.firstReceipt.items = this.firstReceipt.items.filter((i) => i.id !== item.id);
this.itemDeleted.emit(item);
if (!!response && !response?.error && Object.keys(response?.result)?.length > 0) {
this.firstReceipt.items = this.firstReceipt.items.filter((i) => i.id !== item.id);
this.itemDeleted.emit(item);
} else {
throw new Error('Keine Response vorhanden');
}
} catch (err) {
this.loading = false;
this._modal.open({ content: UiErrorModalComponent, title: 'Fehler beim Löschen des Artikels', data: err });