@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.js CHANGED
@@ -3355,76 +3355,15 @@ function useSearch(options = {}) {
3355
3355
  swrOptions
3356
3356
  );
3357
3357
  }
3358
- async function getSiteInfo(client, locale, metafieldIdentifiers) {
3359
- const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
3360
- const query = (
3361
- /* GraphQL */
3362
- `
3363
- query getSiteInfo(
3364
- ${hasMetafields ? "$shopMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
3365
- ) {
3366
- shop {
3367
- name
3368
- description
3369
- primaryDomain {
3370
- url
3371
- host
3372
- }
3373
- brand {
3374
- logo {
3375
- image {
3376
- url
3377
- }
3378
- }
3379
- colors {
3380
- primary {
3381
- background
3382
- }
3383
- secondary {
3384
- background
3385
- }
3386
- }
3387
- }
3388
- ${hasMetafields ? "metafields(identifiers: $shopMetafieldIdentifiers) { key value }" : ""}
3389
- }
3390
- }
3391
- `
3392
- );
3393
- const variables = {};
3394
- if (hasMetafields) {
3395
- variables.shopMetafieldIdentifiers = metafieldIdentifiers;
3396
- }
3397
- const data = await client.query(query, variables);
3398
- if (!data || !data.shop) {
3399
- return void 0;
3400
- }
3401
- const shop = data.shop;
3402
- const metafields = shop.metafields?.reduce((acc, mf) => {
3403
- if (mf && mf.key) {
3404
- acc[mf.key] = mf.value;
3405
- }
3406
- return acc;
3407
- }, {});
3408
- return {
3409
- name: shop.name,
3410
- description: shop.description,
3411
- primaryDomain: shop.primaryDomain,
3412
- brand: shop.brand ? {
3413
- logo: shop.brand.logo,
3414
- colors: shop.brand.colors ? {
3415
- primary: shop.brand.colors.primary?.background,
3416
- secondary: shop.brand.colors.secondary?.background
3417
- } : void 0
3418
- } : void 0,
3419
- metafields
3420
- };
3421
- }
3422
3358
  function useSite(options = {}) {
3423
3359
  const { client, locale } = useShopify();
3424
3360
  const { metafieldIdentifiers, ...swrOptions } = options;
3425
3361
  return useSWR__default.default(
3426
3362
  ["site", locale, metafieldIdentifiers],
3427
- () => getSiteInfo(client, locale, metafieldIdentifiers),
3363
+ () => shopifySdk.getShop(client, {
3364
+ locale,
3365
+ metafieldIdentifiers
3366
+ }),
3428
3367
  swrOptions
3429
3368
  );
3430
3369
  }