@drawbridge/components 0.1.48 → 0.1.50
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/bridge/fields.js +0 -278
- package/dist/bridge/fields.mjs +1 -276
- package/dist/bridge/form-subdomain-shop-modal.js +274 -234
- package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
- package/dist/bridge/form-subdomain.js +0 -7
- package/dist/bridge/form-subdomain.mjs +2 -9
- package/dist/bridge/lib/age-gate.js +0 -12
- package/dist/bridge/lib/age-gate.mjs +0 -11
- package/dist/bridge/lib/checkout-kit.js +32 -2
- package/dist/bridge/lib/checkout-kit.mjs +32 -2
- package/dist/bridge/lib/entry.js +3 -3
- package/dist/bridge/lib/entry.mjs +2 -2
- package/dist/bridge/product-tile.js +6 -9
- package/dist/bridge/product-tile.mjs +6 -9
- package/dist/bridge/template-layout.js +123 -238
- package/dist/bridge/template-layout.mjs +124 -239
- package/dist/bridge/template-modal.js +73 -28
- package/dist/bridge/template-modal.mjs +74 -29
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +2 -7
- package/dist/dashboard/campaign-form.mjs +2 -7
- package/dist/dashboard/card-order.js +4 -22
- package/dist/dashboard/card-order.mjs +4 -22
- package/dist/dashboard/document-blocks.js +17 -4
- package/dist/dashboard/document-blocks.mjs +17 -4
- package/dist/dashboard/form-admin-provider.js +17 -71
- package/dist/dashboard/form-admin-provider.mjs +17 -71
- package/dist/dashboard/form-file-upload.js +2 -3
- package/dist/dashboard/form-file-upload.mjs +3 -4
- package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
- package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
- package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
- package/dist/dashboard/form-organization-campaign.js +0 -82
- package/dist/dashboard/form-organization-campaign.mjs +0 -81
- package/dist/dashboard/form-organization-connection.js +6 -48
- package/dist/dashboard/form-organization-connection.mjs +7 -48
- package/dist/dashboard/form-organization-workflow.js +1 -72
- package/dist/dashboard/form-organization-workflow.mjs +1 -69
- package/dist/dashboard/form-otc.js +5 -4
- package/dist/dashboard/form-otc.mjs +5 -4
- package/dist/dashboard/form-stripe.js +5 -12
- package/dist/dashboard/form-stripe.mjs +5 -12
- package/dist/dashboard/input-fields.js +158 -11
- package/dist/dashboard/input-fields.mjs +158 -11
- package/dist/dashboard/input-file.js +4 -21
- package/dist/dashboard/input-file.mjs +4 -21
- package/dist/dashboard/lib/connection-controls.js +2 -5
- package/dist/dashboard/lib/connection-controls.mjs +1 -3
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/uppy.js +1 -10
- package/dist/dashboard/lib/uppy.mjs +2 -11
- package/dist/dashboard/order-sections.js +6 -456
- package/dist/dashboard/order-sections.mjs +7 -453
- package/dist/dashboard/provider-ui.js +7 -9
- package/dist/dashboard/provider-ui.mjs +7 -9
- package/dist/dashboard/template-ui.js +12 -4
- package/dist/dashboard/template-ui.mjs +12 -4
- package/dist/input-checkbox.js +10 -28
- package/dist/input-checkbox.mjs +10 -28
- package/dist/product.js +24 -96
- package/dist/product.mjs +25 -97
- package/dist/shared/lib/helpers.js +6 -54
- package/dist/shared/lib/helpers.mjs +8 -53
- package/package.json +4 -74
- package/types/bridge/fields.d.ts +2 -14
- package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
- package/types/bridge/lib/age-gate.d.ts +0 -5
- package/types/bridge/lib/checkout-kit.d.ts +10 -2
- package/types/bridge/lib/entry.d.ts +3 -3
- package/types/dashboard/card-order.d.ts +0 -6
- package/types/dashboard/document-blocks.d.ts +3 -2
- package/types/dashboard/form-admin-provider.d.ts +2 -9
- package/types/dashboard/form-file-upload.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
- package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
- package/types/dashboard/form-organization-campaign.d.ts +0 -3
- package/types/dashboard/form-organization-connection.d.ts +0 -11
- package/types/dashboard/form-otc.d.ts +1 -5
- package/types/dashboard/form-stripe.d.ts +2 -3
- package/types/dashboard/input-file.d.ts +0 -2
- package/types/dashboard/order-sections.d.ts +1 -24
- package/types/input-checkbox.d.ts +0 -2
- package/types/shared/lib/helpers.d.ts +0 -4
- package/dist/bridge/cart-drawer.js +0 -152
- package/dist/bridge/cart-drawer.mjs +0 -123
- package/dist/bridge/form-subdomain-checkout.js +0 -687
- package/dist/bridge/form-subdomain-checkout.mjs +0 -665
- package/dist/bridge/lib/cart.js +0 -79
- package/dist/bridge/lib/cart.mjs +0 -48
- package/dist/dashboard/embed-stripe.js +0 -145
- package/dist/dashboard/embed-stripe.mjs +0 -116
- package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
- package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
- package/dist/dashboard/form-organization-product.js +0 -1461
- package/dist/dashboard/form-organization-product.mjs +0 -1425
- package/dist/dashboard/input-gallery.js +0 -201
- package/dist/dashboard/input-gallery.mjs +0 -172
- package/dist/dashboard/lib/products.js +0 -169
- package/dist/dashboard/lib/products.mjs +0 -135
- package/dist/dashboard/lib/settings-paths.js +0 -35
- package/dist/dashboard/lib/settings-paths.mjs +0 -11
- package/dist/dashboard/shipping-rates.js +0 -404
- package/dist/dashboard/shipping-rates.mjs +0 -371
- package/dist/dashboard/template-buyer.js +0 -301
- package/dist/dashboard/template-buyer.mjs +0 -267
- package/dist/shared/order-summary.js +0 -139
- package/dist/shared/order-summary.mjs +0 -110
- package/types/bridge/cart-drawer.d.ts +0 -31
- package/types/bridge/form-subdomain-checkout.d.ts +0 -20
- package/types/bridge/lib/cart.d.ts +0 -44
- package/types/dashboard/embed-stripe.d.ts +0 -25
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
- package/types/dashboard/form-organization-product.d.ts +0 -24
- package/types/dashboard/input-gallery.d.ts +0 -14
- package/types/dashboard/lib/products.d.ts +0 -14
- package/types/dashboard/lib/settings-paths.d.ts +0 -5
- package/types/dashboard/shipping-rates.d.ts +0 -26
- package/types/dashboard/template-buyer.d.ts +0 -50
- package/types/shared/order-summary.d.ts +0 -19
|
@@ -48,26 +48,10 @@ var import_link = __toESM(require("next/link"));
|
|
|
48
48
|
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
49
49
|
var import_constants = __toESM(require("./lib/constants"));
|
|
50
50
|
var import_checkout_kit = require("./lib/checkout-kit");
|
|
51
|
-
var import_cart = require("./lib/cart");
|
|
52
51
|
var import_provider_analytics = require("./provider-analytics");
|
|
53
52
|
var import_entry = require("./lib/entry");
|
|
54
53
|
var import_url = require("./lib/url");
|
|
55
54
|
const TemplateModal = (0, import_dynamic.default)(() => import("./template-modal"), { ssr: false });
|
|
56
|
-
const CartDrawer = (0, import_dynamic.default)(() => import("./cart-drawer"), { ssr: false });
|
|
57
|
-
const stored = (key) => {
|
|
58
|
-
try {
|
|
59
|
-
return JSON.parse(window.localStorage.getItem(key) || "null");
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
const store = (key, value) => {
|
|
65
|
-
try {
|
|
66
|
-
if (value) window.localStorage.setItem(key, JSON.stringify(value));
|
|
67
|
-
else window.localStorage.removeItem(key);
|
|
68
|
-
} catch {
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
55
|
const TemplateLayout = ({
|
|
72
56
|
params,
|
|
73
57
|
result,
|
|
@@ -92,11 +76,6 @@ const TemplateLayout = ({
|
|
|
92
76
|
const style = data == null ? void 0 : data.style;
|
|
93
77
|
const [cart, setCart] = (0, import_react.useState)(null);
|
|
94
78
|
const [cartLoading, setCartLoading] = (0, import_react.useState)(true);
|
|
95
|
-
const [drawer, setDrawer] = (0, import_react.useState)({ open: false, pay: null });
|
|
96
|
-
const [drawerOpened, setDrawerOpened] = (0, import_react.useState)(false);
|
|
97
|
-
const [cut, setCut] = (0, import_react.useState)([]);
|
|
98
|
-
const [submitted, setSubmitted] = (0, import_react.useState)(null);
|
|
99
|
-
const leadCode = searchParams.get("m");
|
|
100
79
|
const [modal, setModal] = (0, import_react.useState)(Boolean(submissionId));
|
|
101
80
|
const [opened, setOpened] = (0, import_react.useState)(Boolean(submissionId));
|
|
102
81
|
const [panel, setPanel] = (0, import_react.useState)(submissionId ? {
|
|
@@ -115,86 +94,45 @@ const TemplateLayout = ({
|
|
|
115
94
|
name: null,
|
|
116
95
|
data: {}
|
|
117
96
|
});
|
|
118
|
-
const cartCount = (0,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const who = (0, import_react.useMemo)(
|
|
122
|
-
() => ({
|
|
123
|
-
...affiliate && { affiliate },
|
|
124
|
-
...leadCode && { code: leadCode },
|
|
125
|
-
...(data == null ? void 0 : data.page) && { page: data.page },
|
|
126
|
-
...submitted && { submission: submitted }
|
|
127
|
-
}),
|
|
128
|
-
[affiliate, data == null ? void 0 : data.page, leadCode, submitted]
|
|
129
|
-
);
|
|
130
|
-
const openDrawer = (0, import_react.useCallback)(
|
|
131
|
-
(pay = null) => {
|
|
132
|
-
setDrawerOpened(true);
|
|
133
|
-
setDrawer({ open: true, pay });
|
|
134
|
-
},
|
|
135
|
-
[]
|
|
97
|
+
const cartCount = (0, import_react.useMemo)(
|
|
98
|
+
() => ((cart == null ? void 0 : cart.lines) || []).reduce((sum, line) => sum + (line.quantity || 0), 0),
|
|
99
|
+
[cart]
|
|
136
100
|
);
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
setPanel({
|
|
148
|
-
name: "purchase",
|
|
149
|
-
data: {
|
|
150
|
-
message: (0, import_entry.copy)(data, "purchase")
|
|
101
|
+
const cartRoot = "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart";
|
|
102
|
+
const cartStorageKey = "cart:" + (params == null ? void 0 : params.subdomain);
|
|
103
|
+
const checkout = (0, import_react.useCallback)(
|
|
104
|
+
(args = {}) => (0, import_checkout_kit.checkout)({
|
|
105
|
+
affiliate,
|
|
106
|
+
campaign: data == null ? void 0 : data.campaign,
|
|
107
|
+
onComplete: () => {
|
|
108
|
+
if (typeof window !== "undefined") {
|
|
109
|
+
window.localStorage.removeItem(cartStorageKey);
|
|
110
|
+
window.localStorage.removeItem(cartStorageKey + "_expiry");
|
|
151
111
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
onOpen: () => {
|
|
162
|
-
setModal(false);
|
|
163
|
-
closeDrawer();
|
|
112
|
+
;
|
|
113
|
+
setCart(null);
|
|
114
|
+
setPanel({
|
|
115
|
+
name: "purchase",
|
|
116
|
+
data: {
|
|
117
|
+
message: (0, import_entry.copy)(data, "purchase")
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
setModal(true);
|
|
164
121
|
},
|
|
165
|
-
|
|
122
|
+
onOpen: () => setModal(false),
|
|
123
|
+
onRedirect: redirectToCheckout,
|
|
124
|
+
organization: data == null ? void 0 : data.organization,
|
|
125
|
+
page: data == null ? void 0 : data.page,
|
|
126
|
+
slug: params == null ? void 0 : params.slug,
|
|
127
|
+
subdomain: params == null ? void 0 : params.subdomain,
|
|
128
|
+
...args
|
|
166
129
|
}),
|
|
167
|
-
[
|
|
168
|
-
);
|
|
169
|
-
const startCheckout = (0, import_react.useCallback)(
|
|
170
|
-
(paying) => (paying == null ? void 0 : paying.checkoutUrl) ? storeCheckout(paying) : openDrawer(paying),
|
|
171
|
-
[openDrawer, storeCheckout]
|
|
172
|
-
);
|
|
173
|
-
const checkout = (0, import_react.useCallback)(
|
|
174
|
-
async (args = {}) => {
|
|
175
|
-
var _a2;
|
|
176
|
-
if (!args.lines) return args.checkoutUrl ? storeCheckout({ checkoutUrl: args.checkoutUrl }) : null;
|
|
177
|
-
const response = await (0, import_fetch.request)({
|
|
178
|
-
body: {
|
|
179
|
-
...who,
|
|
180
|
-
...args.advertisement && { advertisement: args.advertisement },
|
|
181
|
-
lines: args.lines
|
|
182
|
-
},
|
|
183
|
-
endpoint: cartRoot,
|
|
184
|
-
method: "POST"
|
|
185
|
-
});
|
|
186
|
-
if (!((_a2 = response == null ? void 0 : response.result) == null ? void 0 : _a2.id)) return null;
|
|
187
|
-
setModal(false);
|
|
188
|
-
startCheckout(response.result);
|
|
189
|
-
return response.result;
|
|
190
|
-
},
|
|
191
|
-
[cartRoot, startCheckout, storeCheckout, who]
|
|
130
|
+
[affiliate, cartStorageKey, data, params == null ? void 0 : params.slug, params == null ? void 0 : params.subdomain, redirectToCheckout]
|
|
192
131
|
);
|
|
193
132
|
const openCheckout = (0, import_react.useCallback)(
|
|
194
133
|
(checkoutUrl) => checkout({ checkoutUrl }),
|
|
195
134
|
[checkout]
|
|
196
135
|
);
|
|
197
|
-
if (drawer.open && !drawerOpened) setDrawerOpened(true);
|
|
198
136
|
if ((modal || (panel == null ? void 0 : panel.name)) && !opened) setOpened(true);
|
|
199
137
|
(0, import_react.useEffect)(
|
|
200
138
|
() => {
|
|
@@ -234,138 +172,140 @@ const TemplateLayout = ({
|
|
|
234
172
|
(0, import_react.useEffect)(
|
|
235
173
|
() => {
|
|
236
174
|
if (typeof window === "undefined") return;
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
175
|
+
const cartId = window.localStorage.getItem(cartStorageKey);
|
|
176
|
+
const cartExpiry = window.localStorage.getItem(cartStorageKey + "_expiry");
|
|
177
|
+
const expired = !cartExpiry || Date.now() - Number(cartExpiry) > 864e5;
|
|
178
|
+
if (!cartId || expired) {
|
|
179
|
+
if (cartId && expired) {
|
|
180
|
+
window.localStorage.removeItem(cartStorageKey);
|
|
181
|
+
window.localStorage.removeItem(cartStorageKey + "_expiry");
|
|
182
|
+
}
|
|
183
|
+
;
|
|
240
184
|
setCartLoading(false);
|
|
241
185
|
return;
|
|
242
186
|
}
|
|
243
187
|
;
|
|
244
188
|
(0, import_fetch.request)({
|
|
245
|
-
endpoint: cartRoot + "?cartId=" + encodeURIComponent(
|
|
189
|
+
endpoint: cartRoot + "?cartId=" + encodeURIComponent(cartId),
|
|
246
190
|
method: "GET"
|
|
247
191
|
}).then(({ result: result2 }) => {
|
|
248
192
|
if (result2 == null ? void 0 : result2.id) {
|
|
249
193
|
setCart(result2);
|
|
250
194
|
} else {
|
|
251
|
-
|
|
195
|
+
window.localStorage.removeItem(cartStorageKey);
|
|
196
|
+
window.localStorage.removeItem(cartStorageKey + "_expiry");
|
|
252
197
|
}
|
|
253
198
|
;
|
|
254
199
|
}).catch(() => {
|
|
255
|
-
|
|
200
|
+
window.localStorage.removeItem(cartStorageKey);
|
|
201
|
+
window.localStorage.removeItem(cartStorageKey + "_expiry");
|
|
256
202
|
}).finally(() => {
|
|
257
203
|
setCartLoading(false);
|
|
258
204
|
});
|
|
259
205
|
},
|
|
260
206
|
[cartRoot, cartStorageKey]
|
|
261
207
|
);
|
|
262
|
-
const linkedCart = searchParams.get("drwbrdg_cart");
|
|
263
|
-
(0, import_react.useEffect)(
|
|
264
|
-
() => {
|
|
265
|
-
if (!linkedCart) return;
|
|
266
|
-
(0, import_fetch.request)({
|
|
267
|
-
endpoint: cartRoot + "?cartId=" + encodeURIComponent(linkedCart),
|
|
268
|
-
method: "GET"
|
|
269
|
-
}).then(({ result: result2 }) => {
|
|
270
|
-
var _a2;
|
|
271
|
-
if ((result2 == null ? void 0 : result2.id) && ((_a2 = result2.lines) == null ? void 0 : _a2.length)) startCheckout(result2);
|
|
272
|
-
}).catch(() => {
|
|
273
|
-
});
|
|
274
|
-
},
|
|
275
|
-
// Once per cart named: startCheckout changes with the page's cart.
|
|
276
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
277
|
-
[cartRoot, linkedCart]
|
|
278
|
-
);
|
|
279
208
|
const onAddToCart = (0, import_react.useCallback)(
|
|
280
209
|
async ({ variant }) => {
|
|
281
210
|
var _a2;
|
|
211
|
+
const attributes = [
|
|
212
|
+
...(data == null ? void 0 : data.campaign) ? [{ key: "_drwbrdg_ca", value: data.campaign }] : [],
|
|
213
|
+
...(data == null ? void 0 : data.organization) ? [{ key: "_drwbrdg_or", value: data.organization }] : [],
|
|
214
|
+
...affiliate ? [{ key: "_drwbrdg_af", value: affiliate }] : [],
|
|
215
|
+
...(data == null ? void 0 : data.page) ? [{ key: "_drwbrdg_pg", value: data.page }] : []
|
|
216
|
+
];
|
|
282
217
|
const line = {
|
|
218
|
+
attributes,
|
|
283
219
|
merchandiseId: variant.id,
|
|
284
220
|
quantity: 1
|
|
285
221
|
};
|
|
286
|
-
const create = () => (0, import_fetch.request)({
|
|
287
|
-
body: {
|
|
288
|
-
...who,
|
|
289
|
-
lines: [line]
|
|
290
|
-
},
|
|
291
|
-
endpoint: cartRoot,
|
|
292
|
-
method: "POST"
|
|
293
|
-
});
|
|
294
222
|
let response;
|
|
295
223
|
if (cart == null ? void 0 : cart.id) {
|
|
296
224
|
try {
|
|
297
225
|
response = await (0, import_fetch.request)({
|
|
298
226
|
body: {
|
|
299
|
-
...who,
|
|
300
227
|
cartId: cart.id,
|
|
301
228
|
lines: [line]
|
|
302
229
|
},
|
|
303
230
|
endpoint: cartRoot + "/lines",
|
|
304
231
|
method: "POST"
|
|
305
232
|
});
|
|
306
|
-
} catch
|
|
307
|
-
|
|
308
|
-
|
|
233
|
+
} catch {
|
|
234
|
+
response = await (0, import_fetch.request)({
|
|
235
|
+
body: {
|
|
236
|
+
lines: [line]
|
|
237
|
+
},
|
|
238
|
+
endpoint: cartRoot,
|
|
239
|
+
method: "POST"
|
|
240
|
+
});
|
|
309
241
|
}
|
|
310
242
|
} else {
|
|
311
|
-
response = await
|
|
243
|
+
response = await (0, import_fetch.request)({
|
|
244
|
+
body: {
|
|
245
|
+
lines: [line]
|
|
246
|
+
},
|
|
247
|
+
endpoint: cartRoot,
|
|
248
|
+
method: "POST"
|
|
249
|
+
});
|
|
312
250
|
}
|
|
313
251
|
;
|
|
314
252
|
if ((_a2 = response == null ? void 0 : response.result) == null ? void 0 : _a2.id) {
|
|
315
|
-
if (
|
|
253
|
+
if (typeof window !== "undefined") {
|
|
254
|
+
window.localStorage.setItem(cartStorageKey, response.result.id);
|
|
255
|
+
window.localStorage.setItem(cartStorageKey + "_expiry", String(Date.now()));
|
|
256
|
+
}
|
|
257
|
+
;
|
|
316
258
|
setCart(response.result);
|
|
317
|
-
|
|
318
|
-
setModal(false);
|
|
319
|
-
openDrawer();
|
|
259
|
+
setModal(true);
|
|
320
260
|
}
|
|
321
261
|
;
|
|
322
262
|
return response == null ? void 0 : response.result;
|
|
323
263
|
},
|
|
324
|
-
[cart, cartRoot, cartStorageKey,
|
|
264
|
+
[affiliate, cart, cartRoot, cartStorageKey, data]
|
|
325
265
|
);
|
|
326
|
-
const
|
|
327
|
-
async (lineId, quantity
|
|
266
|
+
const onCartLineUpdate = (0, import_react.useCallback)(
|
|
267
|
+
async (lineId, quantity) => {
|
|
328
268
|
var _a2;
|
|
329
269
|
if (!(cart == null ? void 0 : cart.id)) return;
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
270
|
+
const response = await (0, import_fetch.request)({
|
|
271
|
+
body: {
|
|
272
|
+
cartId: cart.id,
|
|
273
|
+
lines: [
|
|
274
|
+
{
|
|
275
|
+
id: lineId,
|
|
276
|
+
quantity
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
endpoint: cartRoot + "/lines",
|
|
281
|
+
method: "PUT"
|
|
282
|
+
});
|
|
283
|
+
if ((_a2 = response == null ? void 0 : response.result) == null ? void 0 : _a2.id) setCart(response.result);
|
|
339
284
|
},
|
|
340
|
-
[cart]
|
|
341
|
-
);
|
|
342
|
-
const onCartLineUpdate = (0, import_react.useCallback)(
|
|
343
|
-
(lineId, quantity) => changeLine(lineId, quantity, () => (0, import_fetch.request)({
|
|
344
|
-
body: {
|
|
345
|
-
...who,
|
|
346
|
-
cartId: cart == null ? void 0 : cart.id,
|
|
347
|
-
lines: [
|
|
348
|
-
{
|
|
349
|
-
id: lineId,
|
|
350
|
-
quantity
|
|
351
|
-
}
|
|
352
|
-
]
|
|
353
|
-
},
|
|
354
|
-
endpoint: cartRoot + "/lines",
|
|
355
|
-
method: "PUT"
|
|
356
|
-
})),
|
|
357
|
-
[cart == null ? void 0 : cart.id, cartRoot, changeLine, who]
|
|
285
|
+
[cart, cartRoot]
|
|
358
286
|
);
|
|
359
287
|
const onCartLineRemove = (0, import_react.useCallback)(
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
288
|
+
async (lineId) => {
|
|
289
|
+
var _a2, _b2;
|
|
290
|
+
if (!(cart == null ? void 0 : cart.id)) return;
|
|
291
|
+
const response = await (0, import_fetch.request)({
|
|
292
|
+
body: {
|
|
293
|
+
cartId: cart.id,
|
|
294
|
+
lineIds: [lineId]
|
|
295
|
+
},
|
|
296
|
+
endpoint: cartRoot + "/lines",
|
|
297
|
+
method: "DELETE"
|
|
298
|
+
});
|
|
299
|
+
if ((_a2 = response == null ? void 0 : response.result) == null ? void 0 : _a2.id) {
|
|
300
|
+
setCart(response.result);
|
|
301
|
+
if (!((_b2 = response.result.lines) == null ? void 0 : _b2.length) && typeof window !== "undefined") {
|
|
302
|
+
window.localStorage.removeItem(cartStorageKey);
|
|
303
|
+
}
|
|
304
|
+
;
|
|
305
|
+
}
|
|
306
|
+
;
|
|
307
|
+
},
|
|
308
|
+
[cart, cartRoot, cartStorageKey]
|
|
369
309
|
);
|
|
370
310
|
const tracking = (0, import_provider_analytics.useTracking)({
|
|
371
311
|
params,
|
|
@@ -459,7 +399,7 @@ const TemplateLayout = ({
|
|
|
459
399
|
data: {
|
|
460
400
|
affiliate,
|
|
461
401
|
after,
|
|
462
|
-
giveaway: (0, import_entry.
|
|
402
|
+
giveaway: (0, import_entry.missionsOn)(data, preview),
|
|
463
403
|
id,
|
|
464
404
|
lead,
|
|
465
405
|
message,
|
|
@@ -472,21 +412,8 @@ const TemplateLayout = ({
|
|
|
472
412
|
}
|
|
473
413
|
});
|
|
474
414
|
setModal(true);
|
|
475
|
-
if (id) {
|
|
476
|
-
setSubmitted(id);
|
|
477
|
-
if (cart == null ? void 0 : cart.id) (0, import_fetch.request)({
|
|
478
|
-
body: {
|
|
479
|
-
cartId: cart.id,
|
|
480
|
-
submission: id
|
|
481
|
-
},
|
|
482
|
-
endpoint: cartRoot,
|
|
483
|
-
method: "PUT"
|
|
484
|
-
}).catch(() => {
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
;
|
|
488
415
|
},
|
|
489
|
-
[affiliate,
|
|
416
|
+
[affiliate, data, params, preview, style]
|
|
490
417
|
);
|
|
491
418
|
const leadMission = searchParams.get("open");
|
|
492
419
|
const leadUrl = submissionId ? null : (0, import_url.leadEndpoint)({ code: searchParams.get("m"), slug: params == null ? void 0 : params.slug, subdomain: params == null ? void 0 : params.subdomain, token });
|
|
@@ -559,7 +486,7 @@ const TemplateLayout = ({
|
|
|
559
486
|
return {
|
|
560
487
|
branding: branding(),
|
|
561
488
|
brandingCompact: branding(true),
|
|
562
|
-
close: (name
|
|
489
|
+
close: (name) => {
|
|
563
490
|
var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h2, _i2, _j2, _k2;
|
|
564
491
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
565
492
|
import_button.default,
|
|
@@ -568,7 +495,7 @@ const TemplateLayout = ({
|
|
|
568
495
|
"aria-label": "Close Modal",
|
|
569
496
|
inline: true,
|
|
570
497
|
onClick: () => {
|
|
571
|
-
|
|
498
|
+
setModal(false);
|
|
572
499
|
tracking.track({
|
|
573
500
|
name: "button-" + name + "-close"
|
|
574
501
|
});
|
|
@@ -719,7 +646,10 @@ const TemplateLayout = ({
|
|
|
719
646
|
"aria-label": "Open Shop",
|
|
720
647
|
inline: true,
|
|
721
648
|
onClick: () => {
|
|
722
|
-
|
|
649
|
+
setPanel({
|
|
650
|
+
name
|
|
651
|
+
});
|
|
652
|
+
setModal(true);
|
|
723
653
|
tracking.track({
|
|
724
654
|
name: "button-" + name + "-open"
|
|
725
655
|
});
|
|
@@ -773,7 +703,7 @@ const TemplateLayout = ({
|
|
|
773
703
|
}
|
|
774
704
|
};
|
|
775
705
|
},
|
|
776
|
-
[cartCount, cartLoading, data, face,
|
|
706
|
+
[cartCount, cartLoading, data, face, preview, style, tracking]
|
|
777
707
|
);
|
|
778
708
|
const props = {
|
|
779
709
|
affiliate,
|
|
@@ -825,65 +755,20 @@ const TemplateLayout = ({
|
|
|
825
755
|
}
|
|
826
756
|
}
|
|
827
757
|
),
|
|
828
|
-
drawerOpened && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
829
|
-
CartDrawer,
|
|
830
|
-
{
|
|
831
|
-
...{
|
|
832
|
-
button: buttons.close("cart", closeDrawer),
|
|
833
|
-
cart,
|
|
834
|
-
cut,
|
|
835
|
-
fonts,
|
|
836
|
-
// The back arrow on the first step: the cart, as it was.
|
|
837
|
-
onBack: () => setDrawer({ open: true, pay: null }),
|
|
838
|
-
onCart: (next) => {
|
|
839
|
-
if ((next == null ? void 0 : next.id) && next.id === (cart == null ? void 0 : cart.id)) {
|
|
840
|
-
setCart(next);
|
|
841
|
-
setCut(next.cut || []);
|
|
842
|
-
}
|
|
843
|
-
;
|
|
844
|
-
},
|
|
845
|
-
onCheckout: startCheckout,
|
|
846
|
-
onClose: closeDrawer,
|
|
847
|
-
onLineRemove: onCartLineRemove,
|
|
848
|
-
onLineUpdate: onCartLineUpdate,
|
|
849
|
-
// @story shop/recommended-products
|
|
850
|
-
// A recommended row opens its product over the cart.
|
|
851
|
-
onOpenProduct: (product) => {
|
|
852
|
-
setPanel({
|
|
853
|
-
name: "product",
|
|
854
|
-
data: {
|
|
855
|
-
product
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
setModal(true);
|
|
859
|
-
},
|
|
860
|
-
onPaid: () => {
|
|
861
|
-
var _a3;
|
|
862
|
-
return paid((_a3 = drawer.pay) == null ? void 0 : _a3.id);
|
|
863
|
-
},
|
|
864
|
-
open: drawer.open,
|
|
865
|
-
params: {
|
|
866
|
-
...params,
|
|
867
|
-
token
|
|
868
|
-
},
|
|
869
|
-
pay: drawer.pay,
|
|
870
|
-
preview,
|
|
871
|
-
style,
|
|
872
|
-
tracking
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
),
|
|
876
758
|
opened && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
877
759
|
TemplateModal,
|
|
878
760
|
{
|
|
879
761
|
...{
|
|
880
762
|
buttons,
|
|
763
|
+
cart,
|
|
881
764
|
checkout,
|
|
882
765
|
data,
|
|
883
766
|
fonts,
|
|
884
767
|
iframe,
|
|
885
768
|
modal,
|
|
886
769
|
onAddToCart,
|
|
770
|
+
onCartLineRemove,
|
|
771
|
+
onCartLineUpdate,
|
|
887
772
|
openCheckout,
|
|
888
773
|
panel,
|
|
889
774
|
params,
|