@gem-sdk/pages 2.0.0-staging.152 → 2.0.0-staging.709

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.
Files changed (62) hide show
  1. package/dist/cjs/components/FooterForPostPurchase.js +1 -1
  2. package/dist/cjs/components/builder/Footer.js +2 -2
  3. package/dist/cjs/components/builder/Header.js +0 -1
  4. package/dist/cjs/components/builder/Toolbar.js +6 -0
  5. package/dist/cjs/components/builder/Toolbox.js +27 -14
  6. package/dist/cjs/components/composable/getListFontWeightTypos.js +14 -0
  7. package/dist/cjs/components/image-to-layout/AddSectionImageToLayout.js +5 -4
  8. package/dist/cjs/components/image-to-layout/DropElement.js +34 -9
  9. package/dist/cjs/constants/index.js +15 -0
  10. package/dist/cjs/libs/api/get-home-page-props-v2.js +20 -8
  11. package/dist/cjs/libs/api/get-home-page-props.js +15 -3
  12. package/dist/cjs/libs/api/get-post-purchase-props-preview.js +38 -5
  13. package/dist/cjs/libs/api/get-static-page-props-preview.js +5 -0
  14. package/dist/cjs/libs/api/get-static-page-props-v2.js +19 -10
  15. package/dist/cjs/libs/api/get-static-page-props.js +16 -3
  16. package/dist/cjs/libs/google-fonts.js +25 -5
  17. package/dist/cjs/libs/helpers/gen-fonts.js +9 -3
  18. package/dist/cjs/libs/helpers/get-metafield.js +7 -0
  19. package/dist/cjs/libs/helpers/normalize.js +2 -1
  20. package/dist/cjs/libs/helpers/parse-json.js +1 -1
  21. package/dist/cjs/libs/helpers/sentry.js +17 -0
  22. package/dist/cjs/pages/404.js +1 -0
  23. package/dist/cjs/pages/500.js +1 -0
  24. package/dist/cjs/pages/CollectionGlobalProvider.js +1 -0
  25. package/dist/cjs/pages/builder.js +46 -41
  26. package/dist/cjs/pages/collection-detail.js +1 -0
  27. package/dist/cjs/pages/preview.js +1 -0
  28. package/dist/cjs/pages/product-detail.js +1 -0
  29. package/dist/cjs/pages/static-v2.js +22 -17
  30. package/dist/cjs/pages/static.js +1 -0
  31. package/dist/esm/components/FooterForPostPurchase.js +1 -1
  32. package/dist/esm/components/builder/Footer.js +2 -2
  33. package/dist/esm/components/builder/Header.js +1 -2
  34. package/dist/esm/components/builder/Toolbar.js +6 -0
  35. package/dist/esm/components/builder/Toolbox.js +27 -14
  36. package/dist/esm/components/composable/getListFontWeightTypos.js +12 -0
  37. package/dist/esm/components/image-to-layout/AddSectionImageToLayout.js +6 -5
  38. package/dist/esm/components/image-to-layout/DropElement.js +34 -9
  39. package/dist/esm/constants/index.js +15 -0
  40. package/dist/esm/libs/api/get-home-page-props-v2.js +21 -9
  41. package/dist/esm/libs/api/get-home-page-props.js +16 -4
  42. package/dist/esm/libs/api/get-post-purchase-props-preview.js +39 -6
  43. package/dist/esm/libs/api/get-static-page-props-preview.js +5 -0
  44. package/dist/esm/libs/api/get-static-page-props-v2.js +19 -10
  45. package/dist/esm/libs/api/get-static-page-props.js +17 -4
  46. package/dist/esm/libs/google-fonts.js +25 -5
  47. package/dist/esm/libs/helpers/gen-fonts.js +9 -3
  48. package/dist/esm/libs/helpers/get-metafield.js +5 -0
  49. package/dist/esm/libs/helpers/normalize.js +2 -1
  50. package/dist/esm/libs/helpers/parse-json.js +1 -1
  51. package/dist/esm/libs/helpers/sentry.js +15 -0
  52. package/dist/esm/pages/404.js +1 -0
  53. package/dist/esm/pages/500.js +1 -0
  54. package/dist/esm/pages/CollectionGlobalProvider.js +1 -0
  55. package/dist/esm/pages/builder.js +47 -42
  56. package/dist/esm/pages/collection-detail.js +1 -0
  57. package/dist/esm/pages/preview.js +1 -0
  58. package/dist/esm/pages/product-detail.js +1 -0
  59. package/dist/esm/pages/static-v2.js +23 -18
  60. package/dist/esm/pages/static.js +1 -0
  61. package/dist/types/index.d.ts +61 -53
  62. package/package.json +6 -6
@@ -13,7 +13,7 @@ const defaultMargin = {
13
13
  };
