@anker-in/shopify-react 1.3.0-beta.10 → 1.3.0-beta.12
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 +3 -22
- package/dist/hooks/index.d.ts +3 -22
- package/dist/hooks/index.js +4 -65
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -66
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +4 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useMemo, useRef, useState, useEffect, useCallback, useContext } from 'react';
|
|
2
2
|
import useSWRMutation from 'swr/mutation';
|
|
3
|
-
import { getProductsByHandles, removeCartLines, updateCartCodes, createCart, addCartLines, updateCartLines, getLocalStorage, updateCartAttributes, updateBuyerIdentity, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog, setLocalStorage } from '@anker-in/shopify-sdk';
|
|
3
|
+
import { getProductsByHandles, removeCartLines, updateCartCodes, createCart, addCartLines, updateCartLines, getLocalStorage, updateCartAttributes, updateBuyerIdentity, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog, getShop, setLocalStorage } from '@anker-in/shopify-sdk';
|
|
4
4
|
import Cookies5 from 'js-cookie';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import Decimal3 from 'decimal.js';
|
|
@@ -3177,76 +3177,15 @@ function useSearch(options = {}) {
|
|
|
3177
3177
|
swrOptions
|
|
3178
3178
|
);
|
|
3179
3179
|
}
|
|
3180
|
-
async function getSiteInfo(client, locale, metafieldIdentifiers) {
|
|
3181
|
-
const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
|
|
3182
|
-
const query = (
|
|
3183
|
-
/* GraphQL */
|
|
3184
|
-
`
|
|
3185
|
-
query getSiteInfo(
|
|
3186
|
-
${hasMetafields ? "$shopMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
3187
|
-
) {
|
|
3188
|
-
shop {
|
|
3189
|
-
name
|
|
3190
|
-
description
|
|
3191
|
-
primaryDomain {
|
|
3192
|
-
url
|
|
3193
|
-
host
|
|
3194
|
-
}
|
|
3195
|
-
brand {
|
|
3196
|
-
logo {
|
|
3197
|
-
image {
|
|
3198
|
-
url
|
|
3199
|
-
}
|
|
3200
|
-
}
|
|
3201
|
-
colors {
|
|
3202
|
-
primary {
|
|
3203
|
-
background
|
|
3204
|
-
}
|
|
3205
|
-
secondary {
|
|
3206
|
-
background
|
|
3207
|
-
}
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
${hasMetafields ? "metafields(identifiers: $shopMetafieldIdentifiers) { key value }" : ""}
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
`
|
|
3214
|
-
);
|
|
3215
|
-
const variables = {};
|
|
3216
|
-
if (hasMetafields) {
|
|
3217
|
-
variables.shopMetafieldIdentifiers = metafieldIdentifiers;
|
|
3218
|
-
}
|
|
3219
|
-
const data = await client.query(query, variables);
|
|
3220
|
-
if (!data || !data.shop) {
|
|
3221
|
-
return void 0;
|
|
3222
|
-
}
|
|
3223
|
-
const shop = data.shop;
|
|
3224
|
-
const metafields = shop.metafields?.reduce((acc, mf) => {
|
|
3225
|
-
if (mf && mf.key) {
|
|
3226
|
-
acc[mf.key] = mf.value;
|
|
3227
|
-
}
|
|
3228
|
-
return acc;
|
|
3229
|
-
}, {});
|
|
3230
|
-
return {
|
|
3231
|
-
name: shop.name,
|
|
3232
|
-
description: shop.description,
|
|
3233
|
-
primaryDomain: shop.primaryDomain,
|
|
3234
|
-
brand: shop.brand ? {
|
|
3235
|
-
logo: shop.brand.logo,
|
|
3236
|
-
colors: shop.brand.colors ? {
|
|
3237
|
-
primary: shop.brand.colors.primary?.background,
|
|
3238
|
-
secondary: shop.brand.colors.secondary?.background
|
|
3239
|
-
} : void 0
|
|
3240
|
-
} : void 0,
|
|
3241
|
-
metafields
|
|
3242
|
-
};
|
|
3243
|
-
}
|
|
3244
3180
|
function useSite(options = {}) {
|
|
3245
3181
|
const { client, locale } = useShopify();
|
|
3246
3182
|
const { metafieldIdentifiers, ...swrOptions } = options;
|
|
3247
3183
|
return useSWR(
|
|
3248
3184
|
["site", locale, metafieldIdentifiers],
|
|
3249
|
-
() =>
|
|
3185
|
+
() => getShop(client, {
|
|
3186
|
+
locale,
|
|
3187
|
+
metafieldIdentifiers
|
|
3188
|
+
}),
|
|
3250
3189
|
swrOptions
|
|
3251
3190
|
);
|
|
3252
3191
|
}
|