From 277c17e06f69276b10b77cc4016b0916079d2e8d Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Mon, 22 Apr 2024 12:01:11 +0200 Subject: [PATCH] fix(admin-ui): Fix default quantity when adding item to order --- .../components/order-editor/order-editor.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/admin-ui/src/lib/order/src/components/order-editor/order-editor.component.ts b/packages/admin-ui/src/lib/order/src/components/order-editor/order-editor.component.ts index b8e77c1b9c..774a9c18fc 100644 --- a/packages/admin-ui/src/lib/order/src/components/order-editor/order-editor.component.ts +++ b/packages/admin-ui/src/lib/order/src/components/order-editor/order-editor.component.ts @@ -260,10 +260,13 @@ export class OrderEditorComponent const adjustedLine = this.modifyOrderInput.adjustOrderLines?.find(l => l.orderLineId === lineId); if (adjustedLine) { return adjustedLine.quantity; - } else { - const line = this.orderSnapshot.lines.find(l => l.id === lineId); - return line ? line.quantity : 0; } + const addedLine = this.modifyOrderInput.addItems?.find(l => this.getIdForAddedItem(l) === lineId); + if (addedLine) { + return addedLine.quantity ?? 1; + } + const line = this.orderSnapshot.lines.find(l => l.id === lineId); + return line ? line.quantity : 1; } updateLineQuantity(line: OrderDetailFragment['lines'][number] | AddedLine, quantity: string) {