@drawbridge/components 0.1.7 → 0.1.8

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.
@@ -134,6 +134,9 @@ const FormSubdomainProduct = ({
134
134
  {
135
135
  ...{
136
136
  action,
137
+ // @story shop/sample-products
138
+ // A sample opens like a real product, but no store can sell it.
139
+ disabled: Boolean(product == null ? void 0 : product.sample),
137
140
  errors: {
138
141
  root: (_c = (_b = formState == null ? void 0 : formState.errors) == null ? void 0 : _b.root) == null ? void 0 : _c.message,
139
142
  variant: (_e = (_d = formState == null ? void 0 : formState.errors) == null ? void 0 : _d.variant) == null ? void 0 : _e.message
@@ -163,6 +166,7 @@ const FormSubdomainCart = ({
163
166
  button,
164
167
  cart,
165
168
  children,
169
+ drawer = true,
166
170
  onLineRemove,
167
171
  onLineUpdate,
168
172
  onSuccess,
@@ -413,6 +417,10 @@ const FormSubdomainCart = ({
413
417
  ]
414
418
  }
415
419
  );
420
+ if (children && !drawer) {
421
+ return children(setShow);
422
+ }
423
+ ;
416
424
  if (children) {
417
425
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
418
426
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -101,6 +101,9 @@ const FormSubdomainProduct = ({
101
101
  {
102
102
  ...{
103
103
  action,
104
+ // @story shop/sample-products
105
+ // A sample opens like a real product, but no store can sell it.
106
+ disabled: Boolean(product == null ? void 0 : product.sample),
104
107
  errors: {
105
108
  root: (_c = (_b = formState == null ? void 0 : formState.errors) == null ? void 0 : _b.root) == null ? void 0 : _c.message,
106
109
  variant: (_e = (_d = formState == null ? void 0 : formState.errors) == null ? void 0 : _d.variant) == null ? void 0 : _e.message
@@ -130,6 +133,7 @@ const FormSubdomainCart = ({
130
133
  button,
131
134
  cart,
132
135
  children,
136
+ drawer = true,
133
137
  onLineRemove,
134
138
  onLineUpdate,
135
139
  onSuccess,
@@ -380,6 +384,10 @@ const FormSubdomainCart = ({
380
384
  ]
381
385
  }
382
386
  );
387
+ if (children && !drawer) {
388
+ return children(setShow);
389
+ }
390
+ ;
383
391
  if (children) {
384
392
  return /* @__PURE__ */ jsxs(Fragment, { children: [
385
393
  /* @__PURE__ */ jsx(
@@ -74,7 +74,7 @@ const TemplateModal = ({
74
74
  var _a, _b, _c, _d, _e, _f;
75
75
  const renderPanel = (0, import_react.useCallback)(
76
76
  () => {
77
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
77
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
78
78
  const agreements = (data == null ? void 0 : data.agreements) || {};
79
79
  switch (panel == null ? void 0 : panel.name) {
80
80
  case "cart":
@@ -401,6 +401,7 @@ const TemplateModal = ({
401
401
  {
402
402
  ...{
403
403
  cart,
404
+ drawer: !((_t = (_s = panel.data) == null ? void 0 : _s.product) == null ? void 0 : _t.sample),
404
405
  onLineRemove: onCartLineRemove,
405
406
  onLineUpdate: onCartLineUpdate,
406
407
  onSuccess: ({ result }) => {
@@ -457,7 +458,7 @@ const TemplateModal = ({
457
458
  {
458
459
  ...{
459
460
  button: buttons.close("purchase"),
460
- message: (_s = panel == null ? void 0 : panel.data) == null ? void 0 : _s.message,
461
+ message: (_u = panel == null ? void 0 : panel.data) == null ? void 0 : _u.message,
461
462
  style,
462
463
  title: "Purchase complete"
463
464
  }
@@ -520,7 +521,7 @@ const TemplateModal = ({
520
521
  values: {
521
522
  description: data == null ? void 0 : data.description,
522
523
  headline: data == null ? void 0 : data.headline,
523
- image: (_t = data == null ? void 0 : data.images) == null ? void 0 : _t.preview,
524
+ image: (_v = data == null ? void 0 : data.images) == null ? void 0 : _v.preview,
524
525
  url: data == null ? void 0 : data.url
525
526
  }
526
527
  }
@@ -42,7 +42,7 @@ const TemplateModal = ({
42
42
  var _a, _b, _c, _d, _e, _f;
43
43
  const renderPanel = useCallback(
44
44
  () => {
45
- var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
45
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
46
46
  const agreements = (data == null ? void 0 : data.agreements) || {};
47
47
  switch (panel == null ? void 0 : panel.name) {
48
48
  case "cart":
@@ -369,6 +369,7 @@ const TemplateModal = ({
369
369
  {
370
370
  ...{
371
371
  cart,
372
+ drawer: !((_t = (_s = panel.data) == null ? void 0 : _s.product) == null ? void 0 : _t.sample),
372
373
  onLineRemove: onCartLineRemove,
373
374
  onLineUpdate: onCartLineUpdate,
374
375
  onSuccess: ({ result }) => {
@@ -425,7 +426,7 @@ const TemplateModal = ({
425
426
  {
426
427
  ...{
427
428
  button: buttons.close("purchase"),
428
- message: (_s = panel == null ? void 0 : panel.data) == null ? void 0 : _s.message,
429
+ message: (_u = panel == null ? void 0 : panel.data) == null ? void 0 : _u.message,
429
430
  style,
430
431
  title: "Purchase complete"
431
432
  }
@@ -488,7 +489,7 @@ const TemplateModal = ({
488
489
  values: {
489
490
  description: data == null ? void 0 : data.description,
490
491
  headline: data == null ? void 0 : data.headline,
491
- image: (_t = data == null ? void 0 : data.images) == null ? void 0 : _t.preview,
492
+ image: (_v = data == null ? void 0 : data.images) == null ? void 0 : _v.preview,
492
493
  url: data == null ? void 0 : data.url
493
494
  }
494
495
  }
@@ -180,7 +180,7 @@ const TemplateSubdomain = ({
180
180
  className: "flex items-center space-x-2 z-30"
181
181
  },
182
182
  children: [
183
- ((_k = data == null ? void 0 : data.products) == null ? void 0 : _k.length) > 0 && buttons.shop("cart"),
183
+ ((_k = data == null ? void 0 : data.products) == null ? void 0 : _k.some((product) => !(product == null ? void 0 : product.sample))) && buttons.shop("cart"),
184
184
  buttons.menu
185
185
  ]
186
186
  }
@@ -148,7 +148,7 @@ const TemplateSubdomain = ({
148
148
  className: "flex items-center space-x-2 z-30"
149
149
  },
150
150
  children: [
151
- ((_k = data == null ? void 0 : data.products) == null ? void 0 : _k.length) > 0 && buttons.shop("cart"),
151
+ ((_k = data == null ? void 0 : data.products) == null ? void 0 : _k.some((product) => !(product == null ? void 0 : product.sample))) && buttons.shop("cart"),
152
152
  buttons.menu
153
153
  ]
154
154
  }
@@ -40,6 +40,7 @@ var import_fieldset = __toESM(require("../shared/fieldset"));
40
40
  var import_input_group = __toESM(require("../input-group"));
41
41
  var import_input_text = __toESM(require("../input-text"));
42
42
  var import_input_combobox = __toESM(require("./input-combobox"));
43
+ var import_input_switch = __toESM(require("../shared/input-switch"));
43
44
  var import_button = __toESM(require("../shared/button"));
44
45
  const FormAdminOrganization = ({
45
46
  onSuccess,
@@ -52,6 +53,7 @@ const FormAdminOrganization = ({
52
53
  const { control, handleSubmit, formState } = (0, import_form.useForm)({
53
54
  resolver: (0, import_yup.resolver)(
54
55
  import_yup.default.object({
56
+ samples: import_yup.default.boolean().label("Include scrape data"),
55
57
  title: import_yup.default.string().label("Title").required().max(150),
56
58
  status: import_yup.default.string().label("Status").required().oneOf(app.enums.organization.status.enum),
57
59
  version: import_yup.default.number().label("Version").required().oneOf(app.enums.organization.version.enum)
@@ -59,10 +61,12 @@ const FormAdminOrganization = ({
59
61
  ),
60
62
  values: {
61
63
  ...values,
64
+ samples: Boolean(values == null ? void 0 : values.samples),
62
65
  version: (_a = values == null ? void 0 : values.version) == null ? void 0 : _a.current
63
66
  }
64
67
  });
65
68
  const onSubmit = async ({
69
+ samples,
66
70
  status,
67
71
  title,
68
72
  version
@@ -70,6 +74,7 @@ const FormAdminOrganization = ({
70
74
  try {
71
75
  const response = await (0, import_fetch.request)({
72
76
  body: {
77
+ samples,
73
78
  status,
74
79
  title,
75
80
  version
@@ -202,6 +207,33 @@ const FormAdminOrganization = ({
202
207
  }
203
208
  }
204
209
  }
210
+ ),
211
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
212
+ import_form.Controller,
213
+ {
214
+ ...{
215
+ control,
216
+ name: "samples",
217
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
218
+ import_input_group.default,
219
+ {
220
+ ...{
221
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
+ import_input_switch.default,
223
+ {
224
+ ...{
225
+ onChange,
226
+ value: Boolean(value)
227
+ }
228
+ }
229
+ ),
230
+ label: "Include scrape data",
231
+ message: "Every campaign in this organization that was generated from a Shopify store, and has no products of its own, shows up to 6 of that store's products."
232
+ }
233
+ }
234
+ )
235
+ }
236
+ }
205
237
  )
206
238
  ]
207
239
  }
@@ -8,6 +8,7 @@ import Fieldset from "../shared/fieldset.mjs";
8
8
  import InputGroup from "../input-group.mjs";
9
9
  import InputText from "../input-text.mjs";
10
10
  import InputCombobox from "./input-combobox.mjs";
11
+ import InputSwitch from "../shared/input-switch.mjs";
11
12
  import Button from "../shared/button.mjs";
12
13
  const FormAdminOrganization = ({
13
14
  onSuccess,
@@ -20,6 +21,7 @@ const FormAdminOrganization = ({
20
21
  const { control, handleSubmit, formState } = useForm({
21
22
  resolver: resolver(
22
23
  yup.object({
24
+ samples: yup.boolean().label("Include scrape data"),
23
25
  title: yup.string().label("Title").required().max(150),
24
26
  status: yup.string().label("Status").required().oneOf(app.enums.organization.status.enum),
25
27
  version: yup.number().label("Version").required().oneOf(app.enums.organization.version.enum)
@@ -27,10 +29,12 @@ const FormAdminOrganization = ({
27
29
  ),
28
30
  values: {
29
31
  ...values,
32
+ samples: Boolean(values == null ? void 0 : values.samples),
30
33
  version: (_a = values == null ? void 0 : values.version) == null ? void 0 : _a.current
31
34
  }
32
35
  });
33
36
  const onSubmit = async ({
37
+ samples,
34
38
  status,
35
39
  title,
36
40
  version
@@ -38,6 +42,7 @@ const FormAdminOrganization = ({
38
42
  try {
39
43
  const response = await request({
40
44
  body: {
45
+ samples,
41
46
  status,
42
47
  title,
43
48
  version
@@ -170,6 +175,33 @@ const FormAdminOrganization = ({
170
175
  }
171
176
  }
172
177
  }
178
+ ),
179
+ /* @__PURE__ */ jsx(
180
+ Controller,
181
+ {
182
+ ...{
183
+ control,
184
+ name: "samples",
185
+ render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
186
+ InputGroup,
187
+ {
188
+ ...{
189
+ input: /* @__PURE__ */ jsx(
190
+ InputSwitch,
191
+ {
192
+ ...{
193
+ onChange,
194
+ value: Boolean(value)
195
+ }
196
+ }
197
+ ),
198
+ label: "Include scrape data",
199
+ message: "Every campaign in this organization that was generated from a Shopify store, and has no products of its own, shows up to 6 of that store's products."
200
+ }
201
+ }
202
+ )
203
+ }
204
+ }
173
205
  )
174
206
  ]
175
207
  }