14
14
  const FooterForPostPurchase = (props)=>{
15
15
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
16
- className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE] gp-bg-white gp-font-sans'),
16
+ className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE] gp-font-sans'),
17
17
  children: /*#__PURE__*/ jsxRuntime.jsx("div", {
18
18
  className: "gp-flex gp-flex-1 gp-items-center gp-justify-between gp-py-6",
19
19
  style: {
@@ -45,7 +45,7 @@ const Footer = (props)=>{
45
45
  ]);
46
46
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
47
47
  children: pageType === 'POST_PURCHASE' ? /*#__PURE__*/ jsxRuntime.jsx("div", {
48
- className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE] gp-bg-white gp-font-sans'),
48
+ className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE] gp-font-sans'),
49
49
  children: /*#__PURE__*/ jsxRuntime.jsx("div", {
50
50
  className: "gp-flex gp-flex-1 gp-items-center gp-justify-between gp-py-6",
51
51
  style: {
@@ -62,7 +62,7 @@ const Footer = (props)=>{
62
62
  })
63
63
  })
64
64
  }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
65
- className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE] gp-bg-white gp-font-sans', {
65
+ className: core.cls('gp-footer-container gp-border-1 gp-group gp-flex gp-justify-center gp-border-y gp-border-[#EEEEEE gp-font-sans', {
66
66
  'gp-fixed gp-bottom-0 gp-w-full': shouldFixed
67
67
  }),
