medusa-product-helper 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -680,14 +680,14 @@ const OrderMetadataTableWidget = ({ data }) => {
|
|
|
680
680
|
}, [orderId]);
|
|
681
681
|
const metadataStringRef = react.useRef("");
|
|
682
682
|
react.useEffect(() => {
|
|
683
|
-
const
|
|
683
|
+
const hasOrderData = !!data;
|
|
684
684
|
const descriptorsLoaded = descriptors.length > 0;
|
|
685
685
|
const sameOrder = previousOrderIdRef.current === orderId;
|
|
686
686
|
const notInitialized = !isInitializedRef.current;
|
|
687
|
-
const
|
|
687
|
+
const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
|
|
688
|
+
const currentMetadataString = JSON.stringify(currentMetadata);
|
|
688
689
|
const metadataChanged = currentMetadataString !== metadataStringRef.current;
|
|
689
|
-
if (
|
|
690
|
-
const currentMetadata = data.metadata ?? {};
|
|
690
|
+
if (hasOrderData && descriptorsLoaded && sameOrder && (notInitialized || metadataChanged)) {
|
|
691
691
|
const newInitialState = buildInitialFormState(descriptors, currentMetadata);
|
|
692
692
|
setBaselineMetadata(currentMetadata);
|
|
693
693
|
setValues(newInitialState);
|
|
@@ -679,14 +679,14 @@ const OrderMetadataTableWidget = ({ data }) => {
|
|
|
679
679
|
}, [orderId]);
|
|
680
680
|
const metadataStringRef = useRef("");
|
|
681
681
|
useEffect(() => {
|
|
682
|
-
const
|
|
682
|
+
const hasOrderData = !!data;
|
|
683
683
|
const descriptorsLoaded = descriptors.length > 0;
|
|
684
684
|
const sameOrder = previousOrderIdRef.current === orderId;
|
|
685
685
|
const notInitialized = !isInitializedRef.current;
|
|
686
|
-
const
|
|
686
|
+
const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
|
|
687
|
+
const currentMetadataString = JSON.stringify(currentMetadata);
|
|
687
688
|
const metadataChanged = currentMetadataString !== metadataStringRef.current;
|
|
688
|
-
if (
|
|
689
|
-
const currentMetadata = data.metadata ?? {};
|
|
689
|
+
if (hasOrderData && descriptorsLoaded && sameOrder && (notInitialized || metadataChanged)) {
|
|
690
690
|
const newInitialState = buildInitialFormState(descriptors, currentMetadata);
|
|
691
691
|
setBaselineMetadata(currentMetadata);
|
|
692
692
|
setValues(newInitialState);
|