@drawbridge/components 0.1.47 → 0.1.48
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/cart-drawer.js +152 -0
- package/dist/bridge/cart-drawer.mjs +123 -0
- package/dist/bridge/fields.js +278 -0
- package/dist/bridge/fields.mjs +276 -1
- package/dist/bridge/form-subdomain-checkout.js +687 -0
- package/dist/bridge/form-subdomain-checkout.mjs +665 -0
- package/dist/bridge/form-subdomain-shop-modal.js +234 -274
- package/dist/bridge/form-subdomain-shop-modal.mjs +233 -275
- package/dist/bridge/form-subdomain.js +1 -0
- package/dist/bridge/form-subdomain.mjs +2 -1
- package/dist/bridge/lib/age-gate.js +12 -0
- package/dist/bridge/lib/age-gate.mjs +11 -0
- package/dist/bridge/lib/cart.js +79 -0
- package/dist/bridge/lib/cart.mjs +48 -0
- package/dist/bridge/lib/checkout-kit.js +2 -32
- package/dist/bridge/lib/checkout-kit.mjs +2 -32
- package/dist/bridge/product-tile.js +9 -6
- package/dist/bridge/product-tile.mjs +9 -6
- package/dist/bridge/template-layout.js +237 -122
- package/dist/bridge/template-layout.mjs +237 -122
- package/dist/bridge/template-modal.js +28 -73
- package/dist/bridge/template-modal.mjs +29 -74
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +7 -2
- package/dist/dashboard/campaign-form.mjs +7 -2
- package/dist/dashboard/card-order.js +22 -4
- package/dist/dashboard/card-order.mjs +22 -4
- package/dist/dashboard/embed-stripe.js +145 -0
- package/dist/dashboard/embed-stripe.mjs +116 -0
- package/dist/dashboard/form-admin-provider.js +71 -17
- package/dist/dashboard/form-admin-provider.mjs +71 -17
- package/dist/dashboard/form-file-upload.js +3 -2
- package/dist/dashboard/form-file-upload.mjs +4 -3
- package/dist/dashboard/form-organization-campaign-advertisements.js +47 -6
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +47 -6
- package/dist/dashboard/form-organization-campaign-field-birthday.js +193 -0
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +164 -0
- package/dist/dashboard/form-organization-campaign-field-rating.js +246 -0
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +217 -0
- package/dist/dashboard/form-organization-campaign.js +82 -0
- package/dist/dashboard/form-organization-campaign.mjs +81 -0
- package/dist/dashboard/form-organization-connection.js +48 -6
- package/dist/dashboard/form-organization-connection.mjs +48 -7
- package/dist/dashboard/form-organization-product.js +1461 -0
- package/dist/dashboard/form-organization-product.mjs +1425 -0
- package/dist/dashboard/form-organization-workflow.js +72 -1
- package/dist/dashboard/form-organization-workflow.mjs +69 -1
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-stripe.js +12 -5
- package/dist/dashboard/form-stripe.mjs +12 -5
- package/dist/dashboard/input-fields.js +11 -158
- package/dist/dashboard/input-fields.mjs +11 -158
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/lib/connection-controls.js +5 -2
- package/dist/dashboard/lib/connection-controls.mjs +3 -1
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/products.js +169 -0
- package/dist/dashboard/lib/products.mjs +135 -0
- package/dist/dashboard/lib/settings-paths.js +35 -0
- package/dist/dashboard/lib/settings-paths.mjs +11 -0
- package/dist/dashboard/lib/uppy.js +10 -1
- package/dist/dashboard/lib/uppy.mjs +11 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/shipping-rates.js +404 -0
- package/dist/dashboard/shipping-rates.mjs +371 -0
- package/dist/dashboard/template-buyer.js +301 -0
- package/dist/dashboard/template-buyer.mjs +267 -0
- package/dist/input-checkbox.js +28 -10
- package/dist/input-checkbox.mjs +28 -10
- package/dist/product.js +96 -24
- package/dist/product.mjs +97 -25
- package/dist/shared/lib/helpers.js +54 -6
- package/dist/shared/lib/helpers.mjs +53 -8
- package/dist/shared/order-summary.js +139 -0
- package/dist/shared/order-summary.mjs +110 -0
- package/package.json +74 -4
- package/types/bridge/cart-drawer.d.ts +31 -0
- package/types/bridge/fields.d.ts +14 -2
- package/types/bridge/form-subdomain-checkout.d.ts +20 -0
- package/types/bridge/form-subdomain-shop-modal.d.ts +27 -3
- package/types/bridge/lib/age-gate.d.ts +5 -0
- package/types/bridge/lib/cart.d.ts +44 -0
- package/types/bridge/lib/checkout-kit.d.ts +2 -10
- package/types/dashboard/card-order.d.ts +6 -0
- package/types/dashboard/embed-stripe.d.ts +25 -0
- package/types/dashboard/form-admin-provider.d.ts +9 -2
- package/types/dashboard/form-file-upload.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +3 -0
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +31 -0
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +33 -0
- package/types/dashboard/form-organization-campaign.d.ts +3 -0
- package/types/dashboard/form-organization-connection.d.ts +11 -0
- package/types/dashboard/form-organization-product.d.ts +24 -0
- package/types/dashboard/form-otc.d.ts +5 -1
- package/types/dashboard/form-stripe.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +2 -0
- package/types/dashboard/input-gallery.d.ts +14 -0
- package/types/dashboard/lib/products.d.ts +14 -0
- package/types/dashboard/lib/settings-paths.d.ts +5 -0
- package/types/dashboard/order-sections.d.ts +24 -1
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/input-checkbox.d.ts +2 -0
- package/types/shared/lib/helpers.d.ts +4 -0
- package/types/shared/order-summary.d.ts +19 -0
|
@@ -33,6 +33,7 @@ __export(form_admin_provider_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(form_admin_provider_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_react = require("react");
|
|
36
|
+
var import_react_query = require("@tanstack/react-query");
|
|
36
37
|
var import_form = require("../shared/lib/form");
|
|
37
38
|
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
38
39
|
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
@@ -44,11 +45,18 @@ var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
|
44
45
|
var import_card_task = __toESM(require("./card-task"));
|
|
45
46
|
var import_input_secret = __toESM(require("./input-secret"));
|
|
46
47
|
var import_button = __toESM(require("../shared/button"));
|
|
47
|
-
|
|
48
|
+
var import_form_organization_connection = require("./form-organization-connection");
|
|
49
|
+
var import_settings_paths = require("./lib/settings-paths");
|
|
50
|
+
const schemaFor = (field, enabled) => {
|
|
48
51
|
if (field.input === "switch") return import_yup.default.boolean().label(field.label);
|
|
49
52
|
const rule = field.input === "email" ? import_yup.default.string().label(field.label).email() : import_yup.default.string().label(field.label);
|
|
50
|
-
return field.required && !field.redact
|
|
53
|
+
return enabled && field.required && !field.redact && !field.hook ? rule.required() : rule.nullable();
|
|
51
54
|
};
|
|
55
|
+
const shape = (tree) => import_yup.default.object(
|
|
56
|
+
Object.fromEntries(
|
|
57
|
+
Object.entries(tree).map(([key, node]) => [key, import_yup.default.isSchema(node) ? node : shape(node)])
|
|
58
|
+
)
|
|
59
|
+
);
|
|
52
60
|
const FormAdminProvider = ({
|
|
53
61
|
onError,
|
|
54
62
|
onSuccess,
|
|
@@ -61,25 +69,37 @@ const FormAdminProvider = ({
|
|
|
61
69
|
// A row that has never been touched has no answer stored and is on, so
|
|
62
70
|
// the box starts checked rather than empty.
|
|
63
71
|
enabled: (values == null ? void 0 : values.enabled) !== false,
|
|
64
|
-
...
|
|
65
|
-
fields.map((field) =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
field.input === "switch" ? ((_a = values == null ? void 0 : values.settings) == null ? void 0 : _a[field.key]) === true : field.redact ? "" : ((_b = values == null ? void 0 : values.settings) == null ? void 0 : _b[field.key]) ?? ""
|
|
70
|
-
];
|
|
71
|
-
})
|
|
72
|
+
...(0, import_settings_paths.nestPaths)(
|
|
73
|
+
fields.map((field) => [
|
|
74
|
+
field.key,
|
|
75
|
+
field.input === "switch" ? (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key) === true : field.redact ? "" : (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key) ?? ""
|
|
76
|
+
])
|
|
72
77
|
)
|
|
73
78
|
}),
|
|
74
79
|
[fields, values]
|
|
75
80
|
);
|
|
76
81
|
const schema = (0, import_react.useMemo)(
|
|
77
|
-
() => import_yup.default.
|
|
82
|
+
() => import_yup.default.lazy((data) => shape({
|
|
78
83
|
enabled: import_yup.default.boolean().label("Enabled"),
|
|
79
|
-
...
|
|
80
|
-
}),
|
|
84
|
+
...(0, import_settings_paths.nestPaths)(fields.map((field) => [field.key, schemaFor(field, (data == null ? void 0 : data.enabled) !== false)]))
|
|
85
|
+
})),
|
|
81
86
|
[fields]
|
|
82
87
|
);
|
|
88
|
+
const hooked = (0, import_react.useMemo)(() => fields.filter((field) => field.hook), [fields]);
|
|
89
|
+
const sourced = (0, import_react_query.useQueries)({
|
|
90
|
+
queries: hooked.map((field) => ({
|
|
91
|
+
enabled: Boolean(values == null ? void 0 : values.slug),
|
|
92
|
+
queryFn: async () => {
|
|
93
|
+
const { result } = await (0, import_fetch.request)({
|
|
94
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
95
|
+
params: { limit: 100 }
|
|
96
|
+
});
|
|
97
|
+
return ((result == null ? void 0 : result.items) || []).map((item) => ({ label: item.title, value: item.id }));
|
|
98
|
+
},
|
|
99
|
+
queryKey: ["admin-provider-hook", values == null ? void 0 : values.slug, field.hook, values == null ? void 0 : values.settings]
|
|
100
|
+
}))
|
|
101
|
+
});
|
|
102
|
+
const optionsFor = Object.fromEntries(hooked.map((field, index) => [field.key, sourced[index]]));
|
|
83
103
|
const [clearing, setClearing] = (0, import_react.useState)([]);
|
|
84
104
|
(0, import_react.useEffect)(() => setClearing([]), [values == null ? void 0 : values.slug]);
|
|
85
105
|
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
@@ -104,10 +124,20 @@ const FormAdminProvider = ({
|
|
|
104
124
|
// admin then TYPED INTO is a replacement, not a removal. The api
|
|
105
125
|
// applies `clear` after `settings`, so naming a key that also
|
|
106
126
|
// carries a value deleted the value just typed and answered "Saved".
|
|
107
|
-
|
|
127
|
+
//
|
|
128
|
+
// `clear` stays a list of dotted keys; `settings` goes nested,
|
|
129
|
+
// the shape the api stores.
|
|
130
|
+
//
|
|
131
|
+
// A PICKER EMPTIED IS A REMOVAL TOO. Its trash empties the value,
|
|
132
|
+
// and blank would keep the saved one, so a picker that held a
|
|
133
|
+
// saved value and is empty now is named here as well.
|
|
134
|
+
clear: [
|
|
135
|
+
...clearing.filter((key) => !(0, import_settings_paths.readPath)(data, key)),
|
|
136
|
+
...fields.filter((field) => field.hook && !(0, import_settings_paths.readPath)(data, field.key) && (0, import_settings_paths.readPath)(values == null ? void 0 : values.settings, field.key)).map((field) => field.key)
|
|
137
|
+
],
|
|
108
138
|
enabled: Boolean(data == null ? void 0 : data.enabled),
|
|
109
|
-
settings:
|
|
110
|
-
fields.map((field) => [field.key, (
|
|
139
|
+
settings: (0, import_settings_paths.nestPaths)(
|
|
140
|
+
fields.map((field) => [field.key, (0, import_settings_paths.readPath)(data, field.key) ?? ""])
|
|
111
141
|
)
|
|
112
142
|
},
|
|
113
143
|
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug),
|
|
@@ -233,11 +263,35 @@ const FormAdminProvider = ({
|
|
|
233
263
|
value
|
|
234
264
|
}
|
|
235
265
|
}
|
|
266
|
+
) : field.input === "select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
267
|
+
import_input_group.default,
|
|
268
|
+
{
|
|
269
|
+
...{
|
|
270
|
+
error: (_a = (0, import_settings_paths.readPath)(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _a.message,
|
|
271
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
272
|
+
import_form_organization_connection.Editable,
|
|
273
|
+
{
|
|
274
|
+
...{
|
|
275
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
276
|
+
field,
|
|
277
|
+
onChange,
|
|
278
|
+
titleFor: (id) => {
|
|
279
|
+
var _a2, _b2, _c;
|
|
280
|
+
return ((_c = (_b2 = (_a2 = optionsFor[field.key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.find((option) => option.value === id)) == null ? void 0 : _c.label) || id;
|
|
281
|
+
},
|
|
282
|
+
value
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
),
|
|
286
|
+
label: field.label,
|
|
287
|
+
message: field.message
|
|
288
|
+
}
|
|
289
|
+
}
|
|
236
290
|
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
291
|
import_input_group.default,
|
|
238
292
|
{
|
|
239
293
|
...{
|
|
240
|
-
error: (_b = (
|
|
294
|
+
error: (_b = (0, import_settings_paths.readPath)(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _b.message,
|
|
241
295
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
242
296
|
import_input_text.default,
|
|
243
297
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useMemo, useState } from "react";
|
|
4
|
+
import { useQueries } from "@tanstack/react-query";
|
|
4
5
|
import { Controller, useForm } from "../shared/lib/form.mjs";
|
|
5
6
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
6
7
|
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
@@ -12,11 +13,18 @@ import InputSwitch from "../shared/input-switch.mjs";
|
|
|
12
13
|
import CardTask from "./card-task.mjs";
|
|
13
14
|
import InputSecret from "./input-secret.mjs";
|
|
14
15
|
import Button from "../shared/button.mjs";
|
|
15
|
-
|
|
16
|
+
import { Editable } from "./form-organization-connection.mjs";
|
|
17
|
+
import { nestPaths, readPath } from "./lib/settings-paths.mjs";
|
|
18
|
+
const schemaFor = (field, enabled) => {
|
|
16
19
|
if (field.input === "switch") return yup.boolean().label(field.label);
|
|
17
20
|
const rule = field.input === "email" ? yup.string().label(field.label).email() : yup.string().label(field.label);
|
|
18
|
-
return field.required && !field.redact
|
|
21
|
+
return enabled && field.required && !field.redact && !field.hook ? rule.required() : rule.nullable();
|
|
19
22
|
};
|
|
23
|
+
const shape = (tree) => yup.object(
|
|
24
|
+
Object.fromEntries(
|
|
25
|
+
Object.entries(tree).map(([key, node]) => [key, yup.isSchema(node) ? node : shape(node)])
|
|
26
|
+
)
|
|
27
|
+
);
|
|
20
28
|
const FormAdminProvider = ({
|
|
21
29
|
onError,
|
|
22
30
|
onSuccess,
|
|
@@ -29,25 +37,37 @@ const FormAdminProvider = ({
|
|
|
29
37
|
// A row that has never been touched has no answer stored and is on, so
|
|
30
38
|
// the box starts checked rather than empty.
|
|
31
39
|
enabled: (values == null ? void 0 : values.enabled) !== false,
|
|
32
|
-
...
|
|
33
|
-
fields.map((field) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
field.input === "switch" ? ((_a = values == null ? void 0 : values.settings) == null ? void 0 : _a[field.key]) === true : field.redact ? "" : ((_b = values == null ? void 0 : values.settings) == null ? void 0 : _b[field.key]) ?? ""
|
|
38
|
-
];
|
|
39
|
-
})
|
|
40
|
+
...nestPaths(
|
|
41
|
+
fields.map((field) => [
|
|
42
|
+
field.key,
|
|
43
|
+
field.input === "switch" ? readPath(values == null ? void 0 : values.settings, field.key) === true : field.redact ? "" : readPath(values == null ? void 0 : values.settings, field.key) ?? ""
|
|
44
|
+
])
|
|
40
45
|
)
|
|
41
46
|
}),
|
|
42
47
|
[fields, values]
|
|
43
48
|
);
|
|
44
49
|
const schema = useMemo(
|
|
45
|
-
() => yup.
|
|
50
|
+
() => yup.lazy((data) => shape({
|
|
46
51
|
enabled: yup.boolean().label("Enabled"),
|
|
47
|
-
...
|
|
48
|
-
}),
|
|
52
|
+
...nestPaths(fields.map((field) => [field.key, schemaFor(field, (data == null ? void 0 : data.enabled) !== false)]))
|
|
53
|
+
})),
|
|
49
54
|
[fields]
|
|
50
55
|
);
|
|
56
|
+
const hooked = useMemo(() => fields.filter((field) => field.hook), [fields]);
|
|
57
|
+
const sourced = useQueries({
|
|
58
|
+
queries: hooked.map((field) => ({
|
|
59
|
+
enabled: Boolean(values == null ? void 0 : values.slug),
|
|
60
|
+
queryFn: async () => {
|
|
61
|
+
const { result } = await request({
|
|
62
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
63
|
+
params: { limit: 100 }
|
|
64
|
+
});
|
|
65
|
+
return ((result == null ? void 0 : result.items) || []).map((item) => ({ label: item.title, value: item.id }));
|
|
66
|
+
},
|
|
67
|
+
queryKey: ["admin-provider-hook", values == null ? void 0 : values.slug, field.hook, values == null ? void 0 : values.settings]
|
|
68
|
+
}))
|
|
69
|
+
});
|
|
70
|
+
const optionsFor = Object.fromEntries(hooked.map((field, index) => [field.key, sourced[index]]));
|
|
51
71
|
const [clearing, setClearing] = useState([]);
|
|
52
72
|
useEffect(() => setClearing([]), [values == null ? void 0 : values.slug]);
|
|
53
73
|
const { control, formState, handleSubmit } = useForm({
|
|
@@ -72,10 +92,20 @@ const FormAdminProvider = ({
|
|
|
72
92
|
// admin then TYPED INTO is a replacement, not a removal. The api
|
|
73
93
|
// applies `clear` after `settings`, so naming a key that also
|
|
74
94
|
// carries a value deleted the value just typed and answered "Saved".
|
|
75
|
-
|
|
95
|
+
//
|
|
96
|
+
// `clear` stays a list of dotted keys; `settings` goes nested,
|
|
97
|
+
// the shape the api stores.
|
|
98
|
+
//
|
|
99
|
+
// A PICKER EMPTIED IS A REMOVAL TOO. Its trash empties the value,
|
|
100
|
+
// and blank would keep the saved one, so a picker that held a
|
|
101
|
+
// saved value and is empty now is named here as well.
|
|
102
|
+
clear: [
|
|
103
|
+
...clearing.filter((key) => !readPath(data, key)),
|
|
104
|
+
...fields.filter((field) => field.hook && !readPath(data, field.key) && readPath(values == null ? void 0 : values.settings, field.key)).map((field) => field.key)
|
|
105
|
+
],
|
|
76
106
|
enabled: Boolean(data == null ? void 0 : data.enabled),
|
|
77
|
-
settings:
|
|
78
|
-
fields.map((field) => [field.key, (data
|
|
107
|
+
settings: nestPaths(
|
|
108
|
+
fields.map((field) => [field.key, readPath(data, field.key) ?? ""])
|
|
79
109
|
)
|
|
80
110
|
},
|
|
81
111
|
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug),
|
|
@@ -201,11 +231,35 @@ const FormAdminProvider = ({
|
|
|
201
231
|
value
|
|
202
232
|
}
|
|
203
233
|
}
|
|
234
|
+
) : field.input === "select" ? /* @__PURE__ */ jsx(
|
|
235
|
+
InputGroup,
|
|
236
|
+
{
|
|
237
|
+
...{
|
|
238
|
+
error: (_a = readPath(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _a.message,
|
|
239
|
+
input: /* @__PURE__ */ jsx(
|
|
240
|
+
Editable,
|
|
241
|
+
{
|
|
242
|
+
...{
|
|
243
|
+
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug) + "/hook/" + field.hook,
|
|
244
|
+
field,
|
|
245
|
+
onChange,
|
|
246
|
+
titleFor: (id) => {
|
|
247
|
+
var _a2, _b2, _c;
|
|
248
|
+
return ((_c = (_b2 = (_a2 = optionsFor[field.key]) == null ? void 0 : _a2.data) == null ? void 0 : _b2.find((option) => option.value === id)) == null ? void 0 : _c.label) || id;
|
|
249
|
+
},
|
|
250
|
+
value
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
label: field.label,
|
|
255
|
+
message: field.message
|
|
256
|
+
}
|
|
257
|
+
}
|
|
204
258
|
) : /* @__PURE__ */ jsx(
|
|
205
259
|
InputGroup,
|
|
206
260
|
{
|
|
207
261
|
...{
|
|
208
|
-
error: (_b = (
|
|
262
|
+
error: (_b = readPath(formState == null ? void 0 : formState.errors, field.key)) == null ? void 0 : _b.message,
|
|
209
263
|
input: /* @__PURE__ */ jsx(
|
|
210
264
|
InputText,
|
|
211
265
|
{
|
|
@@ -62,7 +62,8 @@ const FormFileUpload = ({
|
|
|
62
62
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
63
63
|
const queryClient = (0, import_react_query.useQueryClient)();
|
|
64
64
|
const app = queryClient.getQueryData(["app"]);
|
|
65
|
-
const
|
|
65
|
+
const digital = type === "digital";
|
|
66
|
+
const sizeLimits = digital ? import_helpers.digitalSizeLimits : maximumUploadBytes ? { ...import_helpers.fileSizeLimits, video: maximumUploadBytes / import_drawbridge_utils.megabyte } : import_helpers.fileSizeLimits;
|
|
66
67
|
const uploaderRef = (0, import_react.useRef)(null);
|
|
67
68
|
const successRef = (0, import_react.useRef)(onSuccess);
|
|
68
69
|
const realRef = (0, import_react.useRef)(0);
|
|
@@ -262,7 +263,7 @@ const FormFileUpload = ({
|
|
|
262
263
|
type: type2
|
|
263
264
|
}
|
|
264
265
|
}) => {
|
|
265
|
-
if ((data == null ? void 0 : data.size) >= multipartBytes) {
|
|
266
|
+
if (digital || (data == null ? void 0 : data.size) >= multipartBytes) {
|
|
266
267
|
return await onMultipart({
|
|
267
268
|
data
|
|
268
269
|
});
|
|
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { bytesToGB, bytesToMB, formatNumber, gigabyte, megabyte } from "@drawbridge/drawbridge-utils";
|
|
4
4
|
import { upload } from "@drawbridge/drawbridge-utils/fetch";
|
|
5
5
|
import { useForm, Controller } from "../shared/lib/form.mjs";
|
|
6
|
-
import { fileParts, fileSizeLimits, fileSizes, fileTypes } from "../shared/lib/helpers.mjs";
|
|
6
|
+
import { digitalSizeLimits, fileParts, fileSizeLimits, fileSizes, fileTypes } from "../shared/lib/helpers.mjs";
|
|
7
7
|
import { getUploader, releaseUploader } from "./lib/uppy.mjs";
|
|
8
8
|
import { trickle } from "./lib/trickle.mjs";
|
|
9
9
|
import { useQueryClient } from "@tanstack/react-query";
|
|
@@ -30,7 +30,8 @@ const FormFileUpload = ({
|
|
|
30
30
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
31
31
|
const queryClient = useQueryClient();
|
|
32
32
|
const app = queryClient.getQueryData(["app"]);
|
|
33
|
-
const
|
|
33
|
+
const digital = type === "digital";
|
|
34
|
+
const sizeLimits = digital ? digitalSizeLimits : maximumUploadBytes ? { ...fileSizeLimits, video: maximumUploadBytes / megabyte } : fileSizeLimits;
|
|
34
35
|
const uploaderRef = useRef(null);
|
|
35
36
|
const successRef = useRef(onSuccess);
|
|
36
37
|
const realRef = useRef(0);
|
|
@@ -230,7 +231,7 @@ const FormFileUpload = ({
|
|
|
230
231
|
type: type2
|
|
231
232
|
}
|
|
232
233
|
}) => {
|
|
233
|
-
if ((data == null ? void 0 : data.size) >= multipartBytes) {
|
|
234
|
+
if (digital || (data == null ? void 0 : data.size) >= multipartBytes) {
|
|
234
235
|
return await onMultipart({
|
|
235
236
|
data
|
|
236
237
|
});
|
|
@@ -35,6 +35,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_react_query = require("@tanstack/react-query");
|
|
37
37
|
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
38
|
+
var import_products = require("@drawbridge/drawbridge-utils/products");
|
|
38
39
|
var import_helpers = require("../shared/lib/helpers");
|
|
39
40
|
var import_form_page = require("./lib/form-page");
|
|
40
41
|
var import_form_organization_campaign_advertisement = __toESM(require("./form-organization-campaign-advertisement"));
|
|
@@ -52,6 +53,7 @@ var import_arrow_left = __toESM(require("../icons/arrow-left"));
|
|
|
52
53
|
var import_loader = __toESM(require("../icons/loader"));
|
|
53
54
|
var import_plus_small = __toESM(require("../icons/plus-small"));
|
|
54
55
|
const FormOrganizationCampaignAdvertisements = ({
|
|
56
|
+
checkout,
|
|
55
57
|
commerce,
|
|
56
58
|
disabled,
|
|
57
59
|
onError,
|
|
@@ -75,6 +77,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
75
77
|
}),
|
|
76
78
|
queryKey: (0, import_form_page.advertisementsKey)(params)
|
|
77
79
|
});
|
|
80
|
+
const made = import_products.PRODUCT_PROVIDER[checkout] === "drawbridge";
|
|
78
81
|
const ads = (Array.isArray(data == null ? void 0 : data.result) ? data.result : (_a = data == null ? void 0 : data.result) == null ? void 0 : _a.items) || [];
|
|
79
82
|
const full = ads.length >= import_form_page.MAX_ADS;
|
|
80
83
|
const back = () => setView("list");
|
|
@@ -188,7 +191,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
188
191
|
...{
|
|
189
192
|
list: [
|
|
190
193
|
{ title: "Details" },
|
|
191
|
-
{ title: (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
194
|
+
{ title: made ? "Products" : (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
192
195
|
],
|
|
193
196
|
panels: [
|
|
194
197
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -214,9 +217,12 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
214
217
|
import_list_resource.default,
|
|
215
218
|
{
|
|
216
219
|
...{
|
|
217
|
-
endpoint: "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
220
|
+
endpoint: made ? "/organization/" + (params == null ? void 0 : params.organization) + "/products" : "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
218
221
|
model: "product",
|
|
219
222
|
params: {
|
|
223
|
+
...made && {
|
|
224
|
+
provider: import_products.PRODUCT_PROVIDER[checkout]
|
|
225
|
+
},
|
|
220
226
|
sort: {
|
|
221
227
|
createdAt: -1
|
|
222
228
|
}
|
|
@@ -236,20 +242,21 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
236
242
|
}
|
|
237
243
|
},
|
|
238
244
|
render: (product) => {
|
|
239
|
-
var _a2;
|
|
245
|
+
var _a2, _b, _c;
|
|
240
246
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
241
247
|
import_card_product.default,
|
|
242
248
|
{
|
|
243
249
|
...{
|
|
244
|
-
image: ((_a2 = product.featuredImage) == null ? void 0 :
|
|
245
|
-
title: product.title
|
|
250
|
+
image: made ? ((_b = (_a2 = (0, import_helpers.productAsset)(product)) == null ? void 0 : _a2.sizes) == null ? void 0 : _b["100x100"]) || null : ((_c = product.featuredImage) == null ? void 0 : _c.url) || null,
|
|
251
|
+
title: product.title,
|
|
252
|
+
updatedAt: product.updatedAt
|
|
246
253
|
}
|
|
247
254
|
}
|
|
248
255
|
);
|
|
249
256
|
},
|
|
250
257
|
renderButton: ({ button, item }) => {
|
|
251
258
|
var _a2, _b;
|
|
252
|
-
return ((_b = (_a2 = item.variants) == null ? void 0 : _a2.edges) == null ? void 0 : _b.some((edge) => edge.node.availableForSale)) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
259
|
+
return (made ? (item.variants || []).some(import_products.available) : (_b = (_a2 = item.variants) == null ? void 0 : _a2.edges) == null ? void 0 : _b.some((edge) => edge.node.availableForSale)) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
253
260
|
import_button.default,
|
|
254
261
|
{
|
|
255
262
|
...button.props,
|
|
@@ -318,6 +325,40 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
318
325
|
onSort: reorder,
|
|
319
326
|
renderItem: (ad, _index, handle) => {
|
|
320
327
|
const badge = (0, import_helpers.statusBadge)("advertisement", ad.status);
|
|
328
|
+
if (ad.locked) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
329
|
+
import_card_shortcut.default,
|
|
330
|
+
{
|
|
331
|
+
...{
|
|
332
|
+
badge: badge && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
333
|
+
import_badge.default,
|
|
334
|
+
{
|
|
335
|
+
...{
|
|
336
|
+
size: "small",
|
|
337
|
+
type: badge.type
|
|
338
|
+
},
|
|
339
|
+
children: badge.text
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
controls: !disabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
343
|
+
import_button.default,
|
|
344
|
+
{
|
|
345
|
+
...{
|
|
346
|
+
onClick: () => setView({
|
|
347
|
+
remove: ad.id
|
|
348
|
+
}),
|
|
349
|
+
size: "small",
|
|
350
|
+
variant: "error"
|
|
351
|
+
},
|
|
352
|
+
children: "Delete"
|
|
353
|
+
}
|
|
354
|
+
),
|
|
355
|
+
description: "Product no longer sold here",
|
|
356
|
+
handle,
|
|
357
|
+
image: ad.file || (0, import_helpers.productAsset)(ad.product),
|
|
358
|
+
title: ad.title || "Untitled advertisement"
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
321
362
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
322
363
|
import_card_shortcut.default,
|
|
323
364
|
{
|
|
@@ -3,6 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
5
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
6
|
+
import { available, PRODUCT_PROVIDER } from "@drawbridge/drawbridge-utils/products";
|
|
6
7
|
import { productAsset, statusBadge } from "../shared/lib/helpers.mjs";
|
|
7
8
|
import { adsLimit, advertisementsKey, MAX_ADS } from "./lib/form-page.mjs";
|
|
8
9
|
import FormOrganizationCampaignAdvertisement from "./form-organization-campaign-advertisement.mjs";
|
|
@@ -20,6 +21,7 @@ import ArrowLeft from "../icons/arrow-left.mjs";
|
|
|
20
21
|
import Loader from "../icons/loader.mjs";
|
|
21
22
|
import PlusSmall from "../icons/plus-small.mjs";
|
|
22
23
|
const FormOrganizationCampaignAdvertisements = ({
|
|
24
|
+
checkout,
|
|
23
25
|
commerce,
|
|
24
26
|
disabled,
|
|
25
27
|
onError,
|
|
@@ -43,6 +45,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
43
45
|
}),
|
|
44
46
|
queryKey: advertisementsKey(params)
|
|
45
47
|
});
|
|
48
|
+
const made = PRODUCT_PROVIDER[checkout] === "drawbridge";
|
|
46
49
|
const ads = (Array.isArray(data == null ? void 0 : data.result) ? data.result : (_a = data == null ? void 0 : data.result) == null ? void 0 : _a.items) || [];
|
|
47
50
|
const full = ads.length >= MAX_ADS;
|
|
48
51
|
const back = () => setView("list");
|
|
@@ -156,7 +159,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
156
159
|
...{
|
|
157
160
|
list: [
|
|
158
161
|
{ title: "Details" },
|
|
159
|
-
{ title: (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
162
|
+
{ title: made ? "Products" : (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
160
163
|
],
|
|
161
164
|
panels: [
|
|
162
165
|
/* @__PURE__ */ jsx(
|
|
@@ -182,9 +185,12 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
182
185
|
ListResource,
|
|
183
186
|
{
|
|
184
187
|
...{
|
|
185
|
-
endpoint: "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
188
|
+
endpoint: made ? "/organization/" + (params == null ? void 0 : params.organization) + "/products" : "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
186
189
|
model: "product",
|
|
187
190
|
params: {
|
|
191
|
+
...made && {
|
|
192
|
+
provider: PRODUCT_PROVIDER[checkout]
|
|
193
|
+
},
|
|
188
194
|
sort: {
|
|
189
195
|
createdAt: -1
|
|
190
196
|
}
|
|
@@ -204,20 +210,21 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
204
210
|
}
|
|
205
211
|
},
|
|
206
212
|
render: (product) => {
|
|
207
|
-
var _a2;
|
|
213
|
+
var _a2, _b, _c;
|
|
208
214
|
return /* @__PURE__ */ jsx(
|
|
209
215
|
CardProduct,
|
|
210
216
|
{
|
|
211
217
|
...{
|
|
212
|
-
image: ((_a2 = product.featuredImage) == null ? void 0 :
|
|
213
|
-
title: product.title
|
|
218
|
+
image: made ? ((_b = (_a2 = productAsset(product)) == null ? void 0 : _a2.sizes) == null ? void 0 : _b["100x100"]) || null : ((_c = product.featuredImage) == null ? void 0 : _c.url) || null,
|
|
219
|
+
title: product.title,
|
|
220
|
+
updatedAt: product.updatedAt
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
);
|
|
217
224
|
},
|
|
218
225
|
renderButton: ({ button, item }) => {
|
|
219
226
|
var _a2, _b;
|
|
220
|
-
return ((_b = (_a2 = item.variants) == null ? void 0 : _a2.edges) == null ? void 0 : _b.some((edge) => edge.node.availableForSale)) ? /* @__PURE__ */ jsx(
|
|
227
|
+
return (made ? (item.variants || []).some(available) : (_b = (_a2 = item.variants) == null ? void 0 : _a2.edges) == null ? void 0 : _b.some((edge) => edge.node.availableForSale)) ? /* @__PURE__ */ jsx(
|
|
221
228
|
Button,
|
|
222
229
|
{
|
|
223
230
|
...button.props,
|
|
@@ -286,6 +293,40 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
286
293
|
onSort: reorder,
|
|
287
294
|
renderItem: (ad, _index, handle) => {
|
|
288
295
|
const badge = statusBadge("advertisement", ad.status);
|
|
296
|
+
if (ad.locked) return /* @__PURE__ */ jsx(
|
|
297
|
+
CardShortcut,
|
|
298
|
+
{
|
|
299
|
+
...{
|
|
300
|
+
badge: badge && /* @__PURE__ */ jsx(
|
|
301
|
+
Badge,
|
|
302
|
+
{
|
|
303
|
+
...{
|
|
304
|
+
size: "small",
|
|
305
|
+
type: badge.type
|
|
306
|
+
},
|
|
307
|
+
children: badge.text
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
controls: !disabled && /* @__PURE__ */ jsx(
|
|
311
|
+
Button,
|
|
312
|
+
{
|
|
313
|
+
...{
|
|
314
|
+
onClick: () => setView({
|
|
315
|
+
remove: ad.id
|
|
316
|
+
}),
|
|
317
|
+
size: "small",
|
|
318
|
+
variant: "error"
|
|
319
|
+
},
|
|
320
|
+
children: "Delete"
|
|
321
|
+
}
|
|
322
|
+
),
|
|
323
|
+
description: "Product no longer sold here",
|
|
324
|
+
handle,
|
|
325
|
+
image: ad.file || productAsset(ad.product),
|
|
326
|
+
title: ad.title || "Untitled advertisement"
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
);
|
|
289
330
|
return /* @__PURE__ */ jsx(
|
|
290
331
|
CardShortcut,
|
|
291
332
|
{
|