File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
packages/shop/src/components/features Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments