@gem-sdk/pages 2.1.15 → 2.1.21
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/cjs/components/builder/Toolbox.js +11 -1
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +38 -5
- package/dist/cjs/pages/static-v2.js +2 -1
- package/dist/esm/components/builder/Toolbox.js +11 -1
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +39 -6
- package/dist/esm/pages/static-v2.js +2 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +2 -2
|
@@ -20,6 +20,7 @@ const Toolbox = ()=>{
|
|
|
20
20
|
const changeStorefrontInfo = core.useShopStore((s)=>s.changeStorefrontInfo);
|
|
21
21
|
const setDynamicProduct = core.usePageStore((s)=>s.setDynamicProduct);
|
|
22
22
|
const setPostPurchaseProductOffers = core.usePageStore((s)=>s.setPostPurchaseProductOffers);
|
|
23
|
+
const setDynamicDiscountOffer = core.usePageStore((s)=>s.setDynamicDiscountOffer);
|
|
23
24
|
const setSalePageProductId = core.usePageStore((s)=>s.setSalePageProductId);
|
|
24
25
|
const setDynamicCollection = core.usePageStore((s)=>s.setDynamicCollection);
|
|
25
26
|
const initState = core.useBuilderPreviewStore((s)=>s.initState);
|
|
@@ -345,6 +346,13 @@ const Toolbox = ()=>{
|
|
|
345
346
|
}, [
|
|
346
347
|
setPostPurchaseProductOffers
|
|
347
348
|
]);
|
|
349
|
+
const onUpdateDynamicDiscountOffer = react.useCallback((e)=>{
|
|
350
|
+
const dynamicDiscountOffer = e.detail;
|
|
351
|
+
if (!dynamicDiscountOffer) return;
|
|
352
|
+
setDynamicDiscountOffer(dynamicDiscountOffer);
|
|
353
|
+
}, [
|
|
354
|
+
setDynamicDiscountOffer
|
|
355
|
+
]);
|
|
348
356
|
const onUpdateSalePageProductId = react.useCallback((e)=>{
|
|
349
357
|
const id = e.detail;
|
|
350
358
|
if (!id) return;
|
|
@@ -416,6 +424,7 @@ const Toolbox = ()=>{
|
|
|
416
424
|
window.addEventListener('update-item-name', onUpdateItemName);
|
|
417
425
|
window.addEventListener('update-item-attribute', onUpdateItemAttribute);
|
|
418
426
|
window.addEventListener('set-product-offer', onUpdateProductOffers);
|
|
427
|
+
window.addEventListener('set-dynamic-discount-offer', onUpdateDynamicDiscountOffer);
|
|
419
428
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
420
429
|
window.addEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
421
430
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
@@ -473,7 +482,8 @@ const Toolbox = ()=>{
|
|
|
473
482
|
onUpdateInteractionIsSelectOnPage,
|
|
474
483
|
onUpdateInteractionSettingType,
|
|
475
484
|
onUpdateFontType,
|
|
476
|
-
onChangeSidebarMode
|
|
485
|
+
onChangeSidebarMode,
|
|
486
|
+
onUpdateDynamicDiscountOffer
|
|
477
487
|
]);
|
|
478
488
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
479
489
|
className: "toolbox"
|
|
@@ -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
|
nextjs.captureException(err);
|
|
@@ -12,7 +12,7 @@ var FooterForPostPurchase = require('../components/FooterForPostPurchase.js');
|
|
|
12
12
|
var Script = require('next/script');
|
|
13
13
|
var react = require('react');
|
|
14
14
|
|
|
15
|
-
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
15
|
+
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, dynamicDiscountOffer, isPreview, interaction })=>{
|
|
16
16
|
const router$1 = router.useRouter();
|
|
17
17
|
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
18
18
|
useTrackingView.useTrackingView(shopToken, pageHandle, router$1.isFallback);
|
|
@@ -86,6 +86,7 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
86
86
|
/*#__PURE__*/ jsxRuntime.jsx(core.PageProvider, {
|
|
87
87
|
productOffers: productOffers,
|
|
88
88
|
publicStoreFrontData: publicStoreFrontData,
|
|
89
|
+
dynamicDiscountOffer: dynamicDiscountOffer,
|
|
89
90
|
children: /*#__PURE__*/ jsxRuntime.jsx(core.BuilderComponentProvider, {
|
|
90
91
|
components: components,
|
|
91
92
|
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
@@ -16,6 +16,7 @@ const Toolbox = ()=>{
|
|
|
16
16
|
const changeStorefrontInfo = useShopStore((s)=>s.changeStorefrontInfo);
|
|
17
17
|
const setDynamicProduct = usePageStore((s)=>s.setDynamicProduct);
|
|
18
18
|
const setPostPurchaseProductOffers = usePageStore((s)=>s.setPostPurchaseProductOffers);
|
|
19
|
+
const setDynamicDiscountOffer = usePageStore((s)=>s.setDynamicDiscountOffer);
|
|
19
20
|
const setSalePageProductId = usePageStore((s)=>s.setSalePageProductId);
|
|
20
21
|
const setDynamicCollection = usePageStore((s)=>s.setDynamicCollection);
|
|
21
22
|
const initState = useBuilderPreviewStore((s)=>s.initState);
|
|
@@ -341,6 +342,13 @@ const Toolbox = ()=>{
|
|
|
341
342
|
}, [
|
|
342
343
|
setPostPurchaseProductOffers
|
|
343
344
|
]);
|
|
345
|
+
const onUpdateDynamicDiscountOffer = useCallback((e)=>{
|
|
346
|
+
const dynamicDiscountOffer = e.detail;
|
|
347
|
+
if (!dynamicDiscountOffer) return;
|
|
348
|
+
setDynamicDiscountOffer(dynamicDiscountOffer);
|
|
349
|
+
}, [
|
|
350
|
+
setDynamicDiscountOffer
|
|
351
|
+
]);
|
|
344
352
|
const onUpdateSalePageProductId = useCallback((e)=>{
|
|
345
353
|
const id = e.detail;
|
|
346
354
|
if (!id) return;
|
|
@@ -412,6 +420,7 @@ const Toolbox = ()=>{
|
|
|
412
420
|
window.addEventListener('update-item-name', onUpdateItemName);
|
|
413
421
|
window.addEventListener('update-item-attribute', onUpdateItemAttribute);
|
|
414
422
|
window.addEventListener('set-product-offer', onUpdateProductOffers);
|
|
423
|
+
window.addEventListener('set-dynamic-discount-offer', onUpdateDynamicDiscountOffer);
|
|
415
424
|
window.addEventListener('update-sale-page-product-id', onUpdateSalePageProductId);
|
|
416
425
|
window.addEventListener('limit-create-theme-section', onLimitCreateThemeSection);
|
|
417
426
|
window.addEventListener('update-interaction-is-select-on-page', onUpdateInteractionIsSelectOnPage);
|
|
@@ -469,7 +478,8 @@ const Toolbox = ()=>{
|
|
|
469
478
|
onUpdateInteractionIsSelectOnPage,
|
|
470
479
|
onUpdateInteractionSettingType,
|
|
471
480
|
onUpdateFontType,
|
|
472
|
-
onChangeSidebarMode
|
|
481
|
+
onChangeSidebarMode,
|
|
482
|
+
onUpdateDynamicDiscountOffer
|
|
473
483
|
]);
|
|
474
484
|
return /*#__PURE__*/ jsx("div", {
|
|
475
485
|
className: "toolbox"
|
|
@@ -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
|
captureException(err);
|
|
@@ -10,7 +10,7 @@ import FooterForPostPurchase from '../components/FooterForPostPurchase.js';
|
|
|
10
10
|
import Script from 'next/script';
|
|
11
11
|
import { useEffect } from 'react';
|
|
12
12
|
|
|
13
|
-
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, isPreview, interaction })=>{
|
|
13
|
+
const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, fontStyle, elementFontStyle, customCodeHeader, shopToken, pageHandle, customFonts, isPostPurchase, shopName, productOffers, publicStoreFrontData, dynamicDiscountOffer, isPreview, interaction })=>{
|
|
14
14
|
const router = useRouter();
|
|
15
15
|
const baseAssetURL = process.env.NEXT_GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
|
|
16
16
|
useTrackingView(shopToken, pageHandle, router.isFallback);
|
|
@@ -84,6 +84,7 @@ const StaticPageV2 = ({ components, builderData, sectionData, seo, themeStyle, f
|
|
|
84
84
|
/*#__PURE__*/ jsx(PageProvider, {
|
|
85
85
|
productOffers: productOffers,
|
|
86
86
|
publicStoreFrontData: publicStoreFrontData,
|
|
87
|
+
dynamicDiscountOffer: dynamicDiscountOffer,
|
|
87
88
|
children: /*#__PURE__*/ jsx(BuilderComponentProvider, {
|
|
88
89
|
components: components,
|
|
89
90
|
children: /*#__PURE__*/ jsxs("div", {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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';
|
|
@@ -90,6 +91,7 @@ type StaticPagePropsV2 = PageBuilderPropsV2 & {
|
|
|
90
91
|
isPostPurchase?: boolean;
|
|
91
92
|
shopName?: string;
|
|
92
93
|
productOffers?: ProductOffer[];
|
|
94
|
+
dynamicDiscountOffer?: OfferDynamicDiscount;
|
|
93
95
|
publicStoreFrontData?: PublicStoreFrontData | null;
|
|
94
96
|
isPreview?: boolean;
|
|
95
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/pages",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.21",
|
|
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.1.
|
|
29
|
+
"@gem-sdk/core": "2.1.21",
|
|
30
30
|
"@gem-sdk/plugin-cookie-bar": "2.1.0",
|
|
31
31
|
"@gem-sdk/plugin-quick-view": "2.1.0",
|
|
32
32
|
"@gem-sdk/plugin-sticky-add-to-cart": "2.1.0"
|