@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,35 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var settings_paths_exports = {};
|
|
19
|
-
__export(settings_paths_exports, {
|
|
20
|
-
nestPaths: () => nestPaths,
|
|
21
|
-
readPath: () => readPath
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(settings_paths_exports);
|
|
24
|
-
const readPath = (object, key) => String(key).split(".").reduce((node, part) => node == null ? void 0 : node[part], object);
|
|
25
|
-
const nestPaths = (pairs) => pairs.reduce((tree, [key, value]) => {
|
|
26
|
-
const parts = String(key).split(".");
|
|
27
|
-
const last = parts.pop();
|
|
28
|
-
parts.reduce((branch, part) => branch[part] ??= {}, tree)[last] = value;
|
|
29
|
-
return tree;
|
|
30
|
-
}, {});
|
|
31
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
-
0 && (module.exports = {
|
|
33
|
-
nestPaths,
|
|
34
|
-
readPath
|
|
35
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const readPath = (object, key) => String(key).split(".").reduce((node, part) => node == null ? void 0 : node[part], object);
|
|
2
|
-
const nestPaths = (pairs) => pairs.reduce((tree, [key, value]) => {
|
|
3
|
-
const parts = String(key).split(".");
|
|
4
|
-
const last = parts.pop();
|
|
5
|
-
parts.reduce((branch, part) => branch[part] ??= {}, tree)[last] = value;
|
|
6
|
-
return tree;
|
|
7
|
-
}, {});
|
|
8
|
-
export {
|
|
9
|
-
nestPaths,
|
|
10
|
-
readPath
|
|
11
|
-
};
|
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var shipping_rates_exports = {};
|
|
30
|
-
__export(shipping_rates_exports, {
|
|
31
|
-
FormRate: () => FormRate,
|
|
32
|
-
default: () => shipping_rates_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(shipping_rates_exports);
|
|
35
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
-
var import_react_query = require("@tanstack/react-query");
|
|
37
|
-
var import_drawbridge_utils = require("@drawbridge/drawbridge-utils");
|
|
38
|
-
var import_fetch = require("@drawbridge/drawbridge-utils/fetch");
|
|
39
|
-
var import_products = require("@drawbridge/drawbridge-utils/products");
|
|
40
|
-
var import_form = require("../shared/lib/form");
|
|
41
|
-
var import_yup = __toESM(require("../shared/lib/yup"));
|
|
42
|
-
var import_hooks = require("./lib/hooks");
|
|
43
|
-
var import_order_sections = require("./order-sections");
|
|
44
|
-
var import_card_section = __toESM(require("./card-section"));
|
|
45
|
-
var import_paged = __toESM(require("./paged"));
|
|
46
|
-
var import_table = __toESM(require("./table"));
|
|
47
|
-
var import_table_cell_title = __toESM(require("./table-cell-title"));
|
|
48
|
-
var import_button = __toESM(require("../shared/button"));
|
|
49
|
-
var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
50
|
-
var import_form2 = __toESM(require("../shared/form"));
|
|
51
|
-
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
52
|
-
var import_input_group = __toESM(require("../input-group"));
|
|
53
|
-
var import_input_number = __toESM(require("../input-number"));
|
|
54
|
-
var import_input_select = __toESM(require("../input-select"));
|
|
55
|
-
var import_input_text = __toESM(require("../input-text"));
|
|
56
|
-
var import_pencil = __toESM(require("../icons/pencil"));
|
|
57
|
-
var import_plus = __toESM(require("../icons/plus"));
|
|
58
|
-
var import_trash = __toESM(require("../icons/trash"));
|
|
59
|
-
const COUNTRIES = [
|
|
60
|
-
{
|
|
61
|
-
label: "Canada",
|
|
62
|
-
value: "CA"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: "United States",
|
|
66
|
-
value: "US"
|
|
67
|
-
}
|
|
68
|
-
];
|
|
69
|
-
const countryName = (code) => {
|
|
70
|
-
var _a;
|
|
71
|
-
return ((_a = COUNTRIES.find((item) => item.value === code)) == null ? void 0 : _a.label) || code;
|
|
72
|
-
};
|
|
73
|
-
const keyOf = (delivery) => delivery ? delivery.minimum + "-" + delivery.maximum : "";
|
|
74
|
-
const FormRate = ({ currency, endpoint, onError, onSuccess, values }) => {
|
|
75
|
-
const { control, formState, handleSubmit, watch } = (0, import_form.useForm)({
|
|
76
|
-
resolver: (0, import_yup.resolver)(
|
|
77
|
-
import_yup.default.object({
|
|
78
|
-
free: import_yup.default.number().label("Free over").nullable().when("freeOver", ([on], schema) => on ? schema.required().min(0) : schema),
|
|
79
|
-
name: import_yup.default.string().label("Name").trim().required().max(100),
|
|
80
|
-
price: import_yup.default.number().label("Price").typeError("Price is a required field").required().min(0)
|
|
81
|
-
})
|
|
82
|
-
),
|
|
83
|
-
values: {
|
|
84
|
-
country: (values == null ? void 0 : values.country) || COUNTRIES[0].value,
|
|
85
|
-
delivery: keyOf((values == null ? void 0 : values.delivery) || import_products.DELIVERY[2]),
|
|
86
|
-
free: (values == null ? void 0 : values.free) ?? null,
|
|
87
|
-
freeOver: Number.isFinite(values == null ? void 0 : values.free),
|
|
88
|
-
name: (values == null ? void 0 : values.name) || "",
|
|
89
|
-
price: (values == null ? void 0 : values.price) ?? null
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
const onSubmit = async ({ country, delivery, free, freeOver, name, price }) => {
|
|
93
|
-
try {
|
|
94
|
-
const [minimum, maximum] = delivery.split("-").map(Number);
|
|
95
|
-
onSuccess(await (0, import_fetch.request)({
|
|
96
|
-
body: {
|
|
97
|
-
country,
|
|
98
|
-
delivery: {
|
|
99
|
-
maximum,
|
|
100
|
-
minimum
|
|
101
|
-
},
|
|
102
|
-
free: freeOver ? Number(free) : null,
|
|
103
|
-
name: name.trim(),
|
|
104
|
-
price: Number(price)
|
|
105
|
-
},
|
|
106
|
-
endpoint,
|
|
107
|
-
method: (values == null ? void 0 : values.id) ? "PUT" : "POST"
|
|
108
|
-
}));
|
|
109
|
-
} catch (error) {
|
|
110
|
-
onError == null ? void 0 : onError(error);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const field = (name, label, input, extra = {}) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
114
|
-
import_form.Controller,
|
|
115
|
-
{
|
|
116
|
-
...{
|
|
117
|
-
control,
|
|
118
|
-
name,
|
|
119
|
-
render: ({ field: { onChange, value } }) => {
|
|
120
|
-
var _a, _b;
|
|
121
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
122
|
-
import_input_group.default,
|
|
123
|
-
{
|
|
124
|
-
...{
|
|
125
|
-
...extra,
|
|
126
|
-
error: (_b = (_a = formState == null ? void 0 : formState.errors) == null ? void 0 : _a[name]) == null ? void 0 : _b.message,
|
|
127
|
-
input: input({ onChange, value }),
|
|
128
|
-
label
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
name
|
|
136
|
-
);
|
|
137
|
-
const symbol = { before: (0, import_drawbridge_utils.formatCurrency)({ code: (currency || "usd").toUpperCase(), value: 0 }).replace(/[\d.,\s]/g, "") };
|
|
138
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
139
|
-
import_form2.default,
|
|
140
|
-
{
|
|
141
|
-
...{
|
|
142
|
-
className: "relative w-full space-y-6",
|
|
143
|
-
onSubmit: handleSubmit(onSubmit)
|
|
144
|
-
},
|
|
145
|
-
children: [
|
|
146
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
147
|
-
import_fieldset.default,
|
|
148
|
-
{
|
|
149
|
-
...{
|
|
150
|
-
className: "space-y-6",
|
|
151
|
-
disabled: formState == null ? void 0 : formState.isSubmitting
|
|
152
|
-
},
|
|
153
|
-
children: [
|
|
154
|
-
field("name", "Name", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
import_input_text.default,
|
|
156
|
-
{
|
|
157
|
-
...{
|
|
158
|
-
onChange,
|
|
159
|
-
placeholder: "Standard",
|
|
160
|
-
value: value || ""
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
)),
|
|
164
|
-
field("price", "Price", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
-
import_input_number.default,
|
|
166
|
-
{
|
|
167
|
-
...{
|
|
168
|
-
min: 0,
|
|
169
|
-
onChange,
|
|
170
|
-
step: 0.01,
|
|
171
|
-
value: value ?? ""
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
), symbol),
|
|
175
|
-
field("country", "Country", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
176
|
-
import_input_select.default,
|
|
177
|
-
{
|
|
178
|
-
...{
|
|
179
|
-
onChange,
|
|
180
|
-
options: COUNTRIES,
|
|
181
|
-
value
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
)),
|
|
185
|
-
field("delivery", "Delivery", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
186
|
-
import_input_select.default,
|
|
187
|
-
{
|
|
188
|
-
...{
|
|
189
|
-
onChange,
|
|
190
|
-
options: import_products.DELIVERY.map((item) => ({
|
|
191
|
-
label: (0, import_products.deliveryText)(item),
|
|
192
|
-
value: keyOf(item)
|
|
193
|
-
})),
|
|
194
|
-
value
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
)),
|
|
198
|
-
field("freeOver", "Free over", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
199
|
-
import_input_switch.default,
|
|
200
|
-
{
|
|
201
|
-
...{
|
|
202
|
-
"aria-label": "Free over",
|
|
203
|
-
onChange,
|
|
204
|
-
value: Boolean(value)
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
)),
|
|
208
|
-
watch("freeOver") && field("free", "Order amount", ({ onChange, value }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
209
|
-
import_input_number.default,
|
|
210
|
-
{
|
|
211
|
-
...{
|
|
212
|
-
min: 0,
|
|
213
|
-
onChange,
|
|
214
|
-
step: 0.01,
|
|
215
|
-
value: value ?? ""
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
), symbol)
|
|
219
|
-
]
|
|
220
|
-
}
|
|
221
|
-
),
|
|
222
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
-
import_fieldset.default,
|
|
224
|
-
{
|
|
225
|
-
...{
|
|
226
|
-
disabled: formState == null ? void 0 : formState.isSubmitting
|
|
227
|
-
},
|
|
228
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
229
|
-
import_button.default,
|
|
230
|
-
{
|
|
231
|
-
...{
|
|
232
|
-
loading: formState == null ? void 0 : formState.isSubmitting,
|
|
233
|
-
type: "submit"
|
|
234
|
-
},
|
|
235
|
-
children: "Submit"
|
|
236
|
-
}
|
|
237
|
-
)
|
|
238
|
-
}
|
|
239
|
-
)
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
-
};
|
|
244
|
-
const ShippingRates = ({ currency, manage, organization }) => {
|
|
245
|
-
var _a, _b, _c, _d;
|
|
246
|
-
const queryClient = (0, import_react_query.useQueryClient)();
|
|
247
|
-
const modal = (0, import_hooks.useModal)({
|
|
248
|
-
queryClient
|
|
249
|
-
});
|
|
250
|
-
const { onError, onSuccess } = (0, import_hooks.useCallbacks)({
|
|
251
|
-
queryClient
|
|
252
|
-
});
|
|
253
|
-
const confirm = (0, import_order_sections.useConfirm)();
|
|
254
|
-
const queryKey = ["rates", organization];
|
|
255
|
-
const base = "/organization/" + organization;
|
|
256
|
-
const listed = (0, import_react_query.useQuery)({
|
|
257
|
-
enabled: false,
|
|
258
|
-
queryKey: [...queryKey, 0]
|
|
259
|
-
});
|
|
260
|
-
const count = ((_b = (_a = listed.data) == null ? void 0 : _a.pageInfo) == null ? void 0 : _b.total) ?? ((_d = (_c = listed.data) == null ? void 0 : _c.items) == null ? void 0 : _d.length) ?? 0;
|
|
261
|
-
const saved = (response) => onSuccess(response, {
|
|
262
|
-
invalidate: [
|
|
263
|
-
{
|
|
264
|
-
queryKey
|
|
265
|
-
}
|
|
266
|
-
]
|
|
267
|
-
});
|
|
268
|
-
const money = (value) => (0, import_drawbridge_utils.formatCurrency)({ code: (currency || "usd").toUpperCase(), value });
|
|
269
|
-
const open = (rate) => modal.open({
|
|
270
|
-
message: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
271
|
-
FormRate,
|
|
272
|
-
{
|
|
273
|
-
...{
|
|
274
|
-
currency,
|
|
275
|
-
endpoint: (rate == null ? void 0 : rate.id) ? base + "/rate/" + rate.id : base + "/rates",
|
|
276
|
-
onError,
|
|
277
|
-
onSuccess: saved,
|
|
278
|
-
values: rate
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
),
|
|
282
|
-
title: (rate == null ? void 0 : rate.id) ? "Edit rate" : "New rate"
|
|
283
|
-
});
|
|
284
|
-
const remove = (rate) => confirm({
|
|
285
|
-
action: "Remove",
|
|
286
|
-
endpoint: base + "/rate/" + rate.id,
|
|
287
|
-
message: "Orders already placed keep the price they recorded.",
|
|
288
|
-
method: "DELETE",
|
|
289
|
-
onSuccess: saved,
|
|
290
|
-
title: "Remove shipping price"
|
|
291
|
-
});
|
|
292
|
-
const cta = count < import_products.MAX_RATES && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
293
|
-
import_button.default,
|
|
294
|
-
{
|
|
295
|
-
...{
|
|
296
|
-
"aria-label": "New rate",
|
|
297
|
-
disabled: !manage,
|
|
298
|
-
icon: import_plus.default,
|
|
299
|
-
inline: true,
|
|
300
|
-
onClick: () => open(),
|
|
301
|
-
size: "small",
|
|
302
|
-
variant: "secondary"
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
const columns = [
|
|
307
|
-
{
|
|
308
|
-
id: "name",
|
|
309
|
-
header: "Rate",
|
|
310
|
-
cell: ({ row }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
311
|
-
import_table_cell_title.default,
|
|
312
|
-
{
|
|
313
|
-
...{
|
|
314
|
-
subtitle: (0, import_products.deliveryText)(row.original.delivery),
|
|
315
|
-
title: row.original.name
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
),
|
|
319
|
-
sortable: false
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: "country",
|
|
323
|
-
header: "Country",
|
|
324
|
-
cell: ({ row }) => countryName(row.original.country),
|
|
325
|
-
sortable: false
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
id: "price",
|
|
329
|
-
header: "Price",
|
|
330
|
-
cell: ({ row }) => row.original.price ? money(row.original.price) : "Free",
|
|
331
|
-
sortable: false
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
id: "free",
|
|
335
|
-
header: "Free over",
|
|
336
|
-
cell: ({ row }) => Number.isFinite(row.original.free) ? money(row.original.free) : "\u2014",
|
|
337
|
-
sortable: false
|
|
338
|
-
}
|
|
339
|
-
];
|
|
340
|
-
const actions = (row) => ({
|
|
341
|
-
controls: [
|
|
342
|
-
{
|
|
343
|
-
"aria-label": "Edit " + row.name,
|
|
344
|
-
disabled: !manage,
|
|
345
|
-
element: "button",
|
|
346
|
-
icon: import_pencil.default,
|
|
347
|
-
onClick: () => open(row),
|
|
348
|
-
type: "button"
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
"aria-label": "Remove " + row.name,
|
|
352
|
-
disabled: !manage,
|
|
353
|
-
element: "button",
|
|
354
|
-
icon: import_trash.default,
|
|
355
|
-
onClick: () => remove(row),
|
|
356
|
-
type: "button"
|
|
357
|
-
}
|
|
358
|
-
]
|
|
359
|
-
});
|
|
360
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
361
|
-
import_card_section.default,
|
|
362
|
-
{
|
|
363
|
-
...{
|
|
364
|
-
className: "shrink-0",
|
|
365
|
-
cta,
|
|
366
|
-
title: "Shipping"
|
|
367
|
-
},
|
|
368
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
369
|
-
import_paged.default,
|
|
370
|
-
{
|
|
371
|
-
...{
|
|
372
|
-
empty: {
|
|
373
|
-
message: "No shipping prices",
|
|
374
|
-
variant: "secondary"
|
|
375
|
-
},
|
|
376
|
-
endpoint: base + "/rates",
|
|
377
|
-
params: {
|
|
378
|
-
limit: import_products.MAX_RATES,
|
|
379
|
-
sort: {
|
|
380
|
-
createdAt: 1
|
|
381
|
-
}
|
|
382
|
-
},
|
|
383
|
-
queryKey
|
|
384
|
-
},
|
|
385
|
-
children: ({ items }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
386
|
-
import_table.default,
|
|
387
|
-
{
|
|
388
|
-
...{
|
|
389
|
-
actions,
|
|
390
|
-
columns,
|
|
391
|
-
data: items
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
)
|
|
395
|
-
}
|
|
396
|
-
)
|
|
397
|
-
}
|
|
398
|
-
);
|
|
399
|
-
};
|
|
400
|
-
var shipping_rates_default = ShippingRates;
|
|
401
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
402
|
-
0 && (module.exports = {
|
|
403
|
-
FormRate
|
|
404
|
-
});
|