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 hasMetadata = (data == null ? void 0 : data.metadata) && Object.keys(data.metadata).length > 0;
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 currentMetadataString = hasMetadata ? JSON.stringify(data.metadata) : "";
687
+ const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
688
+ const currentMetadataString = JSON.stringify(currentMetadata);
688
689
  const metadataChanged = currentMetadataString !== metadataStringRef.current;
689
- if (hasMetadata && descriptorsLoaded && sameOrder && (notInitialized || metadataChanged)) {
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 hasMetadata = (data == null ? void 0 : data.metadata) && Object.keys(data.metadata).length > 0;
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 currentMetadataString = hasMetadata ? JSON.stringify(data.metadata) : "";
686
+ const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
687
+ const currentMetadataString = JSON.stringify(currentMetadata);
687
688
  const metadataChanged = currentMetadataString !== metadataStringRef.current;
688
- if (hasMetadata && descriptorsLoaded && sameOrder && (notInitialized || metadataChanged)) {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "medusa-product-helper",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",