@drawbridge/components 0.1.46 → 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-shop.js +4 -1
- package/dist/bridge/form-subdomain-shop.mjs +4 -1
- package/dist/bridge/form-subdomain.js +24 -5
- package/dist/bridge/form-subdomain.mjs +25 -6
- 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/lib/entry.js +41 -0
- package/dist/bridge/lib/entry.mjs +40 -0
- package/dist/bridge/product-tile.js +13 -6
- package/dist/bridge/product-tile.mjs +13 -6
- package/dist/bridge/template-layout.js +263 -129
- package/dist/bridge/template-layout.mjs +264 -130
- package/dist/bridge/template-modal.js +39 -74
- package/dist/bridge/template-modal.mjs +40 -75
- package/dist/dashboard/avatar.js +2 -3
- package/dist/dashboard/avatar.mjs +2 -3
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +179 -155
- package/dist/dashboard/campaign-form.mjs +179 -155
- package/dist/dashboard/campaign-share.js +347 -0
- package/dist/dashboard/campaign-share.mjs +314 -0
- package/dist/dashboard/card-affiliate.js +1 -1
- package/dist/dashboard/card-affiliate.mjs +1 -1
- package/dist/dashboard/card-campaign-switch.js +4 -1
- package/dist/dashboard/card-campaign-switch.mjs +4 -1
- 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-page.js +73 -39
- package/dist/dashboard/form-organization-campaign-page.mjs +73 -39
- 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-combobox.js +6 -0
- package/dist/dashboard/input-combobox.mjs +6 -0
- package/dist/dashboard/input-fields.js +37 -161
- package/dist/dashboard/input-fields.mjs +37 -161
- package/dist/dashboard/input-file.js +21 -4
- package/dist/dashboard/input-file.mjs +21 -4
- package/dist/dashboard/input-font.js +2 -0
- package/dist/dashboard/input-font.mjs +2 -0
- package/dist/dashboard/input-gallery.js +201 -0
- package/dist/dashboard/input-gallery.mjs +172 -0
- package/dist/dashboard/input-group-ai.js +15 -3
- package/dist/dashboard/input-group-ai.mjs +15 -3
- package/dist/dashboard/lib/ab-tests.js +2 -2
- package/dist/dashboard/lib/ab-tests.mjs +2 -2
- 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/menu.js +19 -0
- package/dist/dashboard/lib/menu.mjs +18 -0
- 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/menu.js +13 -2
- package/dist/dashboard/menu.mjs +13 -2
- package/dist/dashboard/order-sections.js +456 -6
- package/dist/dashboard/order-sections.mjs +453 -7
- package/dist/dashboard/preview.js +119 -52
- package/dist/dashboard/preview.mjs +119 -52
- package/dist/dashboard/provider-ui.js +9 -7
- package/dist/dashboard/provider-ui.mjs +9 -7
- package/dist/dashboard/recharts.js +10 -4
- package/dist/dashboard/recharts.mjs +10 -4
- 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/dashboard/template-dashboard.js +11 -1
- package/dist/dashboard/template-dashboard.mjs +11 -1
- package/dist/dashboard/template-design.js +209 -130
- package/dist/dashboard/template-design.mjs +210 -131
- package/dist/dashboard/template-ui.js +157 -55
- package/dist/dashboard/template-ui.mjs +158 -56
- package/dist/icons/flags.js +134 -0
- package/dist/icons/flags.mjs +115 -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/carousel.js +14 -5
- package/dist/shared/carousel.mjs +14 -5
- 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 +84 -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/form-subdomain.d.ts +13 -0
- 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/bridge/lib/entry.d.ts +5 -0
- package/types/bridge/product-tile.d.ts +2 -0
- package/types/dashboard/campaign-share.d.ts +16 -0
- 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-page.d.ts +8 -1
- 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-combobox.d.ts +2 -0
- 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/preview.d.ts +11 -3
- package/types/dashboard/shipping-rates.d.ts +26 -0
- package/types/dashboard/template-buyer.d.ts +50 -0
- package/types/icons/flags.d.ts +5 -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
|
@@ -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
|
{
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var form_organization_campaign_field_birthday_exports = {};
|
|
29
|
+
__export(form_organization_campaign_field_birthday_exports, {
|
|
30
|
+
default: () => form_organization_campaign_field_birthday_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(form_organization_campaign_field_birthday_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_form = require("../shared/lib/form");
|
|
35
|
+
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
36
|
+
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
37
|
+
var import_form2 = __toESM(require("../shared/form"));
|
|
38
|
+
var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
39
|
+
var import_input_group = __toESM(require("../input-group"));
|
|
40
|
+
var import_input_text = __toESM(require("../input-text"));
|
|
41
|
+
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
42
|
+
var import_button = __toESM(require("../shared/button"));
|
|
43
|
+
const FormOrganizationCampaignFieldBirthday = ({
|
|
44
|
+
disabled,
|
|
45
|
+
onError,
|
|
46
|
+
onSuccess,
|
|
47
|
+
values
|
|
48
|
+
}) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
51
|
+
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
52
|
+
resolver: (0, import_yup.resolver)(
|
|
53
|
+
import_yup.default.object({
|
|
54
|
+
label: import_yup.default.string().label("Label").required().max(150)
|
|
55
|
+
})
|
|
56
|
+
),
|
|
57
|
+
values: {
|
|
58
|
+
...values,
|
|
59
|
+
attributes: {
|
|
60
|
+
required: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.required) !== false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
const onSubmit = async ({
|
|
65
|
+
attributes = {},
|
|
66
|
+
label,
|
|
67
|
+
section
|
|
68
|
+
}) => {
|
|
69
|
+
try {
|
|
70
|
+
const args = {
|
|
71
|
+
body: {
|
|
72
|
+
attributes: {
|
|
73
|
+
required: (attributes == null ? void 0 : attributes.required) !== false
|
|
74
|
+
},
|
|
75
|
+
label,
|
|
76
|
+
...section && {
|
|
77
|
+
section
|
|
78
|
+
},
|
|
79
|
+
slug: values == null ? void 0 : values.slug,
|
|
80
|
+
type: values == null ? void 0 : values.type
|
|
81
|
+
},
|
|
82
|
+
endpoint: "/organization/" + (values == null ? void 0 : values.organization) + "/campaign/" + (values == null ? void 0 : values.campaign) + "/field",
|
|
83
|
+
method: "POST"
|
|
84
|
+
};
|
|
85
|
+
if (values == null ? void 0 : values.id) {
|
|
86
|
+
args.endpoint = args.endpoint + "/" + values.id;
|
|
87
|
+
args.method = "PUT";
|
|
88
|
+
}
|
|
89
|
+
const response = await (0, import_fetch.request)(args);
|
|
90
|
+
onSuccess(response);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
onError(error);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
96
|
+
import_form2.default,
|
|
97
|
+
{
|
|
98
|
+
...{
|
|
99
|
+
className: "relative w-full space-y-6",
|
|
100
|
+
onSubmit: handleSubmit(onSubmit)
|
|
101
|
+
},
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
104
|
+
import_fieldset.default,
|
|
105
|
+
{
|
|
106
|
+
...{
|
|
107
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
108
|
+
},
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
111
|
+
import_form.Controller,
|
|
112
|
+
{
|
|
113
|
+
...{
|
|
114
|
+
control,
|
|
115
|
+
name: "label",
|
|
116
|
+
render: ({ field: { value, onChange } }) => {
|
|
117
|
+
var _a2, _b;
|
|
118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
119
|
+
import_input_group.default,
|
|
120
|
+
{
|
|
121
|
+
...{
|
|
122
|
+
error: (_b = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b.message,
|
|
123
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
124
|
+
import_input_text.default,
|
|
125
|
+
{
|
|
126
|
+
...{
|
|
127
|
+
disabled: !inputs.includes("label"),
|
|
128
|
+
onChange,
|
|
129
|
+
value: value || ""
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
label: "Field label"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
142
|
+
import_form.Controller,
|
|
143
|
+
{
|
|
144
|
+
...{
|
|
145
|
+
control,
|
|
146
|
+
name: "attributes.required",
|
|
147
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
148
|
+
import_input_group.default,
|
|
149
|
+
{
|
|
150
|
+
...{
|
|
151
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
152
|
+
import_input_switch.default,
|
|
153
|
+
{
|
|
154
|
+
...{
|
|
155
|
+
disabled: !inputs.includes("attributes"),
|
|
156
|
+
onChange,
|
|
157
|
+
value: value !== false
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
label: "Required"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
+
import_fieldset.default,
|
|
173
|
+
{
|
|
174
|
+
...{
|
|
175
|
+
disabled: disabled || (formState == null ? void 0 : formState.isSubmitting)
|
|
176
|
+
},
|
|
177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
import_button.default,
|
|
179
|
+
{
|
|
180
|
+
...{
|
|
181
|
+
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
182
|
+
type: "submit"
|
|
183
|
+
},
|
|
184
|
+
children: "Submit"
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
var form_organization_campaign_field_birthday_default = FormOrganizationCampaignFieldBirthday;
|