Skip to content

Commit e74886d

Browse files
committed
fix: 잘못된 ID값을 넘겨 옵션 수정이 불가능하던 문제 재수정
1 parent 7e33cf4 commit e74886d

File tree

1 file changed

+7
-4
lines changed
  • packages/shop/src/components/features

1 file changed

+7
-4
lines changed

packages/shop/src/components/features/order.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@ const OrderProductRelationItem: React.FC<OrderProductRelationItemProps> = ({
8888
const patchOneItemOptions = () => {
8989
if (!Common.Utils.isFormValid(formRef.current)) throw new Error("Form is not valid");
9090

91-
const modifiedCustomOptionValues: ShopSchemas.OrderOptionsPatchRequest["options"] = Object.entries(
92-
Common.Utils.getFormValue<{ [key: string]: string }>({
93-
form: formRef.current,
91+
const formValues = Common.Utils.getFormValue<{ [key: string]: string }>({ form: formRef.current });
92+
const modifiedCustomOptionValues: ShopSchemas.OrderOptionsPatchRequest["options"] = Object.entries(formValues)
93+
.map(([key, value]) => {
94+
// 여기서 key는 order_product_option_relation의 id가 아니라 product_option_group의 id이므로, order_product_option_relation의 id로 변경해야 함
95+
const optionRel = prodRel.options.find((option) => option.product_option_group.id === key);
96+
if (!optionRel) throw new Error(`Option relation for group ${key} not found in product relation ${prodRel.id}`);
97+
return [optionRel.id, value];
9498
})
95-
)
9699
.filter(([key, value]) => currentCustomOptionValues[key] !== value)
97100
.map(([key, value]) => ({
98101
order_product_option_relation: key,

0 commit comments

Comments
 (0)