diff --git a/src/app/(main)/m/admin/orders/page.tsx b/src/app/(main)/m/admin/orders/page.tsx index 0f7f9ec..7477d79 100644 --- a/src/app/(main)/m/admin/orders/page.tsx +++ b/src/app/(main)/m/admin/orders/page.tsx @@ -357,6 +357,18 @@ function StatementPreview({ else Swal.fire({ icon: "error", title: "삭제 실패", text: j.message }); }; const addNewExtra = (kind: "DELIVERY" | "CHARTER") => { + // 같은 종류 라인이 이미 있으면 새로 만들지 않고 수량 +1 + const existing = items.find((it) => it.KIND === kind); + if (existing) { + upsertExtra({ + objid: existing.OBJID, + kind, + label: existing.EXTRA_LABEL || existing.ITEM_NAME, + unitPrice: Number(existing.UNIT_PRICE), + qty: Number(existing.QTY) + 1, + }); + return; + } const defaults = kind === "DELIVERY" ? { unitPrice: 4000, qty: 1, label: "택배비" } : { unitPrice: 5000, qty: 1, label: "용차" }; diff --git a/src/app/(main)/m/orders/new/page.tsx b/src/app/(main)/m/orders/new/page.tsx index a598414..6b66aac 100644 --- a/src/app/(main)/m/orders/new/page.tsx +++ b/src/app/(main)/m/orders/new/page.tsx @@ -127,12 +127,19 @@ export default function ItemsBrowse() { const removeLine = (objid: string) => setCart((c) => c.filter((x) => x.item.OBJID !== objid)); const addExtra = (kind: "DELIVERY" | "CHARTER") => { - const defaultPrice = kind === "DELIVERY" ? DEFAULT_DELIVERY_PRICE : DEFAULT_CHARTER_PRICE; - setExtras((p) => [...p, { - id: newKey(), kind, - unitPrice: defaultPrice, qty: 1, - label: kind === "DELIVERY" ? "택배비" : "용차비", - }]); + // 같은 종류 라인이 이미 있으면 새로 만들지 않고 수량 +1 + setExtras((p) => { + const existing = p.find((e) => e.kind === kind); + if (existing) { + return p.map((e) => e.id === existing.id ? { ...e, qty: e.qty + 1 } : e); + } + const defaultPrice = kind === "DELIVERY" ? DEFAULT_DELIVERY_PRICE : DEFAULT_CHARTER_PRICE; + return [...p, { + id: newKey(), kind, + unitPrice: defaultPrice, qty: 1, + label: kind === "DELIVERY" ? "택배비" : "용차비", + }]; + }); }; const updateExtra = (id: string, field: keyof ExtraLine, value: string | number) => { setExtras((p) => p.map((e) => (e.id === id ? { ...e, [field]: value } as ExtraLine : e)));