@drawbridge/components 0.1.48 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bridge/fields.js +0 -278
- package/dist/bridge/fields.mjs +1 -276
- package/dist/bridge/form-subdomain-shop-modal.js +274 -234
- package/dist/bridge/form-subdomain-shop-modal.mjs +275 -233
- package/dist/bridge/form-subdomain.js +0 -7
- package/dist/bridge/form-subdomain.mjs +2 -9
- package/dist/bridge/lib/age-gate.js +0 -12
- package/dist/bridge/lib/age-gate.mjs +0 -11
- package/dist/bridge/lib/checkout-kit.js +32 -2
- package/dist/bridge/lib/checkout-kit.mjs +32 -2
- package/dist/bridge/lib/entry.js +3 -3
- package/dist/bridge/lib/entry.mjs +2 -2
- package/dist/bridge/product-tile.js +6 -9
- package/dist/bridge/product-tile.mjs +6 -9
- package/dist/bridge/template-layout.js +123 -238
- package/dist/bridge/template-layout.mjs +124 -239
- package/dist/bridge/template-modal.js +73 -28
- package/dist/bridge/template-modal.mjs +74 -29
- package/dist/dashboard/buttons-subscription.js +1 -1
- package/dist/dashboard/buttons-subscription.mjs +1 -1
- package/dist/dashboard/campaign-form.js +2 -7
- package/dist/dashboard/campaign-form.mjs +2 -7
- package/dist/dashboard/card-order.js +4 -22
- package/dist/dashboard/card-order.mjs +4 -22
- package/dist/dashboard/document-blocks.js +17 -4
- package/dist/dashboard/document-blocks.mjs +17 -4
- package/dist/dashboard/form-admin-provider.js +17 -71
- package/dist/dashboard/form-admin-provider.mjs +17 -71
- package/dist/dashboard/form-file-upload.js +2 -3
- package/dist/dashboard/form-file-upload.mjs +3 -4
- package/dist/dashboard/form-organization-campaign-advertisements.js +6 -47
- package/dist/dashboard/form-organization-campaign-advertisements.mjs +6 -47
- package/dist/dashboard/form-organization-campaign-agreement.js +121 -83
- package/dist/dashboard/form-organization-campaign-agreement.mjs +121 -83
- package/dist/dashboard/form-organization-campaign.js +0 -82
- package/dist/dashboard/form-organization-campaign.mjs +0 -81
- package/dist/dashboard/form-organization-connection.js +6 -48
- package/dist/dashboard/form-organization-connection.mjs +7 -48
- package/dist/dashboard/form-organization-workflow.js +1 -72
- package/dist/dashboard/form-organization-workflow.mjs +1 -69
- package/dist/dashboard/form-otc.js +5 -4
- package/dist/dashboard/form-otc.mjs +5 -4
- package/dist/dashboard/form-stripe.js +5 -12
- package/dist/dashboard/form-stripe.mjs +5 -12
- package/dist/dashboard/input-fields.js +158 -11
- package/dist/dashboard/input-fields.mjs +158 -11
- package/dist/dashboard/input-file.js +4 -21
- package/dist/dashboard/input-file.mjs +4 -21
- package/dist/dashboard/lib/connection-controls.js +2 -5
- package/dist/dashboard/lib/connection-controls.mjs +1 -3
- package/dist/dashboard/lib/form-page.js +1 -1
- package/dist/dashboard/lib/form-page.mjs +1 -1
- package/dist/dashboard/lib/uppy.js +1 -10
- package/dist/dashboard/lib/uppy.mjs +2 -11
- package/dist/dashboard/order-sections.js +6 -456
- package/dist/dashboard/order-sections.mjs +7 -453
- package/dist/dashboard/provider-ui.js +7 -9
- package/dist/dashboard/provider-ui.mjs +7 -9
- package/dist/dashboard/template-ui.js +12 -4
- package/dist/dashboard/template-ui.mjs +12 -4
- package/dist/input-checkbox.js +10 -28
- package/dist/input-checkbox.mjs +10 -28
- package/dist/product.js +24 -96
- package/dist/product.mjs +25 -97
- package/dist/shared/lib/helpers.js +6 -54
- package/dist/shared/lib/helpers.mjs +8 -53
- package/package.json +4 -74
- package/types/bridge/fields.d.ts +2 -14
- package/types/bridge/form-subdomain-shop-modal.d.ts +3 -27
- package/types/bridge/lib/age-gate.d.ts +0 -5
- package/types/bridge/lib/checkout-kit.d.ts +10 -2
- package/types/bridge/lib/entry.d.ts +3 -3
- package/types/dashboard/card-order.d.ts +0 -6
- package/types/dashboard/document-blocks.d.ts +3 -2
- package/types/dashboard/form-admin-provider.d.ts +2 -9
- package/types/dashboard/form-file-upload.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-advertisements.d.ts +0 -3
- package/types/dashboard/form-organization-campaign-agreement.d.ts +5 -2
- package/types/dashboard/form-organization-campaign.d.ts +0 -3
- package/types/dashboard/form-organization-connection.d.ts +0 -11
- package/types/dashboard/form-otc.d.ts +1 -5
- package/types/dashboard/form-stripe.d.ts +2 -3
- package/types/dashboard/input-file.d.ts +0 -2
- package/types/dashboard/order-sections.d.ts +1 -24
- package/types/input-checkbox.d.ts +0 -2
- package/types/shared/lib/helpers.d.ts +0 -4
- package/dist/bridge/cart-drawer.js +0 -152
- package/dist/bridge/cart-drawer.mjs +0 -123
- package/dist/bridge/form-subdomain-checkout.js +0 -687
- package/dist/bridge/form-subdomain-checkout.mjs +0 -665
- package/dist/bridge/lib/cart.js +0 -79
- package/dist/bridge/lib/cart.mjs +0 -48
- package/dist/dashboard/embed-stripe.js +0 -145
- package/dist/dashboard/embed-stripe.mjs +0 -116
- package/dist/dashboard/form-organization-campaign-field-birthday.js +0 -193
- package/dist/dashboard/form-organization-campaign-field-birthday.mjs +0 -164
- package/dist/dashboard/form-organization-campaign-field-rating.js +0 -246
- package/dist/dashboard/form-organization-campaign-field-rating.mjs +0 -217
- package/dist/dashboard/form-organization-product.js +0 -1461
- package/dist/dashboard/form-organization-product.mjs +0 -1425
- package/dist/dashboard/input-gallery.js +0 -201
- package/dist/dashboard/input-gallery.mjs +0 -172
- package/dist/dashboard/lib/products.js +0 -169
- package/dist/dashboard/lib/products.mjs +0 -135
- package/dist/dashboard/lib/settings-paths.js +0 -35
- package/dist/dashboard/lib/settings-paths.mjs +0 -11
- package/dist/dashboard/shipping-rates.js +0 -404
- package/dist/dashboard/shipping-rates.mjs +0 -371
- package/dist/dashboard/template-buyer.js +0 -301
- package/dist/dashboard/template-buyer.mjs +0 -267
- package/dist/shared/order-summary.js +0 -139
- package/dist/shared/order-summary.mjs +0 -110
- package/types/bridge/cart-drawer.d.ts +0 -31
- package/types/bridge/form-subdomain-checkout.d.ts +0 -20
- package/types/bridge/lib/cart.d.ts +0 -44
- package/types/dashboard/embed-stripe.d.ts +0 -25
- package/types/dashboard/form-organization-campaign-field-birthday.d.ts +0 -31
- package/types/dashboard/form-organization-campaign-field-rating.d.ts +0 -33
- package/types/dashboard/form-organization-product.d.ts +0 -24
- package/types/dashboard/input-gallery.d.ts +0 -14
- package/types/dashboard/lib/products.d.ts +0 -14
- package/types/dashboard/lib/settings-paths.d.ts +0 -5
- package/types/dashboard/shipping-rates.d.ts +0 -26
- package/types/dashboard/template-buyer.d.ts +0 -50
- package/types/shared/order-summary.d.ts +0 -19
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
import { Controller, useForm } from "../shared/lib/form.mjs";
|
|
6
5
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
7
6
|
import yup, { resolver } from "../shared/lib/yup.mjs";
|
|
@@ -13,18 +12,11 @@ import InputSwitch from "../shared/input-switch.mjs";
|
|
|
13
12
|
import CardTask from "./card-task.mjs";
|
|
14
13
|
import InputSecret from "./input-secret.mjs";
|
|
15
14
|
import Button from "../shared/button.mjs";
|
|
16
|
-
|
|
17
|
-
import { nestPaths, readPath } from "./lib/settings-paths.mjs";
|
|
18
|
-
const schemaFor = (field, enabled) => {
|
|
15
|
+
const schemaFor = (field) => {
|
|
19
16
|
if (field.input === "switch") return yup.boolean().label(field.label);
|
|
20
17
|
const rule = field.input === "email" ? yup.string().label(field.label).email() : yup.string().label(field.label);
|
|
21
|
-
return
|
|
18
|
+
return field.required && !field.redact ? rule.when("enabled", { is: false, otherwise: (s) => s.required(), then: (s) => s.nullable() }) : rule.nullable();
|
|
22
19
|
};
|
|
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
|
-
);
|
|
28
20
|
const FormAdminProvider = ({
|
|
29
21
|
onError,
|
|
30
22
|
onSuccess,
|
|
@@ -37,37 +29,25 @@ const FormAdminProvider = ({
|
|
|
37
29
|
// A row that has never been touched has no answer stored and is on, so
|
|
38
30
|
// the box starts checked rather than empty.
|
|
39
31
|
enabled: (values == null ? void 0 : values.enabled) !== false,
|
|
40
|
-
...
|
|
41
|
-
fields.map((field) =>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
...Object.fromEntries(
|
|
33
|
+
fields.map((field) => {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
return [
|
|
36
|
+
field.key,
|
|
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
|
+
})
|
|
45
40
|
)
|
|
46
41
|
}),
|
|
47
42
|
[fields, values]
|
|
48
43
|
);
|
|
49
44
|
const schema = useMemo(
|
|
50
|
-
() => yup.
|
|
45
|
+
() => yup.object({
|
|
51
46
|
enabled: yup.boolean().label("Enabled"),
|
|
52
|
-
...
|
|
53
|
-
})
|
|
47
|
+
...Object.fromEntries(fields.map((field) => [field.key, schemaFor(field)]))
|
|
48
|
+
}),
|
|
54
49
|
[fields]
|
|
55
50
|
);
|
|
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]]));
|
|
71
51
|
const [clearing, setClearing] = useState([]);
|
|
72
52
|
useEffect(() => setClearing([]), [values == null ? void 0 : values.slug]);
|
|
73
53
|
const { control, formState, handleSubmit } = useForm({
|
|
@@ -92,20 +72,10 @@ const FormAdminProvider = ({
|
|
|
92
72
|
// admin then TYPED INTO is a replacement, not a removal. The api
|
|
93
73
|
// applies `clear` after `settings`, so naming a key that also
|
|
94
74
|
// carries a value deleted the value just typed and answered "Saved".
|
|
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
|
-
],
|
|
75
|
+
clear: clearing.filter((key) => !(data == null ? void 0 : data[key])),
|
|
106
76
|
enabled: Boolean(data == null ? void 0 : data.enabled),
|
|
107
|
-
settings:
|
|
108
|
-
fields.map((field) => [field.key,
|
|
77
|
+
settings: Object.fromEntries(
|
|
78
|
+
fields.map((field) => [field.key, (data == null ? void 0 : data[field.key]) ?? ""])
|
|
109
79
|
)
|
|
110
80
|
},
|
|
111
81
|
endpoint: "/admin/provider/" + (values == null ? void 0 : values.slug),
|
|
@@ -231,35 +201,11 @@ const FormAdminProvider = ({
|
|
|
231
201
|
value
|
|
232
202
|
}
|
|
233
203
|
}
|
|
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
|
-
}
|
|
258
204
|
) : /* @__PURE__ */ jsx(
|
|
259
205
|
InputGroup,
|
|
260
206
|
{
|
|
261
207
|
...{
|
|
262
|
-
error: (_b =
|
|
208
|
+
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[field.key]) == null ? void 0 : _b.message,
|
|
263
209
|
input: /* @__PURE__ */ jsx(
|
|
264
210
|
InputText,
|
|
265
211
|
{
|
|
@@ -62,8 +62,7 @@ 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
|
|
66
|
-
const sizeLimits = digital ? import_helpers.digitalSizeLimits : maximumUploadBytes ? { ...import_helpers.fileSizeLimits, video: maximumUploadBytes / import_drawbridge_utils.megabyte } : import_helpers.fileSizeLimits;
|
|
65
|
+
const sizeLimits = maximumUploadBytes ? { ...import_helpers.fileSizeLimits, video: maximumUploadBytes / import_drawbridge_utils.megabyte } : import_helpers.fileSizeLimits;
|
|
67
66
|
const uploaderRef = (0, import_react.useRef)(null);
|
|
68
67
|
const successRef = (0, import_react.useRef)(onSuccess);
|
|
69
68
|
const realRef = (0, import_react.useRef)(0);
|
|
@@ -263,7 +262,7 @@ const FormFileUpload = ({
|
|
|
263
262
|
type: type2
|
|
264
263
|
}
|
|
265
264
|
}) => {
|
|
266
|
-
if (
|
|
265
|
+
if ((data == null ? void 0 : data.size) >= multipartBytes) {
|
|
267
266
|
return await onMultipart({
|
|
268
267
|
data
|
|
269
268
|
});
|
|
@@ -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 {
|
|
6
|
+
import { 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,8 +30,7 @@ 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
|
|
34
|
-
const sizeLimits = digital ? digitalSizeLimits : maximumUploadBytes ? { ...fileSizeLimits, video: maximumUploadBytes / megabyte } : fileSizeLimits;
|
|
33
|
+
const sizeLimits = maximumUploadBytes ? { ...fileSizeLimits, video: maximumUploadBytes / megabyte } : fileSizeLimits;
|
|
35
34
|
const uploaderRef = useRef(null);
|
|
36
35
|
const successRef = useRef(onSuccess);
|
|
37
36
|
const realRef = useRef(0);
|
|
@@ -231,7 +230,7 @@ const FormFileUpload = ({
|
|
|
231
230
|
type: type2
|
|
232
231
|
}
|
|
233
232
|
}) => {
|
|
234
|
-
if (
|
|
233
|
+
if ((data == null ? void 0 : data.size) >= multipartBytes) {
|
|
235
234
|
return await onMultipart({
|
|
236
235
|
data
|
|
237
236
|
});
|
|
@@ -35,7 +35,6 @@ 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");
|
|
39
38
|
var import_helpers = require("../shared/lib/helpers");
|
|
40
39
|
var import_form_page = require("./lib/form-page");
|
|
41
40
|
var import_form_organization_campaign_advertisement = __toESM(require("./form-organization-campaign-advertisement"));
|
|
@@ -53,7 +52,6 @@ var import_arrow_left = __toESM(require("../icons/arrow-left"));
|
|
|
53
52
|
var import_loader = __toESM(require("../icons/loader"));
|
|
54
53
|
var import_plus_small = __toESM(require("../icons/plus-small"));
|
|
55
54
|
const FormOrganizationCampaignAdvertisements = ({
|
|
56
|
-
checkout,
|
|
57
55
|
commerce,
|
|
58
56
|
disabled,
|
|
59
57
|
onError,
|
|
@@ -77,7 +75,6 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
77
75
|
}),
|
|
78
76
|
queryKey: (0, import_form_page.advertisementsKey)(params)
|
|
79
77
|
});
|
|
80
|
-
const made = import_products.PRODUCT_PROVIDER[checkout] === "drawbridge";
|
|
81
78
|
const ads = (Array.isArray(data == null ? void 0 : data.result) ? data.result : (_a = data == null ? void 0 : data.result) == null ? void 0 : _a.items) || [];
|
|
82
79
|
const full = ads.length >= import_form_page.MAX_ADS;
|
|
83
80
|
const back = () => setView("list");
|
|
@@ -191,7 +188,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
191
188
|
...{
|
|
192
189
|
list: [
|
|
193
190
|
{ title: "Details" },
|
|
194
|
-
{ title:
|
|
191
|
+
{ title: (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
195
192
|
],
|
|
196
193
|
panels: [
|
|
197
194
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -217,12 +214,9 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
217
214
|
import_list_resource.default,
|
|
218
215
|
{
|
|
219
216
|
...{
|
|
220
|
-
endpoint:
|
|
217
|
+
endpoint: "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
221
218
|
model: "product",
|
|
222
219
|
params: {
|
|
223
|
-
...made && {
|
|
224
|
-
provider: import_products.PRODUCT_PROVIDER[checkout]
|
|
225
|
-
},
|
|
226
220
|
sort: {
|
|
227
221
|
createdAt: -1
|
|
228
222
|
}
|
|
@@ -242,21 +236,20 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
242
236
|
}
|
|
243
237
|
},
|
|
244
238
|
render: (product) => {
|
|
245
|
-
var _a2
|
|
239
|
+
var _a2;
|
|
246
240
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
247
241
|
import_card_product.default,
|
|
248
242
|
{
|
|
249
243
|
...{
|
|
250
|
-
image:
|
|
251
|
-
title: product.title
|
|
252
|
-
updatedAt: product.updatedAt
|
|
244
|
+
image: ((_a2 = product.featuredImage) == null ? void 0 : _a2.url) || null,
|
|
245
|
+
title: product.title
|
|
253
246
|
}
|
|
254
247
|
}
|
|
255
248
|
);
|
|
256
249
|
},
|
|
257
250
|
renderButton: ({ button, item }) => {
|
|
258
251
|
var _a2, _b;
|
|
259
|
-
return (
|
|
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)(
|
|
260
253
|
import_button.default,
|
|
261
254
|
{
|
|
262
255
|
...button.props,
|
|
@@ -325,40 +318,6 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
325
318
|
onSort: reorder,
|
|
326
319
|
renderItem: (ad, _index, handle) => {
|
|
327
320
|
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
|
-
);
|
|
362
321
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
363
322
|
import_card_shortcut.default,
|
|
364
323
|
{
|
|
@@ -3,7 +3,6 @@ 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";
|
|
7
6
|
import { productAsset, statusBadge } from "../shared/lib/helpers.mjs";
|
|
8
7
|
import { adsLimit, advertisementsKey, MAX_ADS } from "./lib/form-page.mjs";
|
|
9
8
|
import FormOrganizationCampaignAdvertisement from "./form-organization-campaign-advertisement.mjs";
|
|
@@ -21,7 +20,6 @@ import ArrowLeft from "../icons/arrow-left.mjs";
|
|
|
21
20
|
import Loader from "../icons/loader.mjs";
|
|
22
21
|
import PlusSmall from "../icons/plus-small.mjs";
|
|
23
22
|
const FormOrganizationCampaignAdvertisements = ({
|
|
24
|
-
checkout,
|
|
25
23
|
commerce,
|
|
26
24
|
disabled,
|
|
27
25
|
onError,
|
|
@@ -45,7 +43,6 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
45
43
|
}),
|
|
46
44
|
queryKey: advertisementsKey(params)
|
|
47
45
|
});
|
|
48
|
-
const made = PRODUCT_PROVIDER[checkout] === "drawbridge";
|
|
49
46
|
const ads = (Array.isArray(data == null ? void 0 : data.result) ? data.result : (_a = data == null ? void 0 : data.result) == null ? void 0 : _a.items) || [];
|
|
50
47
|
const full = ads.length >= MAX_ADS;
|
|
51
48
|
const back = () => setView("list");
|
|
@@ -159,7 +156,7 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
159
156
|
...{
|
|
160
157
|
list: [
|
|
161
158
|
{ title: "Details" },
|
|
162
|
-
{ title:
|
|
159
|
+
{ title: (commerce == null ? void 0 : commerce.title) || "Store" }
|
|
163
160
|
],
|
|
164
161
|
panels: [
|
|
165
162
|
/* @__PURE__ */ jsx(
|
|
@@ -185,12 +182,9 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
185
182
|
ListResource,
|
|
186
183
|
{
|
|
187
184
|
...{
|
|
188
|
-
endpoint:
|
|
185
|
+
endpoint: "/organization/" + (params == null ? void 0 : params.organization) + "/connection/" + ((commerce == null ? void 0 : commerce.slug) || "shopify") + "/hook/browse.products",
|
|
189
186
|
model: "product",
|
|
190
187
|
params: {
|
|
191
|
-
...made && {
|
|
192
|
-
provider: PRODUCT_PROVIDER[checkout]
|
|
193
|
-
},
|
|
194
188
|
sort: {
|
|
195
189
|
createdAt: -1
|
|
196
190
|
}
|
|
@@ -210,21 +204,20 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
210
204
|
}
|
|
211
205
|
},
|
|
212
206
|
render: (product) => {
|
|
213
|
-
var _a2
|
|
207
|
+
var _a2;
|
|
214
208
|
return /* @__PURE__ */ jsx(
|
|
215
209
|
CardProduct,
|
|
216
210
|
{
|
|
217
211
|
...{
|
|
218
|
-
image:
|
|
219
|
-
title: product.title
|
|
220
|
-
updatedAt: product.updatedAt
|
|
212
|
+
image: ((_a2 = product.featuredImage) == null ? void 0 : _a2.url) || null,
|
|
213
|
+
title: product.title
|
|
221
214
|
}
|
|
222
215
|
}
|
|
223
216
|
);
|
|
224
217
|
},
|
|
225
218
|
renderButton: ({ button, item }) => {
|
|
226
219
|
var _a2, _b;
|
|
227
|
-
return (
|
|
220
|
+
return ((_b = (_a2 = item.variants) == null ? void 0 : _a2.edges) == null ? void 0 : _b.some((edge) => edge.node.availableForSale)) ? /* @__PURE__ */ jsx(
|
|
228
221
|
Button,
|
|
229
222
|
{
|
|
230
223
|
...button.props,
|
|
@@ -293,40 +286,6 @@ const FormOrganizationCampaignAdvertisements = ({
|
|
|
293
286
|
onSort: reorder,
|
|
294
287
|
renderItem: (ad, _index, handle) => {
|
|
295
288
|
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
|
-
);
|
|
330
289
|
return /* @__PURE__ */ jsx(
|
|
331
290
|
CardShortcut,
|
|
332
291
|
{
|