68
68
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -22,7 +22,6 @@ const sizeCheck = {
22
22
  const Header = (props)=>{
23
23
  const { pageType, isOriginTemplate, openPageSetting } = props;
24
24
  const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
25
- core.usePageStore((s)=>s.sidebarMode);
26
25
  const activeHeader = layoutSetting?.showHeader || isOriginTemplate;
27
26
  const headerColor = activeHeader ? HEADER_ON_COLOR : HEADER_OFF_COLOR;
28
27
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -411,6 +411,7 @@ const Toolbar = ()=>{
411
411
  if (!value || !currentComponentActive.current) {
412
412
  return;
413
413
  }
414
+ let isClickProcessing = false;
414
415
  const selector = getSelectorComponent({
415
416
  ...currentComponentActive.current
416
417
  });
@@ -419,6 +420,7 @@ const Toolbar = ()=>{
419
420
  const $parents = $component?.querySelectorAll('[data-toolbar-parent]');
420
421
  if ($parents.length) {
421
422
  const onHover = ($parent)=>{
423
+ if (isClickProcessing) return;
422
424
  const uid = $parent.getAttribute('data-parent-uid');
423
425
  if (!uid) return;
424
426
  const $parentComponents = document.body.querySelector('#storefront')?.querySelectorAll(`[data-uid="${uid}"]`);
@@ -447,6 +449,7 @@ const Toolbar = ()=>{
447
449
  }
448
450
  };
449
451
  const onClick = async ($parent)=>{
452
+ isClickProcessing = true;
450
453
  const uid = $parent.getAttribute('data-parent-uid');
451
454
  if (!uid) return;
452
455
  const isElementInsideProduct = async ()=>{
@@ -478,6 +481,9 @@ const Toolbar = ()=>{
478
481
  });
479
482
  outHover($parent);
480
483
  window.dispatchEvent(event);
484
+ setTimeout(()=>{
485
+ isClickProcessing = false;
486
+ }, 0);
481
487
  };
482
488
  $parents.forEach(($parent)=>{
483
489
  $parent.addEventListener('mouseover', ()=>onHover($parent));
@@ -8,11 +8,12 @@ var core = require('@gem-sdk/core');
8
8
  var react = require('react');
9
9
  var getStorefrontApi = require('../../libs/get-storefront-api.js');
10
10
  var googleFonts = require('../../libs/google-fonts.js');
11
+ var checkOptionFont = require('../../libs/helpers/check-option-font.js');
11
12
  var genCss = require('../../libs/helpers/gen-css.js');
12
13
  var genFonts = require('../../libs/helpers/gen-fonts.js');
13
14
  var shopifyCdnWithGoogleFonts = require('../../libs/shopify-cdn-with-google-fonts.js');
14
15
  var libsStore = require('../../store/libs-store.js');
15
- var checkOptionFont = require('../../libs/helpers/check-option-font.js');
16
+ var getListFontWeightTypos = require('../composable/getListFontWeightTypos.js');
16
17
 
17
18
  const globalStyleId = 'global-style';
18
19
  const Toolbox = ()=>{
@@ -21,6 +22,7 @@ const Toolbox = ()=>{
21
22
  const changeStorefrontInfo = core.useShopStore((s)=>s.changeStorefrontInfo);
22
23
  const setDynamicProduct = core.usePageStore((s)=>s.setDynamicProduct);
23
24
  const setPostPurchaseProductOffers = core.usePageStore((s)=>s.setPostPurchaseProductOffers);
25
+ const setDynamicDiscountOffer = core.usePageStore((s)=>s.setDynamicDiscountOffer);
24
26
  const setSalePageProductId = core.usePageStore((s)=>s.setSalePageProductId);
25
27
  const setDynamicCollection = core.usePageStore((s)=>s.setDynamicCollection);
26
28
  const initState = core.useBuilderPreviewStore((s)=>s.initState);
@@ -38,7 +40,7 @@ const Toolbox = ()=>{
38
40
  const changeLayoutSettings = core.useShopStore((s)=>s.changeLayoutSettings);
39
41
  const changeCreateThemeSectionCount = core.useShopStore((s)=>s.changeCreateThemeSectionCount);
40
42
  const changeShopPlan = core.useShopStore((s)=>s.changeShopPlan);
41
- const changeShopifyPlan = core.useShopStore((s)=>s.changeShopifyPlan);
43
+ const updatePriceWithCurrency = core.useShopStore((s)=>s.updatePriceWithCurrency);
42
44
  const changeFontType = libsStore.libsStore((s)=>s.changeFontType);
43
45
  const fontType = libsStore.libsStore((s)=>s.fontType);
44
46
  const clearModal = core.useModalStore((s)=>s.clearModal);
@@ -137,9 +139,11 @@ const Toolbox = ()=>{
137
139
  try {
138
140
  if (detail.data) {
139
141
  const themeStyle = genCss.genCSS(detail.data, detail.mobileOnly);
140
- const font = Object.entries(detail.data?.font).map(([, value])=>{
141
- return value;
142
- }).map((item)=>{
142
+ const fontWeights = getListFontWeightTypos.getListFontWeightTypos(detail.data?.typography);
143
+ const font = Object.entries(detail.data?.font).map(([, value])=>({
144
+ ...value,
145
+ variants: value.variants.filter((variant)=>fontWeights.includes(variant) || variant === 'regular' && fontWeights.includes('400')).map((variant)=>variant === 'regular' ? '400' : variant)
146
+ })).map((item)=>{
143
147
  if (item.type == 'custom') {
144
148
  const isGoogleFont = shopifyCdnWithGoogleFonts.shopifyCdnWithGoogleFonts.find((ggFont)=>ggFont.family == item.family);
145
149
  if (isGoogleFont) {
@@ -296,12 +300,12 @@ const Toolbox = ()=>{
296
300
  }, [
297
301
  changeShopPlan
298
302
  ]);
299
- const onUpdateShopifyPlan = react.useCallback((e)=>{
300
- const shopifyPlan = e.detail;
301
- if (!shopifyPlan) return;
302
- changeShopifyPlan(shopifyPlan);
303
+ const onUpdatePriceWithCurrency = react.useCallback((e)=>{
304
+ const showPriceCurrency = e.detail;
305
+ if (!showPriceCurrency) return;
306
+ updatePriceWithCurrency(showPriceCurrency);
303
307
  }, [
304
- changeShopifyPlan
308
+ updatePriceWithCurrency
305
309
  ]);
306
310
  const onUpdateFontType = react.useCallback((e)=>{
307
311
  const fontType = e.detail;
@@ -354,6 +358,13 @@ const Toolbox = ()=>{
354
358
  }, [
355
359
  setPostPurchaseProductOffers
356
360
  ]);
361
+ const onUpdateDynamicDiscountOffer = react.useCallback((e)=>{
362
+ const dynamicDiscountOffer = e.detail;
363
+ if (!dynamicDiscountOffer) return;
364
+ setDynamicDiscountOffer(dynamicDiscountOffer);
365
+ }, [
366
+ setDynamicDiscountOffer
367
+ ]);
357
368
  const onUpdateSalePageProductId = react.useCallback((e)=>{
358
369
  const id = e.detail;
359
370
  if (!id) return;
@@ -420,12 +431,12 @@ const Toolbox = ()=>{
420
431
  window.addEventListener('on-off-header-footer', onChangeLayoutSettingData);
421
432
  window.addEventListener('update-create-theme-section-count', onUpdateCreateThemeSectionCount);
422
433
  window.addEventListener('update-shop-plan', onUpdateShopPlan);
423
- window.addEventListener('update-shopify-plan', onUpdateShopifyPlan);
424
434
  window.addEventListener('set-dynamic-product', onUpdateDynamicProduct);
425
435
  window.addEventListener('set-dynamic-collection', onUpdateDynamicCollection);
426
436
  window.addEventListener('update-item-name', onUpdateItemName);
427
437
  window.addEventListener('update-item-attribute', onUpdateItemAttribute);
428
438
  window.addEventListener('set-product-offer', onUpdateProductOffers);
439
+ window.addEventListener('set-dynamic-discount-offer', onUpdateDynamicDiscountOffer);
429
440
  window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
430
441
  window.addEventListener('limit-create-theme-section', onLimitCreateThemeSection);
431
442
  window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
@@ -433,6 +444,7 @@ const Toolbox = ()=>{
433
444
  window.addEventListener('update-interaction-setting-type', onUpdateInteractionSettingType);
434
445
  window.addEventListener('change-sidebar-mode', onChangeSidebarMode);
435
446
  window.addEventListener('update-font-type', onUpdateFontType);
447
+ window.addEventListener('update-price-with-currency', onUpdatePriceWithCurrency);
436
448
  return ()=>{
437
449
  window.removeEventListener('update-shop-info', onChangeShopInfo);
438
450
  window.removeEventListener('revalidate-query', onRevalidateQuery);
@@ -446,7 +458,7 @@ const Toolbox = ()=>{
446
458
  window.removeEventListener('on-off-header-footer', onChangeLayoutSettingData);
447
459
  window.removeEventListener('update-create-theme-section-count', onUpdateCreateThemeSectionCount);
448
460
  window.removeEventListener('update-shop-plan', onUpdateShopPlan);
449
- window.removeEventListener('update-shopify-plan', onUpdateShopifyPlan);
461
+ window.removeEventListener('update-price-with-currency', onUpdatePriceWithCurrency);
450
462
  window.removeEventListener('set-dynamic-product', onUpdateDynamicProduct);
451
463
  window.removeEventListener('set-dynamic-collection', onUpdateDynamicCollection);
452
464
  window.removeEventListener('update-item-name', onUpdateItemName);
@@ -462,7 +474,6 @@ const Toolbox = ()=>{
462
474
  }, [
463
475
  onAddEntity,
464
476
  onUpdateShopPlan,
465
- onUpdateShopifyPlan,
466
477
  onForceUpdateEntityProps,
467
478
  onUpdateEntityProp,
468
479
  onInitBuilder,
@@ -485,7 +496,9 @@ const Toolbox = ()=>{
485
496
  onUpdateInteractionIsSelectOnPage,
486
497
  onUpdateInteractionSettingType,
487
498
  onUpdateFontType,
488
- onChangeSidebarMode
499
+ onChangeSidebarMode,
500
+ onUpdateDynamicDiscountOffer,
501
+ onUpdatePriceWithCurrency
489
502
  ]);
490
503
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
491
504
  className: "toolbox"
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ const getListFontWeightTypos = (font)=>{
4
+ const fontWeights = new Set();
5
+ Object.values(font).forEach((fontStyle)=>{
6
+ // Check desktop fontWeight
7
+ if (fontStyle.desktop?.fontWeight) {
8
+ fontWeights.add(fontStyle.desktop.fontWeight);
9
+ }
10
+ });
11
+ return Array.from(fontWeights);
12
+ };
13
+
14
+ exports.getListFontWeightTypos = getListFontWeightTypos;
@@ -37,6 +37,7 @@ const defaultPadding = {
37
37
  mobile: 'var(--g-ct-p)'
38
38
  };
39
39
  const AddSectionImageToLayout = ({ editorImageToLayout })=>{
40
+ const { t } = core.useI18nStore();
40
41
  const layoutSetting = core.useShopStore((s)=>s.layoutSettings);
41
42
  const totalSection = core.useBuilderPreviewStore((state)=>state.state.ROOT.childrens?.length);
42
43
  const editingPageType = core.useShopStore((s)=>s.pageType);
@@ -82,11 +83,11 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
82
83
  children: [
83
84
  /*#__PURE__*/ jsxRuntime.jsx("span", {
84
85
  className: "gp-absolute gp-top-[-12px] gp-bg-white gp-px-[8px] gp-text-[14px] gp-font-normal gp-text-[#9E9E9E]",
85
- children: "Add section"
86
+ children: t('Add section')
86
87
  }),
87
88
  ACTIONS_DATA.map((action)=>{
88
89
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
89
- className: `gp-relative gp-mx-1 gp-h-[60px] gp-w-[172px] w375:gp-w-auto w576:gp-w-auto gp-cursor-pointer gp-flex-col gp-items-center gp-justify-center gp-rounded-[3px] gp-bg-[#F4F4F4] hover:gp-bg-black/10 gp-flex`,
90
+ className: `gp-relative gp-mx-1 gp-min-h-[60px] gp-border-box w375:gp-w-auto w576:gp-w-auto gp-cursor-pointer gp-flex-col gp-items-center gp-justify-center gp-rounded-[3px] gp-bg-[#F4F4F4] hover:gp-bg-black/10 gp-flex gp-p-2`,
90
91
  id: action.id,
91
92
  onClick: ()=>handleAddSectionAction(action.eventID),
92
93
  "aria-hidden": true,
@@ -94,7 +95,7 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
94
95
  /*#__PURE__*/ jsxRuntime.jsxs("div", {
95
96
  className: "gp-mb-[4px] gp-flex gp-gap-2 gp-text-[14px] gp-font-medium gp-text-[#212121]",
96
97
  children: [
97
- action.title,
98
+ t(action.title),
98
99
  action.hasAILogo && /*#__PURE__*/ jsxRuntime.jsxs("svg", {
99
100
  width: "43",
100
101
  height: "20",
@@ -137,7 +138,7 @@ const AddSectionImageToLayout = ({ editorImageToLayout })=>{
137
138
  className: "gp-flex gp-items-center",
138
139
  children: /*#__PURE__*/ jsxRuntime.jsx("span", {
139
140
  className: "gp-mr-[3px] gp-text-center gp-text-[12px] gp-font-normal gp-text-[#676767]",
140
- children: action.content
141
+ children: t(action.content)
141
142
  })
142
143
  })
143
144
  ]
@@ -2,8 +2,16 @@
2
2
  'use strict';
3
3
 
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
+ var core = require('@gem-sdk/core');
5
6
 
7
+ const SALE_FUNNEL_PAGE_TYPES = [
8
+ 'GP_FUNNEL_PAGE',
9
+ 'GP_PRE_SALE_PAGE'
10
+ ];
6
11
  const DropElement = ()=>{
12
+ const { t } = core.useI18n();
13
+ const editingPageType = core.useShopStore((s)=>s.pageType);
14
+ const isFunnelSalesPage = SALE_FUNNEL_PAGE_TYPES.includes(editingPageType || '');
7
15
  const dispatchEventBuildWithSectionActiveTab = (value)=>{
8
16
  const event = new CustomEvent('editor:sidebar:build-with-section-active-tab', {
9
17
  bubbles: true,
@@ -13,6 +21,15 @@ const DropElement = ()=>{
13
21
  });
14
22
  window.dispatchEvent(event);
15
23
  };
24
+ const dispatchEventBuildWithTemplateActiveTab = (value)=>{
25
+ const event = new CustomEvent('editor:sidebar:build-with-template-active-tab', {
26
+ bubbles: true,
27
+ detail: {
28
+ value
29
+ }
30
+ });
31
+ window.dispatchEvent(event);
32
+ };
16
33
  const handleClickGenerate = (e)=>{
17
34
  const event = new CustomEvent('editor:sidebar:click-img-to-layout-gallery-btn', e);
18
35
  window.dispatchEvent(event);
@@ -101,22 +118,30 @@ const DropElement = ()=>{
101
118
  children: [
102
119
  /*#__PURE__*/ jsxRuntime.jsx("div", {
103
120
  className: "gp-text-16 gp-font-medium gp-mb-4 gp-text-[#212121]",
104
- children: "Start with Sections from sidebar"
121
+ children: isFunnelSalesPage ? t('Start building with Sections/Elements or') : t('Start with Sections from sidebar')
105
122
  }),
106
123
  /*#__PURE__*/ jsxRuntime.jsxs("div", {
107
- className: "gp-flex gp-w-[291px] gp-justify-between",
124
+ className: "gp-flex gp-gap-3 gp-justify-between",
108
125
  children: [
109
126
  /*#__PURE__*/ jsxRuntime.jsx("button", {
110
127
  "data-button-add-section": true,
111
- onClick: ()=>dispatchEventBuildWithSectionActiveTab(true),
112
- className: "gp-flex gp-h-[40px] gp-w-[136px] gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#1C1C1C] gp-text-[14px] gp-text-white hover:gp-bg-[#3B3B3B]",
113
- children: "Add sections"
128
+ onClick: ()=>{
129
+ if (isFunnelSalesPage) {
130
+ dispatchEventBuildWithTemplateActiveTab('funnelExisting');
131
+ } else dispatchEventBuildWithSectionActiveTab(true);
132
+ },
133
+ className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#1C1C1C] gp-text-[14px] gp-text-white hover:gp-bg-[#3B3B3B]",
134
+ children: isFunnelSalesPage ? t('Use existing page designs') : t('Add sections')
114
135
  }),
115
136
  /*#__PURE__*/ jsxRuntime.jsx("button", {
116
137
  "data-button-add-elements": true,
117
- onClick: ()=>dispatchEventBuildWithSectionActiveTab(false),
118
- className: "gp-flex gp-h-[40px] gp-w-[136px] gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#f4f4f4] gp-text-[14px] gp-text-[#212121] hover:gp-bg-[#E2E2E2]",
119
- children: "Add elements"
138
+ onClick: ()=>{
139
+ if (isFunnelSalesPage) {
140
+ dispatchEventBuildWithTemplateActiveTab('templates');
141
+ } else dispatchEventBuildWithSectionActiveTab(false);
142
+ },
143
+ className: "gp-flex gp-h-[40px] gp-px-6 gp-items-center gp-font-medium gp-justify-center gp-rounded-[8px] gp-bg-[#f4f4f4] gp-text-[14px] gp-text-[#212121] hover:gp-bg-[#E2E2E2]",
144
+ children: isFunnelSalesPage ? t('Explore templates') : t('Add elements')
120
145
  })
121
146
  ]
122
147
  }),
@@ -155,7 +180,7 @@ const DropElement = ()=>{
155
180
  "aria-hidden": "true",
156
181
  id: "gp-img-to-layout-gallery-btn",
157
182
  className: "gp-relative gp-cursor-pointer gp-text-[14px] gp-font-medium gp-text-[#3C67FF]",
158
- children: "Start with Generating from URL or image"
183
+ children: t('Start with Generating from URL or image')
159
184
  })
160
185
  })
161
186
  ]
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ exports.PublishedThemePageMetafields = void 0;
4
+ (function(PublishedThemePageMetafields) {
5
+ PublishedThemePageMetafields["CUSTOM_CODE_HEADER"] = 'custom_code_header';
6
+ PublishedThemePageMetafields["CUSTOM_CODE_BODY"] = 'custom_code_body';
7
+ PublishedThemePageMetafields["ANALYTICS_GA_TRACKING_ID"] = 'analytics_ga_tracking_id';
8
+ PublishedThemePageMetafields["ANALYTICS_FB_PIXEL_ID"] = 'analytics_fb_pixel_id';
9
+ PublishedThemePageMetafields["ANALYTICS_TIKTOK_PIXEL_ID"] = 'analytics_tiktok_pixel_id';
10
+ PublishedThemePageMetafields["GLOBAL_META_DESCRIPTION"] = 'global-meta-description';
11
+ PublishedThemePageMetafields["GLOBAL_META_TITLE"] = 'global-meta-title';
12
+ PublishedThemePageMetafields["GLOBAL_META_THUMBNAIL"] = 'global-meta-thumbnail';
13
+ PublishedThemePageMetafields["NOINDEX_KEY"] = 'noindex';
14
+ PublishedThemePageMetafields["NOFOLLOW_KEY"] = 'nofollow';
15
+ })(exports.PublishedThemePageMetafields || (exports.PublishedThemePageMetafields = {}));
@@ -9,13 +9,15 @@ var getFallback = require('../helpers/get-fallback.js');
9
9
  var normalize = require('../helpers/normalize.js');
10
10
  var parseJson = require('../helpers/parse-json.js');
11
11
  var nextjs = require('@sentry/nextjs');
12
+ var index = require('../../constants/index.js');
13
+ var getMetafield = require('../helpers/get-metafield.js');
12
14
 
13
15
  const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
14
16
  try {
15
17
  const variables = {
16
18
  slugType: 'STATIC'
17
19
  };
18
- const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
20
+ const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
19
21
  fetcher([
20
22
  core.PublishedThemePagesDocument,
21
23
  variables
@@ -25,11 +27,21 @@ const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
25
27
  ]),
26
28
  shopifyFetcher([
27
29
  adapterShopify.ShopMetaDocument
30
+ ]),
31
+ fetcher([
32
+ core.PublishedShopMetasDocument,
33
+ {
34
+ keys: [
35
+ index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION,
36
+ index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL
37
+ ]
38
+ }
28
39
  ])
29
40
  ]);
30
41
  if (theme.status === 'rejected') {
31
42
  throw new Error(theme.reason?.[0]);
32
43
  }
44
+ const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
33
45
  const dataBuilder = theme.value?.publishedThemePages?.[0];
34
46
  if (!dataBuilder) {
35
47
  throw new Error(`No data builder found for Home page`);
@@ -41,8 +53,8 @@ const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
41
53
  getFallback.getFallbackV2(fetcher, homeTemplate)
42
54
  ]);
43
55
  const mobileOnly = dataBuilder.isMobile ?? false;
44
- const description = dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
45
- const thumbnail = parseJson.parseJson(dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
56
+ const description = getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION, dataBuilder?.metafields) || publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION)?.value;
57
+ const thumbnail = parseJson.parseJson(getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL, dataBuilder?.metafields) || publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL)?.value);
46
58
  const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
47
59
  const shopData = storeProperty.status === 'fulfilled' ? storeProperty.value : undefined;
48
60
  const favicon = shopData?.storeProperty?.favicon ?? '/favicon/favicon-32x32.png';
@@ -129,11 +141,11 @@ const getHomePagePropsV2 = (fetcher, shopifyFetcher)=>async ()=>{
129
141
  swatches: parseJson.parseJson(shopData?.storeProperty?.swatchesConfig),
130
142
  seo,
131
143
  mobileOnly,
132
- gaTrackingId: dataBuilder.themePageAnalytic?.gaTrackingID ?? null,
133
- facebookPixelId: dataBuilder.themePageAnalytic?.fbPixelID ?? null,
134
- tiktokPixelId: dataBuilder.themePageAnalytic?.tiktokPixelID ?? null,
135
- customCodeHeader: dataBuilder.themePageCustomCode?.header ?? null,
136
- customCodeBody: dataBuilder.themePageCustomCode?.body ?? null,
144
+ gaTrackingId: getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.ANALYTICS_GA_TRACKING_ID, dataBuilder?.metafields) ?? null,
145
+ facebookPixelId: getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.ANALYTICS_FB_PIXEL_ID, dataBuilder?.metafields) ?? null,
146
+ tiktokPixelId: getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.ANALYTICS_TIKTOK_PIXEL_ID, dataBuilder?.metafields) ?? null,
147
+ customCodeHeader: getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.CUSTOM_CODE_HEADER, dataBuilder?.metafields) ?? null,
148
+ customCodeBody: getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.CUSTOM_CODE_BODY, dataBuilder?.metafields) ?? null,
137
149
  pageHandle: dataBuilder.handle ?? null
138
150
  });
139
151
  } catch (err) {
@@ -7,6 +7,8 @@ var genCss = require('../helpers/gen-css.js');
7
7
  var generateManifres = require('../helpers/generate-manifres.js');
8
8
  var normalize = require('../helpers/normalize.js');
9
9
  var parseJson = require('../helpers/parse-json.js');
10
+ var index = require('../../constants/index.js');
11
+ var getMetafield = require('../helpers/get-metafield.js');
10
12
 
11
13
  const getHomePageProps = (fetcher, shopifyFetcher)=>async ()=>{
12
14
  const pageType = 'STATIC';
@@ -17,7 +19,7 @@ const getHomePageProps = (fetcher, shopifyFetcher)=>async ()=>{
17
19
  // PublishedThemePagesDocument,
18
20
  // variables,
19
21
  // ]);
20
- const [theme, storeProperty, shopifyMeta] = await Promise.allSettled([
22
+ const [theme, storeProperty, shopifyMeta, publishedShopMetas] = await Promise.allSettled([
21
23
  fetcher([
22
24
  core.PublishedThemePagesDocument,
23
25
  variables
@@ -27,6 +29,15 @@ const getHomePageProps = (fetcher, shopifyFetcher)=>async ()=>{
27
29
  ]),
28
30
  shopifyFetcher([
29
31
  adapterShopify.ShopMetaDocument
32
+ ]),
33
+ fetcher([
34
+ core.PublishedShopMetasDocument,
35
+ {
36
+ keys: [
37
+ index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION,
38
+ index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL
39
+ ]
40
+ }
30
41
  ])
31
42
  ]);
32
43
  if (theme.status === 'rejected') {
@@ -34,6 +45,7 @@ const getHomePageProps = (fetcher, shopifyFetcher)=>async ()=>{
34
45
  pageType
35
46
  };
36
47
  }
48
+ const publishedShopMetaValue = publishedShopMetas.status === 'fulfilled' ? publishedShopMetas.value : undefined;
37
49
  const dataBuilder = theme.value.publishedThemePages?.[0];
38
50
  const homeTemplate = normalize.parseBuilderTemplate(dataBuilder);
39
51
  const fontStyle = await googleFonts.getFontFromGlobalStyle(dataBuilder?.pageStyle?.data);
@@ -58,8 +70,8 @@ const getHomePageProps = (fetcher, shopifyFetcher)=>async ()=>{
58
70
  }
59
71
  return acc;
60
72
  }, {});
61
- const description = dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-description')?.value;
62
- const thumbnail = parseJson.parseJson(dataBuilder?.themePageDataSEO?.find((item)=>item?.key === 'global-meta-thumbnail')?.value);
73
+ const description = getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION, dataBuilder?.metafields) || publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === index.PublishedThemePageMetafields.GLOBAL_META_DESCRIPTION)?.value;
74
+ const thumbnail = parseJson.parseJson(getMetafield.getPublishedThemePageMetafieldByKey(index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL, dataBuilder?.metafields) || publishedShopMetaValue?.publishedShopMetas?.find((item)=>item?.key === index.PublishedThemePageMetafields.GLOBAL_META_THUMBNAIL)?.value);
63
75
  const shopMeta = shopifyMeta.status === 'fulfilled' ? shopifyMeta.value : undefined;
64
76
  const shopData = storeProperty.status === 'fulfilled' ? storeProperty.value : undefined;
65
77
  const favicon = shopData?.storeProperty?.favicon ?? '/favicon/favicon-32x32.png';
@@ -33,6 +33,7 @@ const fetchSalePageDataByID = async (data, fetcher)=>{
33
33
  dataBuilder: theme.value.themePage,
34
34
  pageStyle: theme.value.themePage?.theme?.themeStyles?.edges?.[0]?.node?.data,
35
35
  storeProperty,
36
+ dynamicDiscountOffer: undefined,
36
37
  productOffers: []
37
38
  };
38
39
  };
@@ -44,7 +45,7 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
44
45
  default: true
45
46
  }
46
47
  };
47
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
48
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
48
49
  fetcher([
49
50
  core.ThemePageDocument,
50
51
  variables
@@ -59,6 +60,12 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
59
60
  saleFunnelOfferID: data.currentOfferID
60
61
  }
61
62
  }
63
+ ]),
64
+ fetcher([
65
+ core.SaleFunnelOfferDocument,
66
+ {
67
+ saleFunnelOfferId: data.currentOfferID
68
+ }
62
69
  ])
63
70
  ]);
64
71
  if (theme.status === 'rejected') {
@@ -67,10 +74,14 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
67
74
  if (saleFunnelDiscounts.status === 'rejected') {
68
75
  throw new Error(saleFunnelDiscounts.reason?.[0]);
69
76
  }
77
+ if (saleFunnelOffer.status === 'rejected') {
78
+ throw new Error(saleFunnelOffer.reason?.[0]);
79
+ }
70
80
  return {
71
81
  dataBuilder: theme.value.themePage,
72
82
  pageStyle: theme.value.themePage?.theme?.themeStyles?.edges?.[0]?.node?.data,
73
83
  storeProperty,
84
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
74
85
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
75
86
  };
76
87
  };
@@ -116,6 +127,7 @@ const fetchThemePageDataByTemplateID = async (data, fetcher)=>{
116
127
  dataBuilder: theme.value.libraryTemplate,
117
128
  pageStyle: undefined,
118
129
  storeProperty,
130
+ dynamicDiscountOffer: undefined,
119
131
  productOffers: productOffers
120
132
  };
121
133
  };
@@ -123,7 +135,7 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
123
135
  const variables = {
124
136
  shopLibraryPageId: data.shopLibraryPageId
125
137
  };
126
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
138
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
127
139
  fetcher([
128
140
  core.ShopLibraryPageDocument,
129
141
  variables
@@ -138,6 +150,12 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
138
150
  saleFunnelOfferID: data.currentOfferID
139
151
  }
140
152
  }
153
+ ]),
154
+ fetcher([
155
+ core.SaleFunnelOfferDocument,
156
+ {
157
+ saleFunnelOfferId: data.currentOfferID
158
+ }
141
159
  ])
142
160
  ]);
143
161
  if (theme.status === 'rejected') {
@@ -146,10 +164,14 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
146
164
  if (saleFunnelDiscounts.status === 'rejected') {
147
165
  throw new Error(saleFunnelDiscounts.reason?.[0]);
148
166
  }
167
+ if (saleFunnelOffer.status === 'rejected') {
168
+ throw new Error(saleFunnelOffer.reason?.[0]);
169
+ }
149
170
  return {
150
171
  dataBuilder: theme.value.shopLibraryPage,
151
172
  pageStyle: undefined,
152
173
  storeProperty,
174
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
153
175
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
154
176
  };
155
177
  };
@@ -157,7 +179,7 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
157
179
  const variables = {
158
180
  libraryTemplateId: data.libraryTemplateId
159
181
  };
160
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
182
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
161
183
  fetcher([
162
184
  core.LibraryTemplateDocument,
163
185
  variables
@@ -172,6 +194,12 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
172
194
  saleFunnelOfferID: data.currentOfferID
173
195
  }
174
196
  }
197
+ ]),
198
+ fetcher([
199
+ core.SaleFunnelOfferDocument,
200
+ {
201
+ saleFunnelOfferId: data.currentOfferID
202
+ }
175
203
  ])
176
204
  ]);
177
205
  if (theme.status === 'rejected') {
@@ -180,10 +208,14 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
180
208
  if (saleFunnelDiscounts.status === 'rejected') {
181
209
  throw new Error(saleFunnelDiscounts.reason?.[0]);
182
210
  }
211
+ if (saleFunnelOffer.status === 'rejected') {
212
+ throw new Error(saleFunnelOffer.reason?.[0]);
213
+ }
183
214
  return {
184
215
  dataBuilder: theme.value.libraryTemplate,
185
216
  pageStyle: undefined,
186
217
  storeProperty,
218
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
187
219
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
188
220
  };
189
221
  };
@@ -221,7 +253,7 @@ const getRelevantPageData = async (data)=>{
221
253
  const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (data)=>{
222
254
  try {
223
255
  const { id, currentOfferID, isLibraryTemplate, isShopLibraryPage } = data;
224
- const { dataBuilder, storeProperty, productOffers, pageStyle } = await getRelevantPageData({
256
+ const { dataBuilder, storeProperty, productOffers, pageStyle, dynamicDiscountOffer } = await getRelevantPageData({
225
257
  id,
226
258
  currentOfferID,
227
259
  fetcher,
@@ -250,7 +282,8 @@ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFet
250
282
  swr: {
251
283
  fallback
252
284
  },
253
- productOffers
285
+ productOffers,
286
+ dynamicDiscountOffer
254
287
  });
255
288
  } catch (err) {
256
289
  console.log('error', err);
@@ -10,6 +10,7 @@ var getFallback = require('../helpers/get-fallback.js');
10
10
  var normalize = require('../helpers/normalize.js');
11
11
  var parseJson = require('../helpers/parse-json.js');
12
12
  var customFonts = require('../custom-fonts.js');
13
+ var sentry = require('../helpers/sentry.js');
13
14
 
14
15
  const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
15
16
  try {
@@ -31,6 +32,10 @@ const getStaticPagePropsPreview = (fetcher, shopifyFetcher)=>async (slug)=>{
31
32
  ])
32
33
  ]);
33
34
  if (theme.status === 'rejected') {
35
+ sentry.sentryCaptureException('PreviewThemePageDocument', theme.reason, {
36
+ variables,
37
+ theme
38
+ });
34
39
  throw new Error(theme.reason?.[0]);
35
40
  }
36
41
  const dataBuilder = theme.value.previewThemePage;