@drawbridge/components 0.1.13 → 0.1.14
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/components/styles.css +364 -2
- package/dist/advertisement.js +3 -1
- package/dist/advertisement.mjs +3 -1
- package/dist/bridge/advertisements.js +2 -0
- package/dist/bridge/advertisements.mjs +2 -0
- package/dist/bridge/countdown.js +2 -1
- package/dist/bridge/countdown.mjs +2 -1
- package/dist/bridge/form-subdomain-embed.js +18 -20
- package/dist/bridge/form-subdomain-embed.mjs +18 -20
- package/dist/bridge/form-subdomain-header.js +24 -1
- package/dist/bridge/form-subdomain-header.mjs +24 -1
- package/dist/bridge/form-subdomain-missions.js +538 -0
- package/dist/bridge/form-subdomain-missions.mjs +502 -0
- package/dist/bridge/form-subdomain.js +530 -220
- package/dist/bridge/form-subdomain.mjs +533 -222
- package/dist/bridge/lib/entry.js +59 -0
- package/dist/bridge/lib/entry.mjs +29 -0
- package/dist/bridge/lib/location.js +38 -0
- package/dist/bridge/lib/location.mjs +13 -0
- package/dist/bridge/lib/order.js +71 -0
- package/dist/bridge/lib/order.mjs +44 -0
- package/dist/bridge/lib/url.js +9 -0
- package/dist/bridge/lib/url.mjs +7 -0
- package/dist/bridge/share-button.js +5 -3
- package/dist/bridge/share-button.mjs +5 -3
- package/dist/bridge/subdomain-content.js +7 -6
- package/dist/bridge/subdomain-content.mjs +7 -6
- package/dist/bridge/template-layout.js +59 -21
- package/dist/bridge/template-layout.mjs +59 -21
- package/dist/bridge/template-modal.js +42 -76
- package/dist/bridge/template-modal.mjs +39 -73
- package/dist/bridge/template-preview.js +208 -0
- package/dist/bridge/template-preview.mjs +173 -0
- package/dist/bridge/template-subdomain-gallery.js +6 -2
- package/dist/bridge/template-subdomain-gallery.mjs +6 -2
- package/dist/bridge/template-subdomain-link.js +6 -1
- package/dist/bridge/template-subdomain-link.mjs +6 -1
- package/dist/bridge/template-subdomain.js +20 -15
- package/dist/bridge/template-subdomain.mjs +20 -15
- package/dist/dashboard/accordion.js +74 -39
- package/dist/dashboard/accordion.mjs +74 -39
- package/dist/dashboard/avatar.js +109 -3
- package/dist/dashboard/avatar.mjs +106 -4
- package/dist/dashboard/buttons-subscription.js +384 -0
- package/dist/dashboard/buttons-subscription.mjs +349 -0
- package/dist/dashboard/card-campaign-switch.js +265 -0
- package/dist/dashboard/card-campaign-switch.mjs +231 -0
- package/dist/dashboard/card-order.js +28 -11
- package/dist/dashboard/card-order.mjs +28 -11
- package/dist/dashboard/card-section.js +26 -2
- package/dist/dashboard/card-section.mjs +26 -2
- package/dist/dashboard/card-tile.js +6 -7
- package/dist/dashboard/card-tile.mjs +6 -7
- package/dist/dashboard/connection-workflows.js +196 -0
- package/dist/dashboard/connection-workflows.mjs +162 -0
- package/dist/dashboard/device.js +95 -0
- package/dist/dashboard/device.mjs +72 -0
- package/dist/dashboard/form-admin-campaign.js +19 -50
- package/dist/dashboard/form-admin-campaign.mjs +20 -51
- package/dist/dashboard/form-ai.js +9 -6
- package/dist/dashboard/form-ai.mjs +9 -6
- package/dist/dashboard/form-auth.js +35 -25
- package/dist/dashboard/form-auth.mjs +36 -26
- package/dist/dashboard/form-file.js +10 -1
- package/dist/dashboard/form-file.mjs +10 -1
- package/dist/dashboard/form-filters-analytics.js +14 -1
- package/dist/dashboard/form-filters-analytics.mjs +15 -2
- package/dist/dashboard/form-organization-campaign-advertisement.js +15 -1
- package/dist/dashboard/form-organization-campaign-advertisement.mjs +16 -2
- package/dist/dashboard/form-organization-campaign-agreement.js +215 -164
- package/dist/dashboard/form-organization-campaign-agreement.mjs +215 -164
- package/dist/dashboard/form-organization-campaign-field-email.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-email.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-list.js +466 -0
- package/dist/dashboard/form-organization-campaign-field-list.mjs +437 -0
- package/dist/dashboard/form-organization-campaign-field-phone.js +0 -34
- package/dist/dashboard/form-organization-campaign-field-phone.mjs +0 -34
- package/dist/dashboard/form-organization-campaign-field-remove.js +66 -0
- package/dist/dashboard/form-organization-campaign-field-remove.mjs +33 -0
- package/dist/dashboard/form-organization-campaign-integration-age.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-age.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-enable.js +52 -24
- package/dist/dashboard/form-organization-campaign-integration-enable.mjs +54 -26
- package/dist/dashboard/form-organization-campaign-integration-geocode.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-geocode.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.js +6 -12
- package/dist/dashboard/form-organization-campaign-integration-gtm.mjs +6 -12
- package/dist/dashboard/form-organization-campaign-link.js +7 -1
- package/dist/dashboard/form-organization-campaign-link.mjs +7 -1
- package/dist/dashboard/form-organization-campaign-mission.js +291 -0
- package/dist/dashboard/form-organization-campaign-mission.mjs +258 -0
- package/dist/dashboard/form-organization-campaign-page-embed.js +13 -2
- package/dist/dashboard/form-organization-campaign-page-embed.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-page.js +20 -11
- package/dist/dashboard/form-organization-campaign-page.mjs +20 -11
- package/dist/dashboard/form-organization-campaign-prize-edit.js +12 -1
- package/dist/dashboard/form-organization-campaign-prize-edit.mjs +12 -1
- package/dist/dashboard/form-organization-campaign-section.js +223 -0
- package/dist/dashboard/form-organization-campaign-section.mjs +194 -0
- package/dist/dashboard/form-organization-campaign.js +114 -469
- package/dist/dashboard/form-organization-campaign.mjs +113 -467
- package/dist/dashboard/form-organization-export.js +4 -7
- package/dist/dashboard/form-organization-export.mjs +4 -7
- package/dist/dashboard/form-organization-identity.js +46 -51
- package/dist/dashboard/form-organization-identity.mjs +46 -51
- package/dist/dashboard/form-organization-workflow.js +518 -686
- package/dist/dashboard/form-organization-workflow.mjs +517 -682
- package/dist/dashboard/form-organization.js +82 -110
- package/dist/dashboard/form-organization.mjs +81 -109
- package/dist/dashboard/form-otc.js +4 -5
- package/dist/dashboard/form-otc.mjs +4 -5
- package/dist/dashboard/form-payment-methods.js +20 -9
- package/dist/dashboard/form-payment-methods.mjs +20 -9
- package/dist/dashboard/form-stripe.js +30 -0
- package/dist/dashboard/form-stripe.mjs +26 -0
- package/dist/dashboard/input-array.js +4 -2
- package/dist/dashboard/input-array.mjs +4 -2
- package/dist/dashboard/input-combobox.js +7 -3
- package/dist/dashboard/input-combobox.mjs +7 -3
- package/dist/dashboard/input-date.js +7 -0
- package/dist/dashboard/input-date.mjs +7 -0
- package/dist/dashboard/input-fields.js +80 -20
- package/dist/dashboard/input-fields.mjs +80 -20
- package/dist/dashboard/input-file.js +21 -1
- package/dist/dashboard/input-file.mjs +21 -1
- package/dist/dashboard/input-font.js +10 -1
- package/dist/dashboard/input-font.mjs +10 -1
- package/dist/dashboard/lib/item-list.js +57 -0
- package/dist/dashboard/lib/item-list.mjs +33 -0
- package/dist/dashboard/lib/menu.js +50 -0
- package/dist/dashboard/lib/menu.mjs +26 -0
- package/dist/dashboard/locked.js +82 -0
- package/dist/dashboard/locked.mjs +53 -0
- package/dist/dashboard/menu.js +72 -19
- package/dist/dashboard/menu.mjs +72 -19
- package/dist/dashboard/note-ai.js +69 -0
- package/dist/dashboard/note-ai.mjs +36 -0
- package/dist/dashboard/preview.js +419 -0
- package/dist/dashboard/preview.mjs +384 -0
- package/dist/dashboard/steps.js +39 -13
- package/dist/dashboard/steps.mjs +37 -12
- package/dist/dashboard/table-contacts.js +136 -0
- package/dist/dashboard/table-contacts.mjs +103 -0
- package/dist/dashboard/template-not-found.js +4 -2
- package/dist/dashboard/template-not-found.mjs +4 -2
- package/dist/dashboard/template-socket.js +20 -7
- package/dist/dashboard/template-socket.mjs +20 -7
- package/dist/icons/desktop.js +46 -0
- package/dist/icons/desktop.mjs +27 -0
- package/dist/icons/phone.js +46 -0
- package/dist/icons/phone.mjs +27 -0
- package/dist/icons/puzzle-piece.js +46 -0
- package/dist/icons/puzzle-piece.mjs +27 -0
- package/dist/icons/tablet.js +46 -0
- package/dist/icons/tablet.mjs +27 -0
- package/dist/icons/users.js +46 -0
- package/dist/icons/users.mjs +27 -0
- package/dist/input-checkbox.js +1 -0
- package/dist/input-checkbox.mjs +1 -0
- package/dist/input-code.js +101 -0
- package/dist/input-code.mjs +78 -0
- package/dist/input-text.js +2 -1
- package/dist/input-text.mjs +2 -1
- package/dist/shared/input-checkbox-list.js +0 -1
- package/dist/shared/input-checkbox-list.mjs +0 -1
- package/dist/shared/input-switch.js +6 -1
- package/dist/shared/input-switch.mjs +6 -1
- package/dist/shared/lib/campaign.js +117 -0
- package/dist/shared/lib/campaign.mjs +91 -0
- package/dist/shared/lib/helpers.js +14 -2
- package/dist/shared/lib/helpers.mjs +13 -2
- package/package.json +133 -13
- package/types/bridge/form-subdomain-header.d.ts +2 -0
- package/types/bridge/form-subdomain-missions.d.ts +36 -0
- package/types/bridge/form-subdomain.d.ts +23 -1
- package/types/bridge/lib/entry.d.ts +26 -0
- package/types/bridge/lib/location.d.ts +13 -0
- package/types/bridge/lib/order.d.ts +30 -0
- package/types/bridge/lib/url.d.ts +19 -0
- package/types/bridge/template-modal.d.ts +1 -1
- package/types/bridge/template-preview.d.ts +10 -0
- package/types/bridge/template-subdomain-link.d.ts +2 -0
- package/types/dashboard/accordion.d.ts +2 -0
- package/types/dashboard/avatar.d.ts +18 -2
- package/types/dashboard/buttons-subscription.d.ts +22 -0
- package/types/dashboard/card-campaign-switch.d.ts +32 -0
- package/types/dashboard/card-order.d.ts +11 -0
- package/types/dashboard/card-section.d.ts +2 -0
- package/types/dashboard/connection-workflows.d.ts +33 -0
- package/types/dashboard/device.d.ts +12 -0
- package/types/dashboard/form-admin-campaign.d.ts +3 -2
- package/types/dashboard/form-ai.d.ts +2 -2
- package/types/dashboard/form-organization-campaign-agreement.d.ts +18 -12
- package/types/dashboard/form-organization-campaign-field-email.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-list.d.ts +36 -0
- package/types/dashboard/form-organization-campaign-field-phone.d.ts +1 -2
- package/types/dashboard/form-organization-campaign-field-remove.d.ts +22 -0
- package/types/dashboard/form-organization-campaign-field-select.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-field-textarea.d.ts +2 -1
- package/types/dashboard/form-organization-campaign-integration-age.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-integration-enable.d.ts +3 -3
- package/types/dashboard/form-organization-campaign-mission.d.ts +40 -0
- package/types/dashboard/form-organization-campaign-section.d.ts +27 -0
- package/types/dashboard/form-organization-campaign.d.ts +27 -17
- package/types/dashboard/form-organization-identity.d.ts +2 -0
- package/types/dashboard/form-organization-workflow.d.ts +43 -47
- package/types/dashboard/form-organization.d.ts +7 -2
- package/types/dashboard/form-stripe.d.ts +3 -0
- package/types/dashboard/input-combobox.d.ts +2 -0
- package/types/dashboard/input-date.d.ts +2 -0
- package/types/dashboard/input-fields.d.ts +3 -2
- package/types/dashboard/input-file.d.ts +4 -0
- package/types/dashboard/lib/item-list.d.ts +14 -0
- package/types/dashboard/lib/menu.d.ts +17 -0
- package/types/dashboard/locked.d.ts +10 -0
- package/types/dashboard/menu.d.ts +10 -2
- package/types/dashboard/note-ai.d.ts +15 -0
- package/types/dashboard/preview.d.ts +33 -0
- package/types/dashboard/steps.d.ts +19 -4
- package/types/dashboard/table-cell-title.d.ts +2 -2
- package/types/dashboard/table-contacts.d.ts +2 -0
- package/types/icons/desktop.d.ts +5 -0
- package/types/icons/phone.d.ts +5 -0
- package/types/icons/puzzle-piece.d.ts +5 -0
- package/types/icons/tablet.d.ts +5 -0
- package/types/icons/users.d.ts +5 -0
- package/types/input-code.d.ts +23 -0
- package/types/shared/input-switch.d.ts +2 -0
- package/types/shared/lib/campaign.d.ts +35 -0
- package/types/shared/lib/helpers.d.ts +3 -0
- package/dist/dashboard/card-integration.js +0 -187
- package/dist/dashboard/card-integration.mjs +0 -158
- package/dist/dashboard/iframe.js +0 -159
- package/dist/dashboard/iframe.mjs +0 -130
- package/types/dashboard/card-integration.d.ts +0 -24
- package/types/dashboard/iframe.d.ts +0 -18
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Fragment, useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useSearchParams } from "next/navigation";
|
|
5
|
+
import Image from "next/image";
|
|
5
6
|
import { request } from "@drawbridge/drawbridge-utils/fetch";
|
|
7
|
+
import { formatCurrency } from "@drawbridge/drawbridge-utils";
|
|
8
|
+
import { cdnSrc } from "@drawbridge/drawbridge-utils/cdn";
|
|
9
|
+
import { ordersItems } from "@drawbridge/drawbridge-utils/fields-validate";
|
|
6
10
|
import { captureException } from "@drawbridge/drawbridge-telemetry/nextjs";
|
|
7
|
-
import { useForm, Controller } from "react-hook-form";
|
|
11
|
+
import { useForm, useWatch, Controller } from "react-hook-form";
|
|
8
12
|
import yup, { resolver } from "./lib/yup.mjs";
|
|
9
13
|
import { ageFor, ageGateSchema } from "./lib/age-gate.mjs";
|
|
10
14
|
import { useGoogleReCaptcha } from "react-google-recaptcha-v3";
|
|
11
15
|
import { assertRecaptcha } from "./lib/recaptcha.mjs";
|
|
12
16
|
import { submissionEndpoint } from "./lib/url.mjs";
|
|
17
|
+
import { agreementWording, panelMissions } from "./lib/entry.mjs";
|
|
18
|
+
import { LOCATION_TIMEOUT, locationCopy, locationStatus } from "./lib/location.mjs";
|
|
19
|
+
import { isLastList, itemCount, limitMessage, orderTotal, sectionsOf } from "./lib/order.mjs";
|
|
13
20
|
import Form from "../shared/form.mjs";
|
|
14
21
|
import Button from "../shared/button.mjs";
|
|
15
22
|
import Fieldset from "../shared/fieldset.mjs";
|
|
16
|
-
import { components, validate } from "./fields.mjs";
|
|
23
|
+
import { components, errors, validate } from "./fields.mjs";
|
|
17
24
|
import InputGroup from "../input-group.mjs";
|
|
25
|
+
import InputNumber from "../input-number.mjs";
|
|
18
26
|
import Error from "../shared/error.mjs";
|
|
19
27
|
import InputText from "../input-text.mjs";
|
|
20
28
|
import { FormSubdomainHeader } from "./form-subdomain-header.mjs";
|
|
@@ -22,33 +30,44 @@ import Loader from "../icons/loader.mjs";
|
|
|
22
30
|
import Warning from "../icons/warning.mjs";
|
|
23
31
|
import InputCheckbox from "../input-checkbox.mjs";
|
|
24
32
|
import Advertisements from "./advertisements.mjs";
|
|
33
|
+
import FormSubdomainMissions from "./form-subdomain-missions.mjs";
|
|
25
34
|
import Link from "next/link";
|
|
26
35
|
const appendPreview = (endpoint, token) => {
|
|
27
36
|
if (!token) return endpoint;
|
|
28
37
|
const separator = endpoint.includes("?") ? "&" : "?";
|
|
29
38
|
return endpoint + separator + "drwbrdg_pre=" + encodeURIComponent(token);
|
|
30
39
|
};
|
|
40
|
+
const scrollToCentre = (node) => {
|
|
41
|
+
let box = node == null ? void 0 : node.parentElement;
|
|
42
|
+
while (box && !(box.scrollHeight > box.clientHeight && /auto|scroll/.test(getComputedStyle(box).overflowY))) box = box.parentElement;
|
|
43
|
+
if (!box) return;
|
|
44
|
+
box.scrollTop += node.getBoundingClientRect().top - box.getBoundingClientRect().top - (box.clientHeight - node.offsetHeight) / 2;
|
|
45
|
+
};
|
|
31
46
|
const FormSubdomainSubmission = ({
|
|
32
47
|
affiliate,
|
|
33
48
|
button,
|
|
34
49
|
checkout,
|
|
50
|
+
giveaway,
|
|
35
51
|
id,
|
|
36
52
|
lead,
|
|
37
53
|
message,
|
|
54
|
+
panel,
|
|
38
55
|
preview,
|
|
56
|
+
repeat,
|
|
39
57
|
slug,
|
|
40
58
|
style,
|
|
41
59
|
subdomain,
|
|
42
60
|
title,
|
|
43
61
|
tracking
|
|
44
62
|
}) => {
|
|
45
|
-
var _a;
|
|
46
|
-
const [loading, setLoading] = useState(Boolean(id));
|
|
47
|
-
const [
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const [loading, setLoading] = useState(Boolean(id) && !panel);
|
|
65
|
+
const [fetched, setFetched] = useState();
|
|
48
66
|
const [error, setError] = useState();
|
|
67
|
+
const data = panel || fetched;
|
|
49
68
|
const searchParams = useSearchParams();
|
|
50
69
|
const token = searchParams.get("drwbrdg_pre");
|
|
51
|
-
const endpoint = submissionEndpoint({ affiliate, id, slug, subdomain, token });
|
|
70
|
+
const endpoint = panel ? null : submissionEndpoint({ affiliate, id, slug, subdomain, token });
|
|
52
71
|
const submission = useCallback(
|
|
53
72
|
async () => {
|
|
54
73
|
try {
|
|
@@ -57,7 +76,7 @@ const FormSubdomainSubmission = ({
|
|
|
57
76
|
endpoint,
|
|
58
77
|
method: "GET"
|
|
59
78
|
});
|
|
60
|
-
|
|
79
|
+
setFetched(response.result);
|
|
61
80
|
setLoading(false);
|
|
62
81
|
} catch ({ message: message2 }) {
|
|
63
82
|
setError(message2);
|
|
@@ -106,6 +125,43 @@ const FormSubdomainSubmission = ({
|
|
|
106
125
|
}
|
|
107
126
|
);
|
|
108
127
|
}
|
|
128
|
+
const advertisements = ((_a = data == null ? void 0 : data.advertisements) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ jsx(
|
|
129
|
+
Advertisements,
|
|
130
|
+
{
|
|
131
|
+
...{
|
|
132
|
+
affiliate: data == null ? void 0 : data.affiliate,
|
|
133
|
+
campaign: data == null ? void 0 : data.campaign,
|
|
134
|
+
items: (data == null ? void 0 : data.advertisements) || [],
|
|
135
|
+
lead,
|
|
136
|
+
checkout,
|
|
137
|
+
organization: data == null ? void 0 : data.organization,
|
|
138
|
+
page: data == null ? void 0 : data.page,
|
|
139
|
+
preview,
|
|
140
|
+
slug,
|
|
141
|
+
style,
|
|
142
|
+
subdomain,
|
|
143
|
+
tracking
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
if (Boolean(giveaway) && ((_b = data == null ? void 0 : data.missions) == null ? void 0 : _b.length) > 0) return /* @__PURE__ */ jsx(
|
|
148
|
+
FormSubdomainMissions,
|
|
149
|
+
{
|
|
150
|
+
...{
|
|
151
|
+
advertisements,
|
|
152
|
+
button,
|
|
153
|
+
contact: data == null ? void 0 : data.contact,
|
|
154
|
+
message,
|
|
155
|
+
missions: panelMissions(data.missions, repeat),
|
|
156
|
+
shareLink: data == null ? void 0 : data.shareLink,
|
|
157
|
+
slug,
|
|
158
|
+
style,
|
|
159
|
+
subdomain,
|
|
160
|
+
title,
|
|
161
|
+
token: data == null ? void 0 : data.token
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
);
|
|
109
165
|
return /* @__PURE__ */ jsxs(
|
|
110
166
|
"div",
|
|
111
167
|
{
|
|
@@ -127,25 +183,7 @@ const FormSubdomainSubmission = ({
|
|
|
127
183
|
}
|
|
128
184
|
}
|
|
129
185
|
),
|
|
130
|
-
|
|
131
|
-
Advertisements,
|
|
132
|
-
{
|
|
133
|
-
...{
|
|
134
|
-
affiliate: data == null ? void 0 : data.affiliate,
|
|
135
|
-
campaign: data == null ? void 0 : data.campaign,
|
|
136
|
-
items: (data == null ? void 0 : data.advertisements) || [],
|
|
137
|
-
lead,
|
|
138
|
-
checkout,
|
|
139
|
-
organization: data == null ? void 0 : data.organization,
|
|
140
|
-
page: data == null ? void 0 : data.page,
|
|
141
|
-
preview,
|
|
142
|
-
slug,
|
|
143
|
-
style,
|
|
144
|
-
subdomain,
|
|
145
|
-
tracking
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
)
|
|
186
|
+
advertisements
|
|
149
187
|
]
|
|
150
188
|
}
|
|
151
189
|
);
|
|
@@ -252,53 +290,88 @@ const FormSubdomainGeocode = ({
|
|
|
252
290
|
style,
|
|
253
291
|
values
|
|
254
292
|
}) => {
|
|
255
|
-
const [
|
|
293
|
+
const [state, setState] = useState(disabled ? { message: "Campaign is not currently active", status: "inactive" } : { status: "checking" });
|
|
294
|
+
const [attempt, setAttempt] = useState(0);
|
|
256
295
|
const searchParams = useSearchParams();
|
|
257
296
|
const token = searchParams.get("drwbrdg_pre");
|
|
297
|
+
const next = useRef(callback);
|
|
298
|
+
next.current = callback;
|
|
258
299
|
useEffect(
|
|
259
300
|
() => {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
body: {
|
|
266
|
-
coordinates: [
|
|
267
|
-
position.coords.longitude,
|
|
268
|
-
position.coords.latitude
|
|
269
|
-
],
|
|
270
|
-
preview
|
|
271
|
-
},
|
|
272
|
-
cache: "no-store",
|
|
273
|
-
endpoint: appendPreview("/subdomain/" + (values == null ? void 0 : values.subdomain) + "/page/" + (values == null ? void 0 : values.slug) + "/location", token),
|
|
274
|
-
method: "POST"
|
|
275
|
-
});
|
|
276
|
-
callback(response);
|
|
277
|
-
} catch ({ message }) {
|
|
278
|
-
setError(message);
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
() => {
|
|
282
|
-
setError("Location services are not enabled.");
|
|
283
|
-
}
|
|
284
|
-
);
|
|
285
|
-
} else {
|
|
286
|
-
setError("Location data is not supported with your current browser and or device.");
|
|
301
|
+
var _a, _b;
|
|
302
|
+
if (disabled) return;
|
|
303
|
+
if (!navigator.geolocation) {
|
|
304
|
+
setState({ status: "unsupported" });
|
|
305
|
+
return;
|
|
287
306
|
}
|
|
307
|
+
let live = true;
|
|
308
|
+
setState({ status: "checking" });
|
|
309
|
+
(_b = (_a = navigator.permissions) == null ? void 0 : _a.query) == null ? void 0 : _b.call(_a, { name: "geolocation" }).then((permission) => live && (permission == null ? void 0 : permission.state) === "prompt" && setState((current) => current.status === "checking" ? { status: "asking" } : current)).catch(() => {
|
|
310
|
+
});
|
|
311
|
+
navigator.geolocation.getCurrentPosition(
|
|
312
|
+
async (position) => {
|
|
313
|
+
try {
|
|
314
|
+
const response = await request({
|
|
315
|
+
body: {
|
|
316
|
+
coordinates: [
|
|
317
|
+
position.coords.longitude,
|
|
318
|
+
position.coords.latitude
|
|
319
|
+
],
|
|
320
|
+
preview
|
|
321
|
+
},
|
|
322
|
+
cache: "no-store",
|
|
323
|
+
endpoint: appendPreview("/subdomain/" + (values == null ? void 0 : values.subdomain) + "/page/" + (values == null ? void 0 : values.slug) + "/location", token),
|
|
324
|
+
method: "POST"
|
|
325
|
+
});
|
|
326
|
+
if (live) next.current(response);
|
|
327
|
+
} catch ({ message }) {
|
|
328
|
+
if (live) setState({ message, status: "outside" });
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
(error) => live && setState({ status: locationStatus(error) }),
|
|
332
|
+
{
|
|
333
|
+
timeout: LOCATION_TIMEOUT
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
return () => {
|
|
337
|
+
live = false;
|
|
338
|
+
};
|
|
288
339
|
},
|
|
289
|
-
[
|
|
340
|
+
[attempt, disabled, preview, token, values == null ? void 0 : values.slug, values == null ? void 0 : values.subdomain]
|
|
290
341
|
);
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
342
|
+
if (["denied", "inactive", "missing", "outside", "unsupported"].includes(state.status)) {
|
|
343
|
+
const retry = ["denied", "missing"].includes(state.status);
|
|
344
|
+
return /* @__PURE__ */ jsxs(
|
|
345
|
+
"div",
|
|
294
346
|
{
|
|
295
347
|
...{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
348
|
+
className: "space-y-6"
|
|
349
|
+
},
|
|
350
|
+
children: [
|
|
351
|
+
/* @__PURE__ */ jsx(
|
|
352
|
+
FormSubdomainMessage,
|
|
353
|
+
{
|
|
354
|
+
...{
|
|
355
|
+
button,
|
|
356
|
+
message: state.message || locationCopy[state.status],
|
|
357
|
+
style,
|
|
358
|
+
svg: Warning,
|
|
359
|
+
title: "Error"
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
retry && /* @__PURE__ */ jsx(
|
|
364
|
+
Button,
|
|
365
|
+
{
|
|
366
|
+
...{
|
|
367
|
+
onClick: () => setAttempt((value) => value + 1),
|
|
368
|
+
style,
|
|
369
|
+
type: "button"
|
|
370
|
+
},
|
|
371
|
+
children: "Try again"
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
]
|
|
302
375
|
}
|
|
303
376
|
);
|
|
304
377
|
}
|
|
@@ -327,20 +400,32 @@ const FormSubdomainGeocode = ({
|
|
|
327
400
|
}
|
|
328
401
|
}
|
|
329
402
|
),
|
|
330
|
-
/* @__PURE__ */
|
|
403
|
+
/* @__PURE__ */ jsxs(
|
|
331
404
|
"div",
|
|
332
405
|
{
|
|
333
406
|
...{
|
|
334
|
-
className: "flex items-center justify-center p-6"
|
|
407
|
+
className: "flex flex-col items-center justify-center gap-4 p-6"
|
|
335
408
|
},
|
|
336
|
-
children:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
409
|
+
children: [
|
|
410
|
+
/* @__PURE__ */ jsx(
|
|
411
|
+
Loader,
|
|
412
|
+
{
|
|
413
|
+
...{
|
|
414
|
+
className: "w-6 h-6 animate-spin"
|
|
415
|
+
}
|
|
341
416
|
}
|
|
342
|
-
|
|
343
|
-
|
|
417
|
+
),
|
|
418
|
+
state.status === "asking" && /* @__PURE__ */ jsx(
|
|
419
|
+
"p",
|
|
420
|
+
{
|
|
421
|
+
...{
|
|
422
|
+
className: "text-center",
|
|
423
|
+
role: "status"
|
|
424
|
+
},
|
|
425
|
+
children: locationCopy.asking
|
|
426
|
+
}
|
|
427
|
+
)
|
|
428
|
+
]
|
|
344
429
|
}
|
|
345
430
|
)
|
|
346
431
|
]
|
|
@@ -544,50 +629,200 @@ const FormSubdomainAge = ({
|
|
|
544
629
|
}
|
|
545
630
|
);
|
|
546
631
|
};
|
|
547
|
-
const
|
|
632
|
+
const drawnAs = {
|
|
633
|
+
note: "textarea",
|
|
634
|
+
pickup: "select"
|
|
635
|
+
};
|
|
636
|
+
const FormSubdomainItemList = ({
|
|
637
|
+
currency,
|
|
638
|
+
field,
|
|
639
|
+
onChange,
|
|
640
|
+
prices,
|
|
641
|
+
style,
|
|
642
|
+
value
|
|
643
|
+
}) => {
|
|
644
|
+
var _a;
|
|
645
|
+
return /* @__PURE__ */ jsxs(
|
|
646
|
+
"div",
|
|
647
|
+
{
|
|
648
|
+
...{
|
|
649
|
+
className: "space-y-2"
|
|
650
|
+
},
|
|
651
|
+
children: [
|
|
652
|
+
/* @__PURE__ */ jsx(
|
|
653
|
+
"p",
|
|
654
|
+
{
|
|
655
|
+
...{
|
|
656
|
+
className: "text-xs uppercase tracking-wide opacity-60"
|
|
657
|
+
},
|
|
658
|
+
children: field == null ? void 0 : field.label
|
|
659
|
+
}
|
|
660
|
+
),
|
|
661
|
+
/* @__PURE__ */ jsx(
|
|
662
|
+
"div",
|
|
663
|
+
{
|
|
664
|
+
...{
|
|
665
|
+
className: "space-y-4"
|
|
666
|
+
},
|
|
667
|
+
children: (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.items) || []).map((item) => {
|
|
668
|
+
var _a2, _b;
|
|
669
|
+
const quantity = Number(value == null ? void 0 : value[item.id]) || 0;
|
|
670
|
+
const src = cdnSrc(item.image, "200x200", (_a2 = item.image) == null ? void 0 : _a2.updatedAt);
|
|
671
|
+
return /* @__PURE__ */ jsx(
|
|
672
|
+
InputGroup,
|
|
673
|
+
{
|
|
674
|
+
...{
|
|
675
|
+
error: limitMessage(item, quantity),
|
|
676
|
+
input: /* @__PURE__ */ jsxs(
|
|
677
|
+
"div",
|
|
678
|
+
{
|
|
679
|
+
...{
|
|
680
|
+
className: "flex items-center space-x-3"
|
|
681
|
+
},
|
|
682
|
+
children: [
|
|
683
|
+
src && /* @__PURE__ */ jsx(
|
|
684
|
+
"div",
|
|
685
|
+
{
|
|
686
|
+
...{
|
|
687
|
+
className: "relative w-14 h-14 rounded overflow-hidden shrink-0"
|
|
688
|
+
},
|
|
689
|
+
children: /* @__PURE__ */ jsx(
|
|
690
|
+
Image,
|
|
691
|
+
{
|
|
692
|
+
...{
|
|
693
|
+
// The image's own description, else its file name, as every image slot.
|
|
694
|
+
alt: item.description || ((_b = item.image) == null ? void 0 : _b.filename) || "",
|
|
695
|
+
className: "object-cover",
|
|
696
|
+
fill: true,
|
|
697
|
+
sizes: "56px",
|
|
698
|
+
src,
|
|
699
|
+
unoptimized: true
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
)
|
|
703
|
+
}
|
|
704
|
+
),
|
|
705
|
+
/* @__PURE__ */ jsxs(
|
|
706
|
+
"div",
|
|
707
|
+
{
|
|
708
|
+
...{
|
|
709
|
+
className: "flex-1 space-y-0.5 min-w-0"
|
|
710
|
+
},
|
|
711
|
+
children: [
|
|
712
|
+
/* @__PURE__ */ jsx(
|
|
713
|
+
"p",
|
|
714
|
+
{
|
|
715
|
+
...{
|
|
716
|
+
className: "text-sm font-medium leading-tight line-clamp-2"
|
|
717
|
+
},
|
|
718
|
+
children: item.name
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
prices && typeof item.price === "number" && /* @__PURE__ */ jsx(
|
|
722
|
+
"p",
|
|
723
|
+
{
|
|
724
|
+
...{
|
|
725
|
+
className: "text-xs opacity-60"
|
|
726
|
+
},
|
|
727
|
+
children: formatCurrency({
|
|
728
|
+
code: currency.toUpperCase(),
|
|
729
|
+
display: "parts",
|
|
730
|
+
value: item.price
|
|
731
|
+
})
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
),
|
|
737
|
+
/* @__PURE__ */ jsx(
|
|
738
|
+
InputNumber,
|
|
739
|
+
{
|
|
740
|
+
...{
|
|
741
|
+
// The item's limit is a Number field's attributes, spread as
|
|
742
|
+
// FieldNumber spreads them (bridge/fields.js).
|
|
743
|
+
min: 0,
|
|
744
|
+
...item.attributes,
|
|
745
|
+
"aria-label": "Quantity of " + item.name,
|
|
746
|
+
inline: true,
|
|
747
|
+
layout: "split",
|
|
748
|
+
onChange: (next) => onChange({
|
|
749
|
+
...value,
|
|
750
|
+
[item.id]: next
|
|
751
|
+
}),
|
|
752
|
+
small: true,
|
|
753
|
+
style,
|
|
754
|
+
value: quantity
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
)
|
|
758
|
+
]
|
|
759
|
+
}
|
|
760
|
+
),
|
|
761
|
+
style
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
item.id
|
|
765
|
+
);
|
|
766
|
+
})
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
]
|
|
770
|
+
}
|
|
771
|
+
);
|
|
772
|
+
};
|
|
773
|
+
const FormSubdomainSection = ({
|
|
774
|
+
back,
|
|
548
775
|
button,
|
|
549
776
|
callback = () => {
|
|
550
777
|
},
|
|
551
778
|
disabled,
|
|
779
|
+
focus,
|
|
780
|
+
initial,
|
|
781
|
+
last,
|
|
552
782
|
preview,
|
|
783
|
+
section,
|
|
784
|
+
slugs = [],
|
|
553
785
|
style,
|
|
554
786
|
values
|
|
555
787
|
}) => {
|
|
556
788
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
557
|
-
const fields = [
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
const
|
|
563
|
-
const
|
|
789
|
+
const fields = (section == null ? void 0 : section.fields) || [];
|
|
790
|
+
const lists = fields.filter((field) => (field == null ? void 0 : field.slug) === "list");
|
|
791
|
+
const prices = ((_a = section == null ? void 0 : section.settings) == null ? void 0 : _a.prices) !== false;
|
|
792
|
+
const currency = ((_b = section == null ? void 0 : section.settings) == null ? void 0 : _b.currency) || "usd";
|
|
793
|
+
const smsConsent = Boolean(last) && (Boolean((_d = (_c = values == null ? void 0 : values.agreements) == null ? void 0 : _c.sms) == null ? void 0 : _d.enabled) || slugs.includes("phone"));
|
|
794
|
+
const marketingConsent = Boolean(last) && Boolean((_f = (_e = values == null ? void 0 : values.agreements) == null ? void 0 : _e.marketing) == null ? void 0 : _f.enabled);
|
|
795
|
+
const termsConsent = Boolean(last) && Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled);
|
|
564
796
|
const schema = useMemo(
|
|
565
797
|
() => {
|
|
566
|
-
var _a2
|
|
567
|
-
const memoFields = [
|
|
568
|
-
|
|
569
|
-
...((_b2 = values == null ? void 0 : values.fields) == null ? void 0 : _b2.additional) || []
|
|
570
|
-
];
|
|
571
|
-
const memoSlugs = memoFields.map((field) => field == null ? void 0 : field.slug);
|
|
798
|
+
var _a2;
|
|
799
|
+
const memoFields = (section == null ? void 0 : section.fields) || [];
|
|
800
|
+
const memoLists = memoFields.filter((field) => (field == null ? void 0 : field.slug) === "list");
|
|
572
801
|
const shape = {
|
|
573
802
|
fields: yup.object(
|
|
574
803
|
memoFields.reduce(
|
|
575
804
|
(accumulator, field) => {
|
|
576
|
-
accumulator[field.id] = validate[field == null ? void 0 : field.slug](field, yup);
|
|
805
|
+
accumulator[field.id] = validate[drawnAs[field == null ? void 0 : field.slug] || (field == null ? void 0 : field.slug)](field, yup);
|
|
577
806
|
return accumulator;
|
|
578
807
|
},
|
|
579
808
|
{}
|
|
580
809
|
)
|
|
581
810
|
)
|
|
582
811
|
};
|
|
812
|
+
if (memoLists.length > 0) {
|
|
813
|
+
shape.items = yup.mixed().test("items", errors.items, function() {
|
|
814
|
+
var _a3;
|
|
815
|
+
return ordersItems(memoLists, (_a3 = this.parent) == null ? void 0 : _a3.fields);
|
|
816
|
+
});
|
|
817
|
+
}
|
|
583
818
|
const agreements = {};
|
|
584
|
-
if (
|
|
585
|
-
agreements.terms = validate.agreement((
|
|
819
|
+
if (termsConsent) {
|
|
820
|
+
agreements.terms = validate.agreement((_a2 = values == null ? void 0 : values.agreements) == null ? void 0 : _a2.terms, yup);
|
|
586
821
|
}
|
|
587
|
-
if (
|
|
822
|
+
if (marketingConsent) {
|
|
588
823
|
agreements.marketing = yup.bool();
|
|
589
824
|
}
|
|
590
|
-
if (
|
|
825
|
+
if (smsConsent) {
|
|
591
826
|
agreements.sms = yup.bool();
|
|
592
827
|
}
|
|
593
828
|
if (Object.keys(agreements).length > 0) {
|
|
@@ -595,11 +830,15 @@ const FormSubdomainInformation = ({
|
|
|
595
830
|
}
|
|
596
831
|
return yup.object(shape);
|
|
597
832
|
},
|
|
598
|
-
[values]
|
|
833
|
+
[marketingConsent, section, smsConsent, termsConsent, values]
|
|
599
834
|
);
|
|
600
|
-
const { control, handleSubmit, formState } = useForm({
|
|
601
|
-
|
|
602
|
-
|
|
835
|
+
const { control, getValues, handleSubmit, formState } = useForm({
|
|
836
|
+
defaultValues: initial || {},
|
|
837
|
+
resolver: resolver(schema)
|
|
838
|
+
});
|
|
839
|
+
const answers = useWatch({
|
|
840
|
+
control,
|
|
841
|
+
name: "fields"
|
|
603
842
|
});
|
|
604
843
|
const checkbox = ({
|
|
605
844
|
fallback,
|
|
@@ -633,6 +872,54 @@ const FormSubdomainInformation = ({
|
|
|
633
872
|
}
|
|
634
873
|
);
|
|
635
874
|
};
|
|
875
|
+
const count = itemCount(lists, answers);
|
|
876
|
+
const itemsError = (_j = (_i = formState == null ? void 0 : formState.errors) == null ? void 0 : _i.items) == null ? void 0 : _j.message;
|
|
877
|
+
const totalBlock = (prices || itemsError) && /* @__PURE__ */ jsxs(
|
|
878
|
+
"div",
|
|
879
|
+
{
|
|
880
|
+
...{
|
|
881
|
+
className: "space-y-4"
|
|
882
|
+
},
|
|
883
|
+
children: [
|
|
884
|
+
prices && /* @__PURE__ */ jsxs(
|
|
885
|
+
"div",
|
|
886
|
+
{
|
|
887
|
+
...{
|
|
888
|
+
className: "flex items-center justify-between text-sm"
|
|
889
|
+
},
|
|
890
|
+
children: [
|
|
891
|
+
/* @__PURE__ */ jsx("span", { children: "ESTIMATED TOTAL \xB7 " + count + " " + (count === 1 ? "ITEM" : "ITEMS") }),
|
|
892
|
+
/* @__PURE__ */ jsx("span", { children: formatCurrency({
|
|
893
|
+
code: currency.toUpperCase(),
|
|
894
|
+
display: "parts",
|
|
895
|
+
value: orderTotal(lists, answers)
|
|
896
|
+
}) })
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
),
|
|
900
|
+
itemsError && /* @__PURE__ */ jsx(
|
|
901
|
+
Error,
|
|
902
|
+
{
|
|
903
|
+
...{
|
|
904
|
+
error: itemsError,
|
|
905
|
+
style
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
)
|
|
909
|
+
]
|
|
910
|
+
}
|
|
911
|
+
);
|
|
912
|
+
const consent = [
|
|
913
|
+
termsConsent && ["terms"],
|
|
914
|
+
marketingConsent && ["marketing", agreementWording.marketing],
|
|
915
|
+
smsConsent && ["sms", agreementWording.sms]
|
|
916
|
+
].filter(Boolean);
|
|
917
|
+
const faded = (key) => focus && key !== focus ? "opacity-25" : "";
|
|
918
|
+
const focused = useRef(null);
|
|
919
|
+
useEffect(
|
|
920
|
+
() => scrollToCentre(focused.current),
|
|
921
|
+
[focus]
|
|
922
|
+
);
|
|
636
923
|
return /* @__PURE__ */ jsxs(
|
|
637
924
|
Form,
|
|
638
925
|
{
|
|
@@ -642,22 +929,45 @@ const FormSubdomainInformation = ({
|
|
|
642
929
|
},
|
|
643
930
|
children: [
|
|
644
931
|
/* @__PURE__ */ jsx(
|
|
645
|
-
|
|
932
|
+
"div",
|
|
646
933
|
{
|
|
647
934
|
...{
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
935
|
+
className: faded()
|
|
936
|
+
},
|
|
937
|
+
children: /* @__PURE__ */ jsx(
|
|
938
|
+
FormSubdomainHeader,
|
|
939
|
+
{
|
|
940
|
+
...{
|
|
941
|
+
// Back keeps what this step holds so far, answered or not.
|
|
942
|
+
...back && {
|
|
943
|
+
back: {
|
|
944
|
+
onClick: () => back(getValues())
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
button,
|
|
948
|
+
description: section == null ? void 0 : section.description,
|
|
949
|
+
style,
|
|
950
|
+
title: section == null ? void 0 : section.title
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
)
|
|
652
954
|
}
|
|
653
955
|
),
|
|
654
956
|
Boolean(preview) && /* @__PURE__ */ jsx(
|
|
655
|
-
|
|
957
|
+
"div",
|
|
656
958
|
{
|
|
657
959
|
...{
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
960
|
+
className: faded()
|
|
961
|
+
},
|
|
962
|
+
children: /* @__PURE__ */ jsx(
|
|
963
|
+
Error,
|
|
964
|
+
{
|
|
965
|
+
...{
|
|
966
|
+
error: "Preview mode: data not collected",
|
|
967
|
+
style
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
)
|
|
661
971
|
}
|
|
662
972
|
),
|
|
663
973
|
/* @__PURE__ */ jsxs(
|
|
@@ -672,134 +982,111 @@ const FormSubdomainInformation = ({
|
|
|
672
982
|
"div",
|
|
673
983
|
{
|
|
674
984
|
...{
|
|
675
|
-
className: "space-y-4"
|
|
676
|
-
},
|
|
677
|
-
children: fields.map((field) => /* @__PURE__ */ jsx(
|
|
678
|
-
Controller,
|
|
679
|
-
{
|
|
680
|
-
...{
|
|
681
|
-
control,
|
|
682
|
-
name: "fields." + field.id,
|
|
683
|
-
render: ({ field: { onChange, value } }) => {
|
|
684
|
-
var _a2, _b2;
|
|
685
|
-
return components[field == null ? void 0 : field.slug]({
|
|
686
|
-
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.fields) == null ? void 0 : _b2[field == null ? void 0 : field.id],
|
|
687
|
-
field,
|
|
688
|
-
onChange,
|
|
689
|
-
style,
|
|
690
|
-
value
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
field == null ? void 0 : field.id
|
|
696
|
-
))
|
|
697
|
-
}
|
|
698
|
-
),
|
|
699
|
-
(Boolean((_h = (_g = values == null ? void 0 : values.agreements) == null ? void 0 : _g.terms) == null ? void 0 : _h.enabled) || marketingConsent || smsConsent) && /* @__PURE__ */ jsxs(
|
|
700
|
-
"div",
|
|
701
|
-
{
|
|
702
|
-
...{
|
|
703
|
-
className: "space-y-4"
|
|
985
|
+
className: (lists.length > 0 ? "space-y-6 " : "space-y-4 ") + faded()
|
|
704
986
|
},
|
|
705
|
-
children: [
|
|
706
|
-
|
|
987
|
+
children: fields.map((field) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
988
|
+
/* @__PURE__ */ jsx(
|
|
707
989
|
Controller,
|
|
708
990
|
{
|
|
709
991
|
...{
|
|
710
992
|
control,
|
|
711
|
-
name: "
|
|
712
|
-
render: ({ field: {
|
|
713
|
-
var _a2, _b2
|
|
714
|
-
return /* @__PURE__ */ jsx(
|
|
715
|
-
|
|
993
|
+
name: "fields." + field.id,
|
|
994
|
+
render: ({ field: { onChange, value } }) => {
|
|
995
|
+
var _a2, _b2;
|
|
996
|
+
return (field == null ? void 0 : field.slug) === "list" ? /* @__PURE__ */ jsx(
|
|
997
|
+
FormSubdomainItemList,
|
|
716
998
|
{
|
|
717
999
|
...{
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
style
|
|
1000
|
+
currency,
|
|
1001
|
+
field,
|
|
1002
|
+
onChange,
|
|
1003
|
+
prices,
|
|
1004
|
+
style,
|
|
1005
|
+
value
|
|
725
1006
|
}
|
|
726
1007
|
}
|
|
727
|
-
)
|
|
1008
|
+
) : components[drawnAs[field == null ? void 0 : field.slug] || (field == null ? void 0 : field.slug)]({
|
|
1009
|
+
error: (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.fields) == null ? void 0 : _b2[field == null ? void 0 : field.id],
|
|
1010
|
+
field,
|
|
1011
|
+
onChange,
|
|
1012
|
+
style,
|
|
1013
|
+
value
|
|
1014
|
+
});
|
|
728
1015
|
}
|
|
729
1016
|
}
|
|
730
1017
|
}
|
|
731
1018
|
),
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
value
|
|
750
|
-
}),
|
|
751
|
-
style
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
);
|
|
755
|
-
}
|
|
1019
|
+
isLastList(fields, field == null ? void 0 : field.id) && totalBlock
|
|
1020
|
+
] }, field == null ? void 0 : field.id))
|
|
1021
|
+
}
|
|
1022
|
+
),
|
|
1023
|
+
consent.length > 0 && /* @__PURE__ */ jsx(
|
|
1024
|
+
"div",
|
|
1025
|
+
{
|
|
1026
|
+
...{
|
|
1027
|
+
className: "space-y-4"
|
|
1028
|
+
},
|
|
1029
|
+
children: consent.map(([key, fallback]) => /* @__PURE__ */ jsx(
|
|
1030
|
+
"div",
|
|
1031
|
+
{
|
|
1032
|
+
...{
|
|
1033
|
+
className: faded(key),
|
|
1034
|
+
...key === focus && {
|
|
1035
|
+
ref: focused
|
|
756
1036
|
}
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
}),
|
|
780
|
-
style
|
|
1037
|
+
},
|
|
1038
|
+
children: /* @__PURE__ */ jsx(
|
|
1039
|
+
Controller,
|
|
1040
|
+
{
|
|
1041
|
+
...{
|
|
1042
|
+
control,
|
|
1043
|
+
name: "agreements." + key,
|
|
1044
|
+
render: ({ field: { value, onChange } }) => {
|
|
1045
|
+
var _a2, _b2, _c2;
|
|
1046
|
+
return /* @__PURE__ */ jsx(
|
|
1047
|
+
InputGroup,
|
|
1048
|
+
{
|
|
1049
|
+
...{
|
|
1050
|
+
error: (_c2 = (_b2 = (_a2 = formState == null ? void 0 : formState.errors) == null ? void 0 : _a2.agreements) == null ? void 0 : _b2[key]) == null ? void 0 : _c2.message,
|
|
1051
|
+
input: checkbox({
|
|
1052
|
+
fallback,
|
|
1053
|
+
key,
|
|
1054
|
+
onChange,
|
|
1055
|
+
value
|
|
1056
|
+
}),
|
|
1057
|
+
style
|
|
1058
|
+
}
|
|
781
1059
|
}
|
|
782
|
-
|
|
783
|
-
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
784
1062
|
}
|
|
785
1063
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
1064
|
+
)
|
|
1065
|
+
},
|
|
1066
|
+
key
|
|
1067
|
+
))
|
|
789
1068
|
}
|
|
790
1069
|
)
|
|
791
1070
|
]
|
|
792
1071
|
}
|
|
793
1072
|
),
|
|
794
1073
|
/* @__PURE__ */ jsx(
|
|
795
|
-
|
|
1074
|
+
"div",
|
|
796
1075
|
{
|
|
797
1076
|
...{
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1077
|
+
className: faded()
|
|
1078
|
+
},
|
|
1079
|
+
children: /* @__PURE__ */ jsx(
|
|
1080
|
+
FormSubdomainButton,
|
|
1081
|
+
{
|
|
1082
|
+
...{
|
|
1083
|
+
disabled,
|
|
1084
|
+
style,
|
|
1085
|
+
submitting: formState == null ? void 0 : formState.isSubmitting,
|
|
1086
|
+
text: last ? "Submit" : "Next"
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
)
|
|
803
1090
|
}
|
|
804
1091
|
)
|
|
805
1092
|
]
|
|
@@ -811,6 +1098,7 @@ const FormSubdomain = ({
|
|
|
811
1098
|
button,
|
|
812
1099
|
disabled,
|
|
813
1100
|
fields,
|
|
1101
|
+
focus,
|
|
814
1102
|
integrations,
|
|
815
1103
|
onCheckout,
|
|
816
1104
|
onError = () => {
|
|
@@ -819,6 +1107,7 @@ const FormSubdomain = ({
|
|
|
819
1107
|
},
|
|
820
1108
|
params,
|
|
821
1109
|
preview,
|
|
1110
|
+
step: start = 0,
|
|
822
1111
|
style,
|
|
823
1112
|
tracking
|
|
824
1113
|
}) => {
|
|
@@ -827,7 +1116,17 @@ const FormSubdomain = ({
|
|
|
827
1116
|
const searchParams = useSearchParams();
|
|
828
1117
|
const token = searchParams.get("drwbrdg_pre");
|
|
829
1118
|
const [data, setData] = useState({});
|
|
830
|
-
const [step, setStep] = useState(
|
|
1119
|
+
const [step, setStep] = useState(start);
|
|
1120
|
+
const sections = sectionsOf(fields);
|
|
1121
|
+
const slugs = sections.flatMap((section) => ((section == null ? void 0 : section.fields) || []).map((field) => field == null ? void 0 : field.slug));
|
|
1122
|
+
const merge = (object = {}) => ({
|
|
1123
|
+
...data,
|
|
1124
|
+
...object,
|
|
1125
|
+
fields: {
|
|
1126
|
+
...data.fields,
|
|
1127
|
+
...object.fields
|
|
1128
|
+
}
|
|
1129
|
+
});
|
|
831
1130
|
const onSubmit = useCallback(
|
|
832
1131
|
async (values) => {
|
|
833
1132
|
var _a2, _b2;
|
|
@@ -844,7 +1143,6 @@ const FormSubdomain = ({
|
|
|
844
1143
|
const response = await request({
|
|
845
1144
|
body: {
|
|
846
1145
|
...values,
|
|
847
|
-
entries: 1,
|
|
848
1146
|
preview,
|
|
849
1147
|
recaptcha,
|
|
850
1148
|
tracking: (_b2 = tracking == null ? void 0 : tracking.context) == null ? void 0 : _b2.call(tracking)
|
|
@@ -929,26 +1227,40 @@ const FormSubdomain = ({
|
|
|
929
1227
|
"form-subdomain-age"
|
|
930
1228
|
)
|
|
931
1229
|
] : [],
|
|
932
|
-
/* @__PURE__ */ jsx(
|
|
933
|
-
|
|
1230
|
+
...sections.map((section, index) => /* @__PURE__ */ jsx(
|
|
1231
|
+
FormSubdomainSection,
|
|
934
1232
|
{
|
|
935
1233
|
...{
|
|
1234
|
+
// Back moves between sections; it never returns into the location or age step.
|
|
1235
|
+
back: index > 0 ? (object) => {
|
|
1236
|
+
setData(merge(object));
|
|
1237
|
+
setStep(step - 1);
|
|
1238
|
+
} : null,
|
|
936
1239
|
button,
|
|
937
|
-
callback: async (object) =>
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1240
|
+
callback: async (object) => {
|
|
1241
|
+
const merged = merge(object);
|
|
1242
|
+
if (index < sections.length - 1) {
|
|
1243
|
+
setData(merged);
|
|
1244
|
+
setStep(step + 1);
|
|
1245
|
+
return;
|
|
1246
|
+
}
|
|
1247
|
+
await onSubmit(merged);
|
|
1248
|
+
},
|
|
941
1249
|
disabled,
|
|
1250
|
+
focus,
|
|
1251
|
+
initial: data,
|
|
1252
|
+
last: index === sections.length - 1,
|
|
942
1253
|
preview,
|
|
1254
|
+
section,
|
|
1255
|
+
slugs,
|
|
943
1256
|
style,
|
|
944
1257
|
values: {
|
|
945
|
-
agreements
|
|
946
|
-
fields
|
|
1258
|
+
agreements
|
|
947
1259
|
}
|
|
948
1260
|
}
|
|
949
1261
|
},
|
|
950
|
-
"form-subdomain-
|
|
951
|
-
)
|
|
1262
|
+
"form-subdomain-section-" + section.id
|
|
1263
|
+
))
|
|
952
1264
|
];
|
|
953
1265
|
return /* @__PURE__ */ jsx(
|
|
954
1266
|
"div",
|
|
@@ -970,7 +1282,6 @@ const FormSubdomain = ({
|
|
|
970
1282
|
};
|
|
971
1283
|
var form_subdomain_default = FormSubdomain;
|
|
972
1284
|
export {
|
|
973
|
-
FormSubdomainHeader,
|
|
974
1285
|
FormSubdomainMessage,
|
|
975
1286
|
FormSubdomainSubmission,
|
|
976
1287
|
form_subdomain_default as default
|