@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.
Files changed (125) hide show
  1. package/dist/bridge/fields.js +0 -278
  2. package/dist/bridge/fields.mjs +1 -276
  3. package/dist/bridge/form-subdomain-shop-modal.js +274 -234
  4. package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
  5. package/dist/bridge/form-subdomain.js +0 -7
  6. package/dist/bridge/form-subdomain.mjs +2 -9
  7. package/dist/bridge/lib/age-gate.js +0 -12
  8. package/dist/bridge/lib/age-gate.mjs +0 -11
  9. package/dist/bridge/lib/checkout-kit.js +32 -2
  10. package/dist/bridge/lib/checkout-kit.mjs +32 -2
  11. package/dist/bridge/lib/entry.js +3 -3
  12. package/dist/bridge/lib/entry.mjs +2 -2
  13. package/dist/bridge/product-tile.js +6 -9
  14. package/dist/bridge/product-tile.mjs +6 -9
  15. package/dist/bridge/template-layout.js +123 -238
  16. package/dist/bridge/template-layout.mjs +124 -239
  17. package/dist/bridge/template-modal.js +73 -28
  18. package/dist/bridge/template-modal.mjs +74 -29
  19. package/dist/dashboard/buttons-subscription.js +1 -1
  20. package/dist/dashboard/buttons-subscription.mjs +1 -1
  21. package/dist/dashboard/campaign-form.js +2 -7
  22. package/dist/dashboard/campaign-form.mjs +2 -7
  23. package/dist/dashboard/card-order.js +4 -22
  24. package/dist/dashboard/card-order.mjs +4 -22
  25. package/dist/dashboard/document-blocks.js +17 -4
  26. package/dist/dashboard/document-blocks.mjs +17 -4
  27. package/dist/dashboard/form-admin-provider.js +17 -71
  28. package/dist/dashboard/form-admin-provider.mjs +17 -71
  29. package/dist/dashboard/form-file-upload.js +2 -3
  30. package/dist/dashboard/form-file-upload.mjs +3 -4
  31. package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
  32. package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
  33. package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
  34. package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
  35. package/dist/dashboard/form-organization-campaign.js +0 -82
  36. package/dist/dashboard/form-organization-campaign.mjs +0 -81
  37. package/dist/dashboard/form-organization-connection.js +6 -48
  38. package/dist/dashboard/form-organization-connection.mjs +7 -48
  39. package/dist/dashboard/form-organization-workflow.js +1 -72
  40. package/dist/dashboard/form-organization-workflow.mjs +1 -69
  41. package/dist/dashboard/form-otc.js +5 -4
  42. package/dist/dashboard/form-otc.mjs +5 -4
  43. package/dist/dashboard/form-stripe.js +5 -12
  44. package/dist/dashboard/form-stripe.mjs +5 -12
  45. package/dist/dashboard/input-fields.js +158 -11
  46. package/dist/dashboard/input-fields.mjs +158 -11
  47. package/dist/dashboard/input-file.js +4 -21
  48. package/dist/dashboard/input-file.mjs +4 -21
  49. package/dist/dashboard/lib/connection-controls.js +2 -5
  50. package/dist/dashboard/lib/connection-controls.mjs +1 -3
  51. package/dist/dashboard/lib/form-page.js +1 -1
  52. package/dist/dashboard/lib/form-page.mjs +1 -1
  53. package/dist/dashboard/lib/uppy.js +1 -10
  54. package/dist/dashboard/lib/uppy.mjs +2 -11
  55. package/dist/dashboard/order-sections.js +6 -456
  56. package/dist/dashboard/order-sections.mjs +7 -453
  57. package/dist/dashboard/provider-ui.js +7 -9
  58. package/dist/dashboard/provider-ui.mjs +7 -9
  59. package/dist/dashboard/template-ui.js +12 -4
  60. package/dist/dashboard/template-ui.mjs +12 -4
  61. package/dist/input-checkbox.js +10 -28
  62. package/dist/input-checkbox.mjs +10 -28
  63. package/dist/product.js +24 -96
  64. package/dist/product.mjs +25 -97
  65. package/dist/shared/lib/helpers.js +6 -54
  66. package/dist/shared/lib/helpers.mjs +8 -53
  67. package/package.json +4 -74
  68. package/types/bridge/fields.d.ts +2 -14
  69. package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
  70. package/types/bridge/lib/age-gate.d.ts +0 -5
  71. package/types/bridge/lib/checkout-kit.d.ts +10 -2
  72. package/types/bridge/lib/entry.d.ts +3 -3
  73. package/types/dashboard/card-order.d.ts +0 -6
  74. package/types/dashboard/document-blocks.d.ts +3 -2
  75. package/types/dashboard/form-admin-provider.d.ts +2 -9
  76. package/types/dashboard/form-file-upload.d.ts +1 -2
  77. package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
  78. package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
  79. package/types/dashboard/form-organization-campaign.d.ts +0 -3
  80. package/types/dashboard/form-organization-connection.d.ts +0 -11
  81. package/types/dashboard/form-otc.d.ts +1 -5
  82. package/types/dashboard/form-stripe.d.ts +2 -3
  83. package/types/dashboard/input-file.d.ts +0 -2
  84. package/types/dashboard/order-sections.d.ts +1 -24
  85. package/types/input-checkbox.d.ts +0 -2
  86. package/types/shared/lib/helpers.d.ts +0 -4
  87. package/dist/bridge/cart-drawer.js +0 -152
  88. package/dist/bridge/cart-drawer.mjs +0 -123
  89. package/dist/bridge/form-subdomain-checkout.js +0 -687
  90. package/dist/bridge/form-subdomain-checkout.mjs +0 -665
  91. package/dist/bridge/lib/cart.js +0 -79
  92. package/dist/bridge/lib/cart.mjs +0 -48
  93. package/dist/dashboard/embed-stripe.js +0 -145
  94. package/dist/dashboard/embed-stripe.mjs +0 -116
  95. package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
  96. package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
  97. package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
  98. package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
  99. package/dist/dashboard/form-organization-product.js +0 -1461
  100. package/dist/dashboard/form-organization-product.mjs +0 -1425
  101. package/dist/dashboard/input-gallery.js +0 -201
  102. package/dist/dashboard/input-gallery.mjs +0 -172
  103. package/dist/dashboard/lib/products.js +0 -169
  104. package/dist/dashboard/lib/products.mjs +0 -135
  105. package/dist/dashboard/lib/settings-paths.js +0 -35
  106. package/dist/dashboard/lib/settings-paths.mjs +0 -11
  107. package/dist/dashboard/shipping-rates.js +0 -404
  108. package/dist/dashboard/shipping-rates.mjs +0 -371
  109. package/dist/dashboard/template-buyer.js +0 -301
  110. package/dist/dashboard/template-buyer.mjs +0 -267
  111. package/dist/shared/order-summary.js +0 -139
  112. package/dist/shared/order-summary.mjs +0 -110
  113. package/types/bridge/cart-drawer.d.ts +0 -31
  114. package/types/bridge/form-subdomain-checkout.d.ts +0 -20
  115. package/types/bridge/lib/cart.d.ts +0 -44
  116. package/types/dashboard/embed-stripe.d.ts +0 -25
  117. package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
  118. package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
  119. package/types/dashboard/form-organization-product.d.ts +0 -24
  120. package/types/dashboard/input-gallery.d.ts +0 -14
  121. package/types/dashboard/lib/products.d.ts +0 -14
  122. package/types/dashboard/lib/settings-paths.d.ts +0 -5
  123. package/types/dashboard/shipping-rates.d.ts +0 -26
  124. package/types/dashboard/template-buyer.d.ts +0 -50
  125. 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, import_cart.cartCount)(cart);
