@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/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, useMemo, useContext, useRef, useState, useEffect, useCallback } from 'react';
2
- import { createShopifyClient, getProductsByHandles, createCart, updateCartCodes, addCartLines, updateCartLines, removeCartLines, getLocalStorage, updateCartAttributes, updateBuyerIdentity, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog, getCart, setLocalStorage } from '@anker-in/shopify-sdk';
2
+ import { createShopifyClient, getProductsByHandles, createCart, updateCartCodes, addCartLines, updateCartLines, removeCartLines, getLocalStorage, updateCartAttributes, updateBuyerIdentity, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog, getShop, getCart, setLocalStorage } from '@anker-in/shopify-sdk';
3
3
  export * from '@anker-in/shopify-sdk';
4
4
  import Cookies5 from 'js-cookie';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
@@ -3347,76 +3347,15 @@ function useSearch(options = {}) {
3347
3347
  swrOptions
3348
3348
  );
3349
3349
  }
3350
- async function getSiteInfo(client, locale, metafieldIdentifiers) {
3351
- const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
3352
- const query = (
3353
- /* GraphQL */
3354
- `
3355
- query getSiteInfo(
3356
- ${hasMetafields ? "$shopMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
3357
- ) {
3358
- shop {
3359
- name
3360
- description
3361
- primaryDomain {
3362
- url
3363
- host
3364
- }
3365
- brand {
3366
- logo {
3367
- image {
3368
- url
3369
- }
3370
- }
3371
- colors {
3372
- primary {
3373
- background
3374
- }
3375
- secondary {
3376
- background
3377
- }
3378
- }
3379
- }
3380
- ${hasMetafields ? "metafields(identifiers: $shopMetafieldIdentifiers) { key value }" : ""}
3381
- }
3382
- }
3383
- `
3384
- );
3385
- const variables = {};
3386
- if (hasMetafields) {
3387
- variables.shopMetafieldIdentifiers = metafieldIdentifiers;
3388
- }
3389
- const data = await client.query(query, variables);
3390
- if (!data || !data.shop) {
3391
- return void 0;
3392
- }
3393
- const shop = data.shop;
3394
- const metafields = shop.metafields?.reduce((acc, mf) => {
3395
- if (mf && mf.key) {
3396
- acc[mf.key] = mf.value;
3397
- }
3398
- return acc;
3399
- }, {});
3400
- return {
3401
- name: shop.name,
3402
- description: shop.description,
3403
- primaryDomain: shop.primaryDomain,
3404
- brand: shop.brand ? {
3405
- logo: shop.brand.logo,
3406
- colors: shop.brand.colors ? {
3407
- primary: shop.brand.colors.primary?.background,
3408
- secondary: shop.brand.colors.secondary?.background
3409
- } : void 0
3410
- } : void 0,
3411
- metafields
3412
- };
3413
- }
3414
3350
  function useSite(options = {}) {
3415
3351
  const { client, locale } = useShopify();
3416
3352
  const { metafieldIdentifiers, ...swrOptions } = options;
3417
3353
  return useSWR(
3418
3354
  ["site", locale, metafieldIdentifiers],
3419
- () => getSiteInfo(client, locale, metafieldIdentifiers),
3355
+ () => getShop(client, {
3356
+ locale,
3357
+ metafieldIdentifiers
3358
+ }),
3420
3359
  swrOptions
3421
3360
  );
3422
3361
  }