@gem-sdk/pages 2.0.0-dev.184 → 2.0.0-dev.194

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.
@@ -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);
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  'use strict';
3
2
 
4
3
  var jsxRuntime = require('react/jsx-runtime');
@@ -13,7 +12,7 @@ var FooterForPostPurchase = require('../components/FooterForPostPurchase.js');
13
12
  var Script = require('next/script');
14
13
  var react = require('react');
15
14
 
16
- const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction, pageBackground })=>{
15
+ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, dynamicDiscountOffer, isPreview, interaction, pageBackground })=>{
17
16
  const router$1 = router.useRouter();
18
17
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
19
18
  useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
@@ -94,6 +93,7 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
94
93
  /*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
95
94
  productOffers: productOffers,
96
95
  publicStoreFrontData: publicStoreFrontData,
96
+ dynamicDiscountOffer: dynamicDiscountOffer,
97
97
  children: /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
98
98
  components: components,
99
99
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -1,4 +1,4 @@
1
- import { ThemePageDocument, StorePropertyDocument, SaleFunnelDiscountsDocument, LibraryTemplateDocument, LibrarySaleFunnelDocument, ShopLibraryPageDocument } from '@gem-sdk/core';
1
+ import { ThemePageDocument, StorePropertyDocument, SaleFunnelDiscountsDocument, SaleFunnelOfferDocument, LibraryTemplateDocument, LibrarySaleFunnelDocument, ShopLibraryPageDocument } from '@gem-sdk/core';
2
2
  import { captureException } from '@sentry/nextjs';
3
3
  import { getFontStyleFromPageTemplate, getFontFromGlobalStyle } from '../google-fonts.js';
4
4
  import { getFallbackV2 } from '../helpers/get-fallback.js';
@@ -31,6 +31,7 @@ const fetchSalePageDataByID = async (data, fetcher)=>{
31
31
  dataBuilder: theme.value.themePage,
32
32
  pageStyle: theme.value.themePage?.theme?.themeStyles?.edges?.[0]?.node?.data,
33
33
  storeProperty,
34
+ dynamicDiscountOffer: undefined,
34
35
  productOffers: []
35
36
  };
36
37
  };
@@ -42,7 +43,7 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
42
43
  default: true
43
44
  }
44
45
  };
45
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
46
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
46
47
  fetcher([
47
48
  ThemePageDocument,
48
49
  variables
@@ -57,6 +58,12 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
57
58
  saleFunnelOfferID: data.currentOfferID
58
59
  }
59
60
  }
61
+ ]),
62
+ fetcher([
63
+ SaleFunnelOfferDocument,
64
+ {
65
+ saleFunnelOfferId: data.currentOfferID
66
+ }
60
67
  ])
61
68
  ]);
62
69
  if (theme.status === 'rejected') {
@@ -65,10 +72,14 @@ const fetchPostPurchasePageDataByID = async (data, fetcher)=>{
65
72
  if (saleFunnelDiscounts.status === 'rejected') {
66
73
  throw new Error(saleFunnelDiscounts.reason?.[0]);
67
74
  }
75
+ if (saleFunnelOffer.status === 'rejected') {
76
+ throw new Error(saleFunnelOffer.reason?.[0]);
77
+ }
68
78
  return {
69
79
  dataBuilder: theme.value.themePage,
70
80
  pageStyle: theme.value.themePage?.theme?.themeStyles?.edges?.[0]?.node?.data,
71
81
  storeProperty,
82
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
72
83
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
73
84
  };
74
85
  };
@@ -114,6 +125,7 @@ const fetchThemePageDataByTemplateID = async (data, fetcher)=>{
114
125
  dataBuilder: theme.value.libraryTemplate,
115
126
  pageStyle: undefined,
116
127
  storeProperty,
128
+ dynamicDiscountOffer: undefined,
117
129
  productOffers: productOffers
118
130
  };
119
131
  };
@@ -121,7 +133,7 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
121
133
  const variables = {
122
134
  shopLibraryPageId: data.shopLibraryPageId
123
135
  };
124
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
136
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
125
137
  fetcher([
126
138
  ShopLibraryPageDocument,
127
139
  variables
@@ -136,6 +148,12 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
136
148
  saleFunnelOfferID: data.currentOfferID
137
149
  }
138
150
  }
151
+ ]),
152
+ fetcher([
153
+ SaleFunnelOfferDocument,
154
+ {
155
+ saleFunnelOfferId: data.currentOfferID
156
+ }
139
157
  ])
140
158
  ]);
141
159
  if (theme.status === 'rejected') {
@@ -144,10 +162,14 @@ const fetchShopLibraryPageDataByID = async (data, fetcher)=>{
144
162
  if (saleFunnelDiscounts.status === 'rejected') {
145
163
  throw new Error(saleFunnelDiscounts.reason?.[0]);
146
164
  }
165
+ if (saleFunnelOffer.status === 'rejected') {
166
+ throw new Error(saleFunnelOffer.reason?.[0]);
167
+ }
147
168
  return {
148
169
  dataBuilder: theme.value.shopLibraryPage,
149
170
  pageStyle: undefined,
150
171
  storeProperty,
172
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
151
173
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
152
174
  };
153
175
  };
@@ -155,7 +177,7 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
155
177
  const variables = {
156
178
  libraryTemplateId: data.libraryTemplateId
157
179
  };
158
- const [theme, storeProperty, saleFunnelDiscounts] = await Promise.allSettled([
180
+ const [theme, storeProperty, saleFunnelDiscounts, saleFunnelOffer] = await Promise.allSettled([
159
181
  fetcher([
160
182
  LibraryTemplateDocument,
161
183
  variables
@@ -170,6 +192,12 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
170
192
  saleFunnelOfferID: data.currentOfferID
171
193
  }
172
194
  }
195
+ ]),
196
+ fetcher([
197
+ SaleFunnelOfferDocument,
198
+ {
199
+ saleFunnelOfferId: data.currentOfferID
200
+ }
173
201
  ])
174
202
  ]);
175
203
  if (theme.status === 'rejected') {
@@ -178,10 +206,14 @@ const fetchLibraryTemplateDataByID = async (data, fetcher)=>{
178
206
  if (saleFunnelDiscounts.status === 'rejected') {
179
207
  throw new Error(saleFunnelDiscounts.reason?.[0]);
180
208
  }
209
+ if (saleFunnelOffer.status === 'rejected') {
210
+ throw new Error(saleFunnelOffer.reason?.[0]);
211
+ }
181
212
  return {
182
213
  dataBuilder: theme.value.libraryTemplate,
183
214
  pageStyle: undefined,
184
215
  storeProperty,
216
+ dynamicDiscountOffer: saleFunnelOffer.value.saleFunnelOffer?.dynamicDiscounts?.[0],
185
217
  productOffers: saleFunnelDiscounts.value.saleFunnelDiscounts?.edges?.filter((item)=>item?.node?.objectType === 'PRODUCT' && item?.node?.type === 'ORDER_VALUE') || []
186
218
  };
187
219
  };
@@ -219,7 +251,7 @@ const getRelevantPageData = async (data)=>{
219
251
  const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFetcher)=>async (data)=>{
220
252
  try {
221
253
  const { id, currentOfferID, isLibraryTemplate, isShopLibraryPage } = data;
222
- const { dataBuilder, storeProperty, productOffers, pageStyle } = await getRelevantPageData({
254
+ const { dataBuilder, storeProperty, productOffers, pageStyle, dynamicDiscountOffer } = await getRelevantPageData({
223
255
  id,
224
256
  currentOfferID,
225
257
  fetcher,
@@ -248,7 +280,8 @@ const getPostPurchasePropsPreview = (fetcher, librarySaleFunnelID, storeFrontFet
248
280
  swr: {
249
281
  fallback
250
282
  },
251
- productOffers
283
+ productOffers,
284
+ dynamicDiscountOffer
252
285
  });
253
286
  } catch (err) {
254
287
  console.log('error', err);
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
2
  import { PageProvider, BuilderComponentProvider, SectionProvider, BuilderProvider, Render } from '@gem-sdk/core';
4
3
  import { NextSeo } from 'next-seo';
@@ -11,7 +10,7 @@ import FooterForPostPurchase from '../components/FooterForPostPurchase.js';
11
10
  import Script from 'next/script';
12
11
  import { useEffect } from 'react';
13
12
 
14
- const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction, pageBackground })=>{
13
+ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, dynamicDiscountOffer, isPreview, interaction, pageBackground })=>{
15
14
  const router = useRouter();
16
15
  const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
17
16
  useTrackingView(shopToken, pageHandle, router.isFallback);
@@ -92,6 +91,7 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
92
91
  /*#__PURE__*/ jsx(PageProvider, {
93
92
  productOffers: productOffers,
94
93
  publicStoreFrontData: publicStoreFrontData,
94
+ dynamicDiscountOffer: dynamicDiscountOffer,
95
95
  children: /*#__PURE__*/ jsx(BuilderComponentProvider, {
96
96
  components: components,
97
97
  children: /*#__PURE__*/ jsxs("div", {
@@ -4,6 +4,7 @@ import * as next_seo from 'next-seo';
4
4
  import { NextSeoProps } from 'next-seo';
5
5
  import { AppProps } from 'next/app';
6
6
  import { SWRConfig } from 'swr';
7
+ import { OfferDynamicDiscount } from '@gem-sdk/core/src/types/appAPI';
7
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
9
  import { ShopMetaQueryResponse } from '@gem-sdk/adapter-shopify';
9
10
  import * as react from 'react';
@@ -94,6 +95,7 @@ type StaticPagePropsV2 = PageBuilderPropsV2 & {
94
95
  isPostPurchase?: boolean;
95
96
  shopName?: string;
96
97
  productOffers?: ProductOffer[];
98
+ dynamicDiscountOffer?: OfferDynamicDiscount;
97
99
  publicStoreFrontData?: PublicStoreFrontData | null;
98
100
  isPreview?: boolean;
99
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/pages",
3
- "version": "2.0.0-dev.184",
3
+ "version": "2.0.0-dev.194",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -26,7 +26,7 @@
26
26
  "next": "latest"
27
27
  },
28
28
  "devDependencies": {
29
- "@gem-sdk/core": "2.0.0-dev.184",
29
+ "@gem-sdk/core": "2.0.0-dev.195",
30
30
  "@gem-sdk/plugin-cookie-bar": "2.0.0-dev.184",
31
31
  "@gem-sdk/plugin-quick-view": "2.0.0-dev.184",
32
32
  "@gem-sdk/plugin-sticky-add-to-cart": "2.0.0-dev.184"