@anker-in/shopify-react 0.1.1-beta.40 → 0.1.1-beta.42
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.
- package/dist/hooks/index.d.mts +66 -28
- package/dist/hooks/index.d.ts +66 -28
- package/dist/hooks/index.js +183 -132
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +182 -131
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +188 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -132
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +1 -1
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +21 -11
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +21 -11
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-BSsb8OPm.d.mts → types-DntkHhf8.d.mts} +8 -5
- package/dist/{types-BSsb8OPm.d.ts → types-DntkHhf8.d.ts} +8 -5
- package/package.json +3 -3
|
@@ -4,7 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
|
|
|
4
4
|
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.mjs';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-DntkHhf8.mjs';
|
|
8
8
|
|
|
9
9
|
interface ShopifyContextValue {
|
|
10
10
|
client: ShopifyClient;
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ShopifyClient, ShopifyConfig, CartCookieAdapter, NormalizedCart, Attrib
|
|
|
4
4
|
import { C as CookieAdapter, R as RouterAdapter, U as UserContextAdapter, P as PerformanceAdapter } from '../types-SKDHauqk.js';
|
|
5
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
6
|
import { SWRConfiguration } from 'swr';
|
|
7
|
-
import { e as PlusMemberSettingsMetafields } from '../types-
|
|
7
|
+
import { e as PlusMemberSettingsMetafields } from '../types-DntkHhf8.js';
|
|
8
8
|
|
|
9
9
|
interface ShopifyContextValue {
|
|
10
10
|
client: ShopifyClient;
|
package/dist/provider/index.js
CHANGED
|
@@ -711,24 +711,31 @@ var useScriptAutoFreeGift = ({
|
|
|
711
711
|
giftProductsResult: finalGiftProductsResult
|
|
712
712
|
};
|
|
713
713
|
};
|
|
714
|
-
function useUpdateCartAttributes(
|
|
714
|
+
function useUpdateCartAttributes({
|
|
715
|
+
mutate,
|
|
716
|
+
metafieldIdentifiers,
|
|
717
|
+
disabled = false,
|
|
718
|
+
swrOptions
|
|
719
|
+
}) {
|
|
715
720
|
const { client, locale, cartCookieAdapter } = useShopify();
|
|
716
721
|
const updateAttributes = react.useCallback(
|
|
717
722
|
async (_key, { arg }) => {
|
|
723
|
+
if (disabled || !cartCookieAdapter?.getCartId(locale)) {
|
|
724
|
+
return void 0;
|
|
725
|
+
}
|
|
718
726
|
const updatedCart = await shopifySdk.updateCartAttributes(client, {
|
|
719
727
|
...arg,
|
|
720
728
|
metafieldIdentifiers,
|
|
721
729
|
cookieAdapter: cartCookieAdapter
|
|
722
730
|
});
|
|
723
|
-
console.log("useUpdateCartAttributes updatedCart", updatedCart);
|
|
724
731
|
if (updatedCart) {
|
|
725
732
|
mutate(updatedCart);
|
|
726
733
|
}
|
|
727
734
|
return updatedCart;
|
|
728
735
|
},
|
|
729
|
-
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
|
|
736
|
+
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers, disabled]
|
|
730
737
|
);
|
|
731
|
-
return useSWRMutation8__default.default("update-cart-attributes", updateAttributes,
|
|
738
|
+
return useSWRMutation8__default.default("update-cart-attributes", updateAttributes, swrOptions);
|
|
732
739
|
}
|
|
733
740
|
function useHasPlusMemberInCart({
|
|
734
741
|
memberSetting,
|
|
@@ -856,7 +863,7 @@ var useCartAttributes = ({
|
|
|
856
863
|
})
|
|
857
864
|
}
|
|
858
865
|
] : [];
|
|
859
|
-
}, [cart]);
|
|
866
|
+
}, [cart, customer]);
|
|
860
867
|
const presellAttributes = react.useMemo(() => {
|
|
861
868
|
return [
|
|
862
869
|
{
|
|
@@ -920,9 +927,7 @@ var useCartAttributes = ({
|
|
|
920
927
|
"_play_mode_id",
|
|
921
928
|
"_popup"
|
|
922
929
|
];
|
|
923
|
-
return cart?.customAttributes?.filter(
|
|
924
|
-
(item) => !commonAttributeKeys.includes(item.key)
|
|
925
|
-
) || [];
|
|
930
|
+
return cart?.customAttributes?.filter((item) => !commonAttributeKeys.includes(item.key)) || [];
|
|
926
931
|
}, [cart]);
|
|
927
932
|
return react.useMemo(
|
|
928
933
|
() => ({
|
|
@@ -1084,8 +1089,9 @@ var createInitialValue = () => ({
|
|
|
1084
1089
|
tddCoupon: void 0,
|
|
1085
1090
|
isLoadingCoupon: false
|
|
1086
1091
|
},
|
|
1087
|
-
|
|
1088
|
-
|
|
1092
|
+
selectedPlusMemberVariant: void 0,
|
|
1093
|
+
monthlyVariant: void 0,
|
|
1094
|
+
annualVariant: void 0,
|
|
1089
1095
|
showPlusMemberBenefit: false,
|
|
1090
1096
|
setShowPlusMemberBenefit: () => {
|
|
1091
1097
|
},
|
|
@@ -1138,7 +1144,11 @@ function CartProvider({
|
|
|
1138
1144
|
refreshDeps: [locale]
|
|
1139
1145
|
}
|
|
1140
1146
|
);
|
|
1141
|
-
const { trigger: updateAttributes } = useUpdateCartAttributes(
|
|
1147
|
+
const { trigger: updateAttributes } = useUpdateCartAttributes({
|
|
1148
|
+
mutate: mutateCart,
|
|
1149
|
+
metafieldIdentifiers,
|
|
1150
|
+
disabled: isCartLoading
|
|
1151
|
+
});
|
|
1142
1152
|
const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
|
|
1143
1153
|
ahooks.useRequest(
|
|
1144
1154
|
() => {
|