@drawbridge/components 0.1.14 → 0.1.15
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/form-subdomain-missions.js +77 -38
- package/dist/bridge/form-subdomain-missions.mjs +76 -38
- package/dist/dashboard/card-campaign-switch.js +55 -43
- package/dist/dashboard/card-campaign-switch.mjs +56 -44
- package/dist/dashboard/card-order.js +216 -31
- package/dist/dashboard/card-order.mjs +216 -31
- package/dist/dashboard/connection-workflows.js +13 -4
- package/dist/dashboard/connection-workflows.mjs +13 -4
- package/dist/dashboard/form-organization-campaign-field-select.js +51 -5
- package/dist/dashboard/form-organization-campaign-field-select.mjs +51 -5
- package/dist/dashboard/form-organization-campaign-field-textarea.js +46 -8
- package/dist/dashboard/form-organization-campaign-field-textarea.mjs +46 -8
- package/dist/dashboard/form-organization-campaign-section.js +24 -4
- package/dist/dashboard/form-organization-campaign-section.mjs +24 -4
- package/dist/dashboard/form-organization-workflow.js +222 -33
- package/dist/dashboard/form-organization-workflow.mjs +219 -33
- package/dist/input-code.js +35 -53
- package/dist/input-code.mjs +26 -54
- package/dist/shared/button.js +1 -1
- package/dist/shared/button.mjs +1 -1
- package/dist/shared/lib/campaign.js +9 -3
- package/dist/shared/lib/campaign.mjs +7 -2
- package/package.json +1 -1
- package/types/bridge/form-subdomain-missions.d.ts +3 -1
- package/types/dashboard/card-order.d.ts +15 -2
- package/types/dashboard/form-organization-campaign-section.d.ts +2 -0
- package/types/dashboard/form-organization-workflow.d.ts +13 -0
|
@@ -64,7 +64,7 @@ const ConnectionWorkflows = ({
|
|
|
64
64
|
className: "divide-y divide-gray"
|
|
65
65
|
},
|
|
66
66
|
children: items.map((row) => {
|
|
67
|
-
var _a, _b, _c;
|
|
67
|
+
var _a, _b, _c, _d;
|
|
68
68
|
const badge = statusBadge("workflow", row == null ? void 0 : row.status);
|
|
69
69
|
return /* @__PURE__ */ jsxs(
|
|
70
70
|
"div",
|
|
@@ -117,11 +117,20 @@ const ConnectionWorkflows = ({
|
|
|
117
117
|
},
|
|
118
118
|
children: workflowLine(row)
|
|
119
119
|
}
|
|
120
|
+
),
|
|
121
|
+
((_b = row == null ? void 0 : row.issue) == null ? void 0 : _b.message) && /* @__PURE__ */ jsx(
|
|
122
|
+
"p",
|
|
123
|
+
{
|
|
124
|
+
...{
|
|
125
|
+
className: "text-sm text-red-dark"
|
|
126
|
+
},
|
|
127
|
+
children: row.issue.message
|
|
128
|
+
}
|
|
120
129
|
)
|
|
121
130
|
]
|
|
122
131
|
}
|
|
123
132
|
),
|
|
124
|
-
(row == null ? void 0 : row.locked)
|
|
133
|
+
(row == null ? void 0 : row.locked) ? /* @__PURE__ */ jsx(
|
|
125
134
|
Badge,
|
|
126
135
|
{
|
|
127
136
|
...{
|
|
@@ -130,12 +139,12 @@ const ConnectionWorkflows = ({
|
|
|
130
139
|
},
|
|
131
140
|
children: "Locked"
|
|
132
141
|
}
|
|
133
|
-
) : view && /* @__PURE__ */ jsx(
|
|
142
|
+
) : view && ((_c = row == null ? void 0 : row.campaign) == null ? void 0 : _c.id) && /* @__PURE__ */ jsx(
|
|
134
143
|
Button,
|
|
135
144
|
{
|
|
136
145
|
...{
|
|
137
146
|
element: Link,
|
|
138
|
-
href: "/organizations/" + organization + "/campaigns/" + row.campaign.id + "/workflows/" + ((
|
|
147
|
+
href: "/organizations/" + organization + "/campaigns/" + row.campaign.id + "/workflows/" + ((_d = row == null ? void 0 : row.trigger) == null ? void 0 : _d.event),
|
|
139
148
|
inline: true,
|
|
140
149
|
onClick: drawer.close,
|
|
141
150
|
size: "small",
|
|
@@ -38,6 +38,7 @@ var import_form2 = __toESM(require("../shared/form"));
|
|
|
38
38
|
var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
39
39
|
var import_input_group = __toESM(require("../input-group"));
|
|
40
40
|
var import_input_text = __toESM(require("../input-text"));
|
|
41
|
+
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
41
42
|
var import_input_array = require("./input-array");
|
|
42
43
|
var import_trash = __toESM(require("../icons/trash"));
|
|
43
44
|
var import_button = __toESM(require("../shared/button"));
|
|
@@ -47,14 +48,18 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
47
48
|
onSuccess,
|
|
48
49
|
values
|
|
49
50
|
}) => {
|
|
50
|
-
var _a, _b, _c;
|
|
51
|
+
var _a, _b, _c, _d;
|
|
51
52
|
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
53
|
+
const pickup = (values == null ? void 0 : values.slug) === "pickup";
|
|
52
54
|
const option = import_yup.default.object({
|
|
53
55
|
option: import_yup.default.string().label("Option value").required().max(150)
|
|
54
56
|
});
|
|
55
57
|
const { clearErrors, control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
56
58
|
resolver: (0, import_yup.resolver)(
|
|
57
59
|
import_yup.default.object({
|
|
60
|
+
attributes: import_yup.default.object({
|
|
61
|
+
required: import_yup.default.boolean()
|
|
62
|
+
}),
|
|
58
63
|
label: import_yup.default.string().label("Label").required().max(150),
|
|
59
64
|
settings: import_yup.default.object({
|
|
60
65
|
options: import_yup.default.array().label("Options").required().min(2).max(10).of(option).test(
|
|
@@ -68,9 +73,17 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
68
73
|
})
|
|
69
74
|
})
|
|
70
75
|
),
|
|
71
|
-
values
|
|
76
|
+
values: {
|
|
77
|
+
...values,
|
|
78
|
+
...pickup && {
|
|
79
|
+
attributes: {
|
|
80
|
+
required: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.required) !== false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
72
84
|
});
|
|
73
85
|
const onSubmit = async ({
|
|
86
|
+
attributes,
|
|
74
87
|
label,
|
|
75
88
|
settings = {}
|
|
76
89
|
}) => {
|
|
@@ -78,6 +91,11 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
78
91
|
const isPrize = Boolean(values == null ? void 0 : values.prize);
|
|
79
92
|
const args = {
|
|
80
93
|
body: {
|
|
94
|
+
...pickup && {
|
|
95
|
+
attributes: {
|
|
96
|
+
required: Boolean(attributes == null ? void 0 : attributes.required)
|
|
97
|
+
}
|
|
98
|
+
},
|
|
81
99
|
label,
|
|
82
100
|
settings,
|
|
83
101
|
slug: values == null ? void 0 : values.slug,
|
|
@@ -146,7 +164,7 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
146
164
|
import_input_group.default,
|
|
147
165
|
{
|
|
148
166
|
...{
|
|
149
|
-
error: (
|
|
167
|
+
error: (_d = (_c = (_b = formState == null ? void 0 : formState.errors) == null ? void 0 : _b.settings) == null ? void 0 : _c.options) == null ? void 0 : _d.message,
|
|
150
168
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
151
169
|
import_input_array.InputArraySortable,
|
|
152
170
|
{
|
|
@@ -198,12 +216,12 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
198
216
|
control,
|
|
199
217
|
name: `settings.options.${index}.option`,
|
|
200
218
|
render: ({ field: { value, onChange } }) => {
|
|
201
|
-
var _a2, _b2, _c2,
|
|
219
|
+
var _a2, _b2, _c2, _d2, _e;
|
|
202
220
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
203
221
|
import_input_group.default,
|
|
204
222
|
{
|
|
205
223
|
...{
|
|
206
|
-
error: (_e = (
|
|
224
|
+
error: (_e = (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.settings) == null ? void 0 : _b2.options) == null ? void 0 : _c2[index]) == null ? void 0 : _d2.option) == null ? void 0 : _e.message,
|
|
207
225
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
208
226
|
import_input_text.default,
|
|
209
227
|
{
|
|
@@ -229,6 +247,34 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
229
247
|
label: "Options"
|
|
230
248
|
}
|
|
231
249
|
}
|
|
250
|
+
),
|
|
251
|
+
pickup && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
252
|
+
import_form.Controller,
|
|
253
|
+
{
|
|
254
|
+
...{
|
|
255
|
+
control,
|
|
256
|
+
name: "attributes.required",
|
|
257
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
258
|
+
import_input_group.default,
|
|
259
|
+
{
|
|
260
|
+
...{
|
|
261
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
262
|
+
import_input_switch.default,
|
|
263
|
+
{
|
|
264
|
+
...{
|
|
265
|
+
disabled: !inputs.includes("attributes"),
|
|
266
|
+
onChange,
|
|
267
|
+
value: Boolean(value)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
label: "Required",
|
|
272
|
+
message: "Off, a visitor can order without picking one."
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
}
|
|
232
278
|
)
|
|
233
279
|
]
|
|
234
280
|
}
|
|
@@ -6,6 +6,7 @@ import Form from "../shared/form.mjs";
|
|
|
6
6
|
import Fieldset from "../shared/fieldset.mjs";
|
|
7
7
|
import InputGroup from "../input-group.mjs";
|
|
8
8
|
import InputText from "../input-text.mjs";
|
|
9
|
+
import InputSwitch from "../shared/input-switch.mjs";
|
|
9
10
|
import { InputArrayButton, InputArrayControl, InputArraySortable } from "./input-array.mjs";
|
|
10
11
|
import Trash from "../icons/trash.mjs";
|
|
11
12
|
import Button from "../shared/button.mjs";
|
|
@@ -15,14 +16,18 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
15
16
|
onSuccess,
|
|
16
17
|
values
|
|
17
18
|
}) => {
|
|
18
|
-
var _a, _b, _c;
|
|
19
|
+
var _a, _b, _c, _d;
|
|
19
20
|
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
21
|
+
const pickup = (values == null ? void 0 : values.slug) === "pickup";
|
|
20
22
|
const option = yup.object({
|
|
21
23
|
option: yup.string().label("Option value").required().max(150)
|
|
22
24
|
});
|
|
23
25
|
const { clearErrors, control, formState, handleSubmit } = useForm({
|
|
24
26
|
resolver: resolver(
|
|
25
27
|
yup.object({
|
|
28
|
+
attributes: yup.object({
|
|
29
|
+
required: yup.boolean()
|
|
30
|
+
}),
|
|
26
31
|
label: yup.string().label("Label").required().max(150),
|
|
27
32
|
settings: yup.object({
|
|
28
33
|
options: yup.array().label("Options").required().min(2).max(10).of(option).test(
|
|
@@ -36,9 +41,17 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
36
41
|
})
|
|
37
42
|
})
|
|
38
43
|
),
|
|
39
|
-
values
|
|
44
|
+
values: {
|
|
45
|
+
...values,
|
|
46
|
+
...pickup && {
|
|
47
|
+
attributes: {
|
|
48
|
+
required: ((_a = values == null ? void 0 : values.attributes) == null ? void 0 : _a.required) !== false
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
});
|
|
41
53
|
const onSubmit = async ({
|
|
54
|
+
attributes,
|
|
42
55
|
label,
|
|
43
56
|
settings = {}
|
|
44
57
|
}) => {
|
|
@@ -46,6 +59,11 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
46
59
|
const isPrize = Boolean(values == null ? void 0 : values.prize);
|
|
47
60
|
const args = {
|
|
48
61
|
body: {
|
|
62
|
+
...pickup && {
|
|
63
|
+
attributes: {
|
|
64
|
+
required: Boolean(attributes == null ? void 0 : attributes.required)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
49
67
|
label,
|
|
50
68
|
settings,
|
|
51
69
|
slug: values == null ? void 0 : values.slug,
|
|
@@ -114,7 +132,7 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
114
132
|
InputGroup,
|
|
115
133
|
{
|
|
116
134
|
...{
|
|
117
|
-
error: (
|
|
135
|
+
error: (_d = (_c = (_b = formState == null ? void 0 : formState.errors) == null ? void 0 : _b.settings) == null ? void 0 : _c.options) == null ? void 0 : _d.message,
|
|
118
136
|
input: /* @__PURE__ */ jsx(
|
|
119
137
|
InputArraySortable,
|
|
120
138
|
{
|
|
@@ -166,12 +184,12 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
166
184
|
control,
|
|
167
185
|
name: `settings.options.${index}.option`,
|
|
168
186
|
render: ({ field: { value, onChange } }) => {
|
|
169
|
-
var _a2, _b2, _c2,
|
|
187
|
+
var _a2, _b2, _c2, _d2, _e;
|
|
170
188
|
return /* @__PURE__ */ jsx(
|
|
171
189
|
InputGroup,
|
|
172
190
|
{
|
|
173
191
|
...{
|
|
174
|
-
error: (_e = (
|
|
192
|
+
error: (_e = (_d2 = (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.settings) == null ? void 0 : _b2.options) == null ? void 0 : _c2[index]) == null ? void 0 : _d2.option) == null ? void 0 : _e.message,
|
|
175
193
|
input: /* @__PURE__ */ jsx(
|
|
176
194
|
InputText,
|
|
177
195
|
{
|
|
@@ -197,6 +215,34 @@ const FormOrganizationCampaignFieldSelect = ({
|
|
|
197
215
|
label: "Options"
|
|
198
216
|
}
|
|
199
217
|
}
|
|
218
|
+
),
|
|
219
|
+
pickup && /* @__PURE__ */ jsx(
|
|
220
|
+
Controller,
|
|
221
|
+
{
|
|
222
|
+
...{
|
|
223
|
+
control,
|
|
224
|
+
name: "attributes.required",
|
|
225
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
|
|
226
|
+
InputGroup,
|
|
227
|
+
{
|
|
228
|
+
...{
|
|
229
|
+
input: /* @__PURE__ */ jsx(
|
|
230
|
+
InputSwitch,
|
|
231
|
+
{
|
|
232
|
+
...{
|
|
233
|
+
disabled: !inputs.includes("attributes"),
|
|
234
|
+
onChange,
|
|
235
|
+
value: Boolean(value)
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
label: "Required",
|
|
240
|
+
message: "Off, a visitor can order without picking one."
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
}
|
|
200
246
|
)
|
|
201
247
|
]
|
|
202
248
|
}
|
|
@@ -39,6 +39,7 @@ var import_fieldset = __toESM(require("../shared/fieldset"));
|
|
|
39
39
|
var import_input_group = __toESM(require("../input-group"));
|
|
40
40
|
var import_input_text = __toESM(require("../input-text"));
|
|
41
41
|
var import_input_number = __toESM(require("../input-number"));
|
|
42
|
+
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
42
43
|
var import_button = __toESM(require("../shared/button"));
|
|
43
44
|
const defaultValues = {
|
|
44
45
|
attributes: {
|
|
@@ -52,13 +53,15 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
52
53
|
onSuccess,
|
|
53
54
|
values
|
|
54
55
|
}) => {
|
|
55
|
-
var _a;
|
|
56
|
+
var _a, _b;
|
|
56
57
|
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
58
|
+
const note = (values == null ? void 0 : values.slug) === "note";
|
|
57
59
|
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
58
60
|
resolver: (0, import_yup.resolver)(
|
|
59
61
|
import_yup.default.object({
|
|
60
62
|
attributes: import_yup.default.object({
|
|
61
63
|
max: import_yup.default.number().label("Max length").transform((value) => Number(value || 0)).min(1).max((_a = defaultValues == null ? void 0 : defaultValues.attributes) == null ? void 0 : _a.max),
|
|
64
|
+
required: import_yup.default.boolean(),
|
|
62
65
|
rows: import_yup.default.number().label("Rows").required().min(1).max(6)
|
|
63
66
|
}),
|
|
64
67
|
label: import_yup.default.string().label("Label").required().max(150)
|
|
@@ -66,7 +69,14 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
66
69
|
),
|
|
67
70
|
values: {
|
|
68
71
|
...defaultValues,
|
|
69
|
-
...values
|
|
72
|
+
...values,
|
|
73
|
+
...note && {
|
|
74
|
+
attributes: {
|
|
75
|
+
...defaultValues.attributes,
|
|
76
|
+
...values == null ? void 0 : values.attributes,
|
|
77
|
+
required: ((_b = values == null ? void 0 : values.attributes) == null ? void 0 : _b.required) === true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
70
80
|
}
|
|
71
81
|
});
|
|
72
82
|
const onSubmit = async ({
|
|
@@ -118,12 +128,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
118
128
|
control,
|
|
119
129
|
name: "label",
|
|
120
130
|
render: ({ field: { value, onChange } }) => {
|
|
121
|
-
var _a2,
|
|
131
|
+
var _a2, _b2;
|
|
122
132
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
123
133
|
import_input_group.default,
|
|
124
134
|
{
|
|
125
135
|
...{
|
|
126
|
-
error: (
|
|
136
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b2.message,
|
|
127
137
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
128
138
|
import_input_text.default,
|
|
129
139
|
{
|
|
@@ -149,12 +159,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
149
159
|
control,
|
|
150
160
|
name: "attributes.max",
|
|
151
161
|
render: ({ field: { value, onChange } }) => {
|
|
152
|
-
var _a2,
|
|
162
|
+
var _a2, _b2, _c;
|
|
153
163
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
154
164
|
import_input_group.default,
|
|
155
165
|
{
|
|
156
166
|
...{
|
|
157
|
-
error: (_c = (
|
|
167
|
+
error: (_c = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.max) == null ? void 0 : _c.message,
|
|
158
168
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
159
169
|
import_input_number.default,
|
|
160
170
|
{
|
|
@@ -182,12 +192,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
182
192
|
control,
|
|
183
193
|
name: "attributes.rows",
|
|
184
194
|
render: ({ field: { value, onChange } }) => {
|
|
185
|
-
var _a2,
|
|
195
|
+
var _a2, _b2, _c;
|
|
186
196
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
187
197
|
import_input_group.default,
|
|
188
198
|
{
|
|
189
199
|
...{
|
|
190
|
-
error: (_c = (
|
|
200
|
+
error: (_c = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.rows) == null ? void 0 : _c.message,
|
|
191
201
|
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
202
|
import_input_number.default,
|
|
193
203
|
{
|
|
@@ -207,6 +217,34 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
207
217
|
}
|
|
208
218
|
}
|
|
209
219
|
}
|
|
220
|
+
),
|
|
221
|
+
note && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
222
|
+
import_form.Controller,
|
|
223
|
+
{
|
|
224
|
+
...{
|
|
225
|
+
control,
|
|
226
|
+
name: "attributes.required",
|
|
227
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
228
|
+
import_input_group.default,
|
|
229
|
+
{
|
|
230
|
+
...{
|
|
231
|
+
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
232
|
+
import_input_switch.default,
|
|
233
|
+
{
|
|
234
|
+
...{
|
|
235
|
+
disabled: !inputs.includes("attributes"),
|
|
236
|
+
onChange,
|
|
237
|
+
value: Boolean(value)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
label: "Required",
|
|
242
|
+
message: "On, a visitor must fill it in to order."
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
210
248
|
)
|
|
211
249
|
]
|
|
212
250
|
}
|
|
@@ -7,6 +7,7 @@ import Fieldset from "../shared/fieldset.mjs";
|
|
|
7
7
|
import InputGroup from "../input-group.mjs";
|
|
8
8
|
import InputText from "../input-text.mjs";
|
|
9
9
|
import InputNumber from "../input-number.mjs";
|
|
10
|
+
import InputSwitch from "../shared/input-switch.mjs";
|
|
10
11
|
import Button from "../shared/button.mjs";
|
|
11
12
|
const defaultValues = {
|
|
12
13
|
attributes: {
|
|
@@ -20,13 +21,15 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
20
21
|
onSuccess,
|
|
21
22
|
values
|
|
22
23
|
}) => {
|
|
23
|
-
var _a;
|
|
24
|
+
var _a, _b;
|
|
24
25
|
const inputs = (values == null ? void 0 : values.inputs) || [];
|
|
26
|
+
const note = (values == null ? void 0 : values.slug) === "note";
|
|
25
27
|
const { control, formState, handleSubmit } = useForm({
|
|
26
28
|
resolver: resolver(
|
|
27
29
|
yup.object({
|
|
28
30
|
attributes: yup.object({
|
|
29
31
|
max: yup.number().label("Max length").transform((value) => Number(value || 0)).min(1).max((_a = defaultValues == null ? void 0 : defaultValues.attributes) == null ? void 0 : _a.max),
|
|
32
|
+
required: yup.boolean(),
|
|
30
33
|
rows: yup.number().label("Rows").required().min(1).max(6)
|
|
31
34
|
}),
|
|
32
35
|
label: yup.string().label("Label").required().max(150)
|
|
@@ -34,7 +37,14 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
34
37
|
),
|
|
35
38
|
values: {
|
|
36
39
|
...defaultValues,
|
|
37
|
-
...values
|
|
40
|
+
...values,
|
|
41
|
+
...note && {
|
|
42
|
+
attributes: {
|
|
43
|
+
...defaultValues.attributes,
|
|
44
|
+
...values == null ? void 0 : values.attributes,
|
|
45
|
+
required: ((_b = values == null ? void 0 : values.attributes) == null ? void 0 : _b.required) === true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
});
|
|
40
50
|
const onSubmit = async ({
|
|
@@ -86,12 +96,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
86
96
|
control,
|
|
87
97
|
name: "label",
|
|
88
98
|
render: ({ field: { value, onChange } }) => {
|
|
89
|
-
var _a2,
|
|
99
|
+
var _a2, _b2;
|
|
90
100
|
return /* @__PURE__ */ jsx(
|
|
91
101
|
InputGroup,
|
|
92
102
|
{
|
|
93
103
|
...{
|
|
94
|
-
error: (
|
|
104
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.label) == null ? void 0 : _b2.message,
|
|
95
105
|
input: /* @__PURE__ */ jsx(
|
|
96
106
|
InputText,
|
|
97
107
|
{
|
|
@@ -117,12 +127,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
117
127
|
control,
|
|
118
128
|
name: "attributes.max",
|
|
119
129
|
render: ({ field: { value, onChange } }) => {
|
|
120
|
-
var _a2,
|
|
130
|
+
var _a2, _b2, _c;
|
|
121
131
|
return /* @__PURE__ */ jsx(
|
|
122
132
|
InputGroup,
|
|
123
133
|
{
|
|
124
134
|
...{
|
|
125
|
-
error: (_c = (
|
|
135
|
+
error: (_c = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.max) == null ? void 0 : _c.message,
|
|
126
136
|
input: /* @__PURE__ */ jsx(
|
|
127
137
|
InputNumber,
|
|
128
138
|
{
|
|
@@ -150,12 +160,12 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
150
160
|
control,
|
|
151
161
|
name: "attributes.rows",
|
|
152
162
|
render: ({ field: { value, onChange } }) => {
|
|
153
|
-
var _a2,
|
|
163
|
+
var _a2, _b2, _c;
|
|
154
164
|
return /* @__PURE__ */ jsx(
|
|
155
165
|
InputGroup,
|
|
156
166
|
{
|
|
157
167
|
...{
|
|
158
|
-
error: (_c = (
|
|
168
|
+
error: (_c = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.attributes) == null ? void 0 : _b2.rows) == null ? void 0 : _c.message,
|
|
159
169
|
input: /* @__PURE__ */ jsx(
|
|
160
170
|
InputNumber,
|
|
161
171
|
{
|
|
@@ -175,6 +185,34 @@ const FormOrganizationCampaignFieldTextarea = ({
|
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
}
|
|
188
|
+
),
|
|
189
|
+
note && /* @__PURE__ */ jsx(
|
|
190
|
+
Controller,
|
|
191
|
+
{
|
|
192
|
+
...{
|
|
193
|
+
control,
|
|
194
|
+
name: "attributes.required",
|
|
195
|
+
render: ({ field: { value, onChange } }) => /* @__PURE__ */ jsx(
|
|
196
|
+
InputGroup,
|
|
197
|
+
{
|
|
198
|
+
...{
|
|
199
|
+
input: /* @__PURE__ */ jsx(
|
|
200
|
+
InputSwitch,
|
|
201
|
+
{
|
|
202
|
+
...{
|
|
203
|
+
disabled: !inputs.includes("attributes"),
|
|
204
|
+
onChange,
|
|
205
|
+
value: Boolean(value)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
),
|
|
209
|
+
label: "Required",
|
|
210
|
+
message: "On, a visitor must fill it in to order."
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
178
216
|
)
|
|
179
217
|
]
|
|
180
218
|
}
|
|
@@ -41,6 +41,7 @@ var import_input_text = __toESM(require("../input-text"));
|
|
|
41
41
|
var import_input_textarea = __toESM(require("../input-textarea"));
|
|
42
42
|
var import_input_switch = __toESM(require("../shared/input-switch"));
|
|
43
43
|
var import_button = __toESM(require("../shared/button"));
|
|
44
|
+
var import_tooltip = __toESM(require("../shared/tooltip"));
|
|
44
45
|
const FormOrganizationCampaignSection = ({
|
|
45
46
|
disabled,
|
|
46
47
|
onError,
|
|
@@ -49,6 +50,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
49
50
|
}) => {
|
|
50
51
|
var _a;
|
|
51
52
|
const order = (values == null ? void 0 : values.type) === "order";
|
|
53
|
+
const locked = order && (values == null ? void 0 : values.giveaway) ? "Turn off the giveaway to take orders" : null;
|
|
52
54
|
const { control, formState, handleSubmit } = (0, import_form.useForm)({
|
|
53
55
|
resolver: (0, import_yup.resolver)(
|
|
54
56
|
import_yup.default.object({
|
|
@@ -76,7 +78,9 @@ const FormOrganizationCampaignSection = ({
|
|
|
76
78
|
body: {
|
|
77
79
|
description: description || null,
|
|
78
80
|
...order && {
|
|
79
|
-
|
|
81
|
+
...!locked && {
|
|
82
|
+
enabled
|
|
83
|
+
},
|
|
80
84
|
prices
|
|
81
85
|
},
|
|
82
86
|
title
|
|
@@ -89,7 +93,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
89
93
|
onError(error);
|
|
90
94
|
}
|
|
91
95
|
};
|
|
92
|
-
const toggle = (key, label, message) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
const toggle = (key, label, message, lock) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
93
97
|
import_form.Controller,
|
|
94
98
|
{
|
|
95
99
|
...{
|
|
@@ -99,7 +103,23 @@ const FormOrganizationCampaignSection = ({
|
|
|
99
103
|
import_input_group.default,
|
|
100
104
|
{
|
|
101
105
|
...{
|
|
102
|
-
input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
106
|
+
input: lock ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
107
|
+
import_tooltip.default,
|
|
108
|
+
{
|
|
109
|
+
...{
|
|
110
|
+
content: lock
|
|
111
|
+
},
|
|
112
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
113
|
+
import_input_switch.default,
|
|
114
|
+
{
|
|
115
|
+
...{
|
|
116
|
+
disabled: true,
|
|
117
|
+
value: false
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
103
123
|
import_input_switch.default,
|
|
104
124
|
{
|
|
105
125
|
...{
|
|
@@ -193,7 +213,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
193
213
|
}
|
|
194
214
|
}
|
|
195
215
|
),
|
|
196
|
-
order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept."),
|
|
216
|
+
order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept.", locked),
|
|
197
217
|
order && toggle("prices", "Show prices", "Show each item's price and an estimated total.")
|
|
198
218
|
]
|
|
199
219
|
}
|
|
@@ -9,6 +9,7 @@ import InputText from "../input-text.mjs";
|
|
|
9
9
|
import InputTextarea from "../input-textarea.mjs";
|
|
10
10
|
import InputSwitch from "../shared/input-switch.mjs";
|
|
11
11
|
import Button from "../shared/button.mjs";
|
|
12
|
+
import Tooltip from "../shared/tooltip.mjs";
|
|
12
13
|
const FormOrganizationCampaignSection = ({
|
|
13
14
|
disabled,
|
|
14
15
|
onError,
|
|
@@ -17,6 +18,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
17
18
|
}) => {
|
|
18
19
|
var _a;
|
|
19
20
|
const order = (values == null ? void 0 : values.type) === "order";
|
|
21
|
+
const locked = order && (values == null ? void 0 : values.giveaway) ? "Turn off the giveaway to take orders" : null;
|
|
20
22
|
const { control, formState, handleSubmit } = useForm({
|
|
21
23
|
resolver: resolver(
|
|
22
24
|
yup.object({
|
|
@@ -44,7 +46,9 @@ const FormOrganizationCampaignSection = ({
|
|
|
44
46
|
body: {
|
|
45
47
|
description: description || null,
|
|
46
48
|
...order && {
|
|
47
|
-
|
|
49
|
+
...!locked && {
|
|
50
|
+
enabled
|
|
51
|
+
},
|
|
48
52
|
prices
|
|
49
53
|
},
|
|
50
54
|
title
|
|
@@ -57,7 +61,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
57
61
|
onError(error);
|
|
58
62
|
}
|
|
59
63
|
};
|
|
60
|
-
const toggle = (key, label, message) => /* @__PURE__ */ jsx(
|
|
64
|
+
const toggle = (key, label, message, lock) => /* @__PURE__ */ jsx(
|
|
61
65
|
Controller,
|
|
62
66
|
{
|
|
63
67
|
...{
|
|
@@ -67,7 +71,23 @@ const FormOrganizationCampaignSection = ({
|
|
|
67
71
|
InputGroup,
|
|
68
72
|
{
|
|
69
73
|
...{
|
|
70
|
-
input: /* @__PURE__ */ jsx(
|
|
74
|
+
input: lock ? /* @__PURE__ */ jsx(
|
|
75
|
+
Tooltip,
|
|
76
|
+
{
|
|
77
|
+
...{
|
|
78
|
+
content: lock
|
|
79
|
+
},
|
|
80
|
+
children: /* @__PURE__ */ jsx(
|
|
81
|
+
InputSwitch,
|
|
82
|
+
{
|
|
83
|
+
...{
|
|
84
|
+
disabled: true,
|
|
85
|
+
value: false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
) : /* @__PURE__ */ jsx(
|
|
71
91
|
InputSwitch,
|
|
72
92
|
{
|
|
73
93
|
...{
|
|
@@ -161,7 +181,7 @@ const FormOrganizationCampaignSection = ({
|
|
|
161
181
|
}
|
|
162
182
|
}
|
|
163
183
|
),
|
|
164
|
-
order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept."),
|
|
184
|
+
order && toggle("enabled", "Take orders", "Off, the form skips this section. Everything here is kept.", locked),
|
|
165
185
|
order && toggle("prices", "Show prices", "Show each item's price and an estimated total.")
|
|
166
186
|
]
|
|
167
187
|
}
|