@gem-sdk/pages 2.0.0-dev.184 → 2.0.0-dev.201
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/image-to-layout/DropElement.js +27 -8
- package/dist/cjs/libs/api/get-post-purchase-props-preview.js +38 -5
- package/dist/cjs/pages/static-v2.js +2 -2
- package/dist/esm/components/image-to-layout/DropElement.js +27 -8
- package/dist/esm/libs/api/get-post-purchase-props-preview.js +39 -6
- package/dist/esm/pages/static-v2.js +2 -2
- package/dist/types/index.d.ts +2 -0
- package/package.json +2 -2
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var core = require('@gem-sdk/core');
|
|
5
6
|
|
|
6
7
|
const DropElement = ()=>{
|
|
8
|
+
const editingPageType = core.useShopStore((s)=>s.pageType);
|
|
7
9
|
const dispatchEventBuildWithSectionActiveTab = (value)=>{
|
|
8
10
|
const event = new CustomEvent('editor:sidebar:build-with-section-active-tab', {
|
|
9
11
|
bubbles: true,
|
|
@@ -13,6 +15,15 @@ const DropElement = ()=>{
|
|
|
13
15
|
});
|
|
14
16
|
window.dispatchEvent(event);
|
|
15
17
|
};
|
|
18
|
+
const dispatchEventBuildWithTemplateActiveTab = (value)=>{
|
|
19
|
+
const event = new CustomEvent('editor:sidebar:build-with-template-active-tab', {
|
|
20
|
+
bubbles: true,
|
|
21
|
+
detail: {
|
|
22
|
+
value
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
window.dispatchEvent(event);
|
|
26
|
+
};
|
|
16
27
|
const handleClickGenerate = (e)=>{
|
|
17
28
|
const event = new CustomEvent('editor:sidebar:click-img-to-layout-gallery-btn', e);
|
|
18
29
|
window.dispatchEvent(event);
|
|
@@ -101,22 +112,30 @@ const DropElement = ()=>{
|
|
|
101
112
|
children: [
|
|
102
113
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
103
114
|
className: "gp-text-16 gp-font-medium gp-mb-4 gp-text-[#212121]",
|
|
104
|
-
children:
|
|
115
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Start building with Sections/Elements or' : 'Start with Sections from sidebar'
|
|
105
116
|
}),
|
|
106
117
|
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
107
|
-
className: "gp-flex gp-
|
|
118
|
+
className: "gp-flex gp-gap-3 gp-justify-between",
|
|
108
119
|
children: [
|
|
109
120
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
110
121
|
"data-button-add-section": true,
|
|
111
|
-
onClick: ()=>
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
onClick: ()=>{
|
|
123
|
+
if (editingPageType === 'GP_FUNNEL_PAGE') {
|
|
124
|
+
dispatchEventBuildWithTemplateActiveTab('funnelExisting');
|
|
125
|
+
} else dispatchEventBuildWithSectionActiveTab(true);
|
|
126
|
+
},
|
|
127
|
+
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]",
|
|
128
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Use existing page designs' : 'Add sections'
|
|
114
129
|
}),
|
|
115
130
|
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
116
131
|
"data-button-add-elements": true,
|
|
117
|
-
onClick: ()=>
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
onClick: ()=>{
|
|
133
|
+
if (editingPageType === 'GP_FUNNEL_PAGE') {
|
|
134
|
+
dispatchEventBuildWithTemplateActiveTab('templates');
|
|
135
|
+
} else dispatchEventBuildWithSectionActiveTab(false);
|
|
136
|
+
},
|
|
137
|
+
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]",
|
|
138
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Explore templates' : 'Add elements'
|
|
120
139
|
})
|
|
121
140
|
]
|
|
122
141
|
}),
|
|
@@ -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,7 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useShopStore } from '@gem-sdk/core';
|
|
3
4
|
|
|
4
5
|
const DropElement = ()=>{
|
|
6
|
+
const editingPageType = useShopStore((s)=>s.pageType);
|
|
5
7
|
const dispatchEventBuildWithSectionActiveTab = (value)=>{
|
|
6
8
|
const event = new CustomEvent('editor:sidebar:build-with-section-active-tab', {
|
|
7
9
|
bubbles: true,
|
|
@@ -11,6 +13,15 @@ const DropElement = ()=>{
|
|
|
11
13
|
});
|
|
12
14
|
window.dispatchEvent(event);
|
|
13
15
|
};
|
|
16
|
+
const dispatchEventBuildWithTemplateActiveTab = (value)=>{
|
|
17
|
+
const event = new CustomEvent('editor:sidebar:build-with-template-active-tab', {
|
|
18
|
+
bubbles: true,
|
|
19
|
+
detail: {
|
|
20
|
+
value
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
window.dispatchEvent(event);
|
|
24
|
+
};
|
|
14
25
|
const handleClickGenerate = (e)=>{
|
|
15
26
|
const event = new CustomEvent('editor:sidebar:click-img-to-layout-gallery-btn', e);
|
|
16
27
|
window.dispatchEvent(event);
|
|
@@ -99,22 +110,30 @@ const DropElement = ()=>{
|
|
|
99
110
|
children: [
|
|
100
111
|
/*#__PURE__*/ jsx("div", {
|
|
101
112
|
className: "gp-text-16 gp-font-medium gp-mb-4 gp-text-[#212121]",
|
|
102
|
-
children:
|
|
113
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Start building with Sections/Elements or' : 'Start with Sections from sidebar'
|
|
103
114
|
}),
|
|
104
115
|
/*#__PURE__*/ jsxs("div", {
|
|
105
|
-
className: "gp-flex gp-
|
|
116
|
+
className: "gp-flex gp-gap-3 gp-justify-between",
|
|
106
117
|
children: [
|
|
107
118
|
/*#__PURE__*/ jsx("button", {
|
|
108
119
|
"data-button-add-section": true,
|
|
109
|
-
onClick: ()=>
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
onClick: ()=>{
|
|
121
|
+
if (editingPageType === 'GP_FUNNEL_PAGE') {
|
|
122
|
+
dispatchEventBuildWithTemplateActiveTab('funnelExisting');
|
|
123
|
+
} else dispatchEventBuildWithSectionActiveTab(true);
|
|
124
|
+
},
|
|
125
|
+
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]",
|
|
126
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Use existing page designs' : 'Add sections'
|
|
112
127
|
}),
|
|
113
128
|
/*#__PURE__*/ jsx("button", {
|
|
114
129
|
"data-button-add-elements": true,
|
|
115
|
-
onClick: ()=>
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
onClick: ()=>{
|
|
131
|
+
if (editingPageType === 'GP_FUNNEL_PAGE') {
|
|
132
|
+
dispatchEventBuildWithTemplateActiveTab('templates');
|
|
133
|
+
} else dispatchEventBuildWithSectionActiveTab(false);
|
|
134
|
+
},
|
|
135
|
+
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]",
|
|
136
|
+
children: editingPageType === 'GP_FUNNEL_PAGE' ? 'Explore templates' : 'Add elements'
|
|
118
137
|
})
|
|
119
138
|
]
|
|
120
139
|
}),
|
|
@@ -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", {
|
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';
|
|
@@ -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.
|
|
3
|
+
"version": "2.0.0-dev.201",
|
|
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.
|
|
29
|
+
"@gem-sdk/core": "2.0.0-dev.200",
|
|
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"
|