119
- const cartRoot = "/subdomain/" + (params == null ? void 0 : params.subdomain) + "/page/" + (params == null ? void 0 : params.slug) + "/cart";
120
- const cartStorageKey = (0, import_cart.cartKey)({ campaign: result == null ? void 0 : result.campaign, subdomain: params == null ? void 0 : params.subdomain });
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 closeDrawer = (0, import_react.useCallback)(() => setDrawer((current) => ({ ...current, open: false })), []);
138
- const paid = (0, import_react.useCallback)(
139
- (id) => {
140
- if (!id || id === (cart == null ? void 0 : cart.id)) {
141
- store(cartStorageKey, null);
142
- setCart(null);
143
- setCut([]);
144
- }
145
- ;
146
- setDrawer({ open: false, pay: null });
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
- setModal(true);
154
- },
155
- [cart == null ? void 0 : cart.id, cartStorageKey, data]
156
- );
157
- const storeCheckout = (0, import_react.useCallback)(
158
- (paying) => (0, import_checkout_kit.checkout)({
159
- checkoutUrl: paying == null ? void 0 : paying.checkoutUrl,
160
- onComplete: () => paid(paying == null ? void 0 : paying.id),
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
- onRedirect: redirectToCheckout
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
- [closeDrawer, paid, redirectToCheckout]
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 kept = stored(cartStorageKey);
238
- if (!(kept == null ? void 0 : kept.id) || !(0, import_cart.cartAlive)(kept.made)) {
239
- if (kept) store(cartStorageKey, null);
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(kept.id),
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
- store(cartStorageKey, null);
195
+ window.localStorage.removeItem(cartStorageKey);
196
+ window.localStorage.removeItem(cartStorageKey + "_expiry");
252
197
  }
253
198
  ;
254
199
  }).catch(() => {
255
- store(cartStorageKey, null);
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 (error) {
307
- if ((error == null ? void 0 : error.status) === 400) throw error;
308
- response = await create();
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 create();
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 (response.result.id !== (cart == null ? void 0 : cart.id)) store(cartStorageKey, { id: response.result.id, made: Date.now() });
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
- setCut([]);
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, openDrawer, who]
264
+ [affiliate, cart, cartRoot, cartStorageKey, data]
325
265
  );
326
- const changeLine = (0, import_react.useCallback)(
327
- async (lineId, quantity, send) => {
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 before = cart;
331
- setCart((0, import_cart.withQuantity)(cart, lineId, quantity));
332
- try {
333
- const response = await send();
334
- if ((_a2 = response == null ? void 0 : response.result) == null ? void 0 : _a2.id) setCart(response.result);
335
- } catch (error) {
336
- setCart(before);
337
- throw error;
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
- (lineId) => changeLine(lineId, 0, () => (0, import_fetch.request)({
361
- body: {
362
- cartId: cart == null ? void 0 : cart.id,
363
- lineIds: [lineId]
364
- },
365
- endpoint: cartRoot + "/lines",
366
- method: "DELETE"
367
- })),
368
- [cart == null ? void 0 : cart.id, cartRoot, changeLine]
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.awardingOn)(data),
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, cart == null ? void 0 : cart.id, cartRoot, data, params, preview, style]
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, onClose) => {
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
- (onClose || (() => setModal(false)))();
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
- openDrawer();
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, openDrawer, preview, style, tracking]
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,