@saasquatch/mint-components 2.2.0-3 → 2.2.0-4
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/cjs/sqm-big-stat_46.cjs.entry.js +10 -0
- package/dist/cjs/sqm-email-verification_2.cjs.entry.js +28 -10
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +29 -11
- package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +11 -1
- package/dist/esm/{keys-d7c5c851.js → keys-1054056a.js} +1 -1
- package/dist/esm/sqm-banking-info-form_10.entry.js +1 -1
- package/dist/esm/sqm-big-stat_46.entry.js +11 -1
- package/dist/esm/sqm-code-verification.entry.js +1 -1
- package/dist/esm/sqm-email-verification_2.entry.js +30 -12
- package/dist/esm/sqm-widget-verification-controller.entry.js +1 -1
- package/dist/esm-es5/{keys-d7c5c851.js → keys-1054056a.js} +1 -1
- package/dist/esm-es5/sqm-banking-info-form_10.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_46.entry.js +1 -1
- package/dist/esm-es5/sqm-code-verification.entry.js +1 -1
- package/dist/esm-es5/sqm-email-verification_2.entry.js +1 -1
- package/dist/esm-es5/sqm-widget-verification-controller.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-fe944f94.system.entry.js → p-121119ac.system.entry.js} +1 -1
- package/dist/mint-components/{p-45d7412b.entry.js → p-155963e0.entry.js} +7 -7
- package/dist/mint-components/p-1c413a06.system.js +1 -1
- package/dist/mint-components/p-39d9a60a.system.entry.js +1 -0
- package/dist/mint-components/p-4691e9d5.system.js +1 -0
- package/dist/mint-components/{p-1bff74c0.js → p-4f9dc974.js} +1 -1
- package/dist/mint-components/{p-440d3788.entry.js → p-608de854.entry.js} +1 -1
- package/dist/mint-components/{p-ecdbe09b.system.entry.js → p-747b3040.system.entry.js} +1 -1
- package/dist/mint-components/{p-6d15ce09.system.entry.js → p-81e622bd.system.entry.js} +1 -1
- package/dist/mint-components/{p-d43c728e.entry.js → p-8e66e608.entry.js} +2 -2
- package/dist/mint-components/{p-70a90ad8.system.entry.js → p-c0cf8d32.system.entry.js} +1 -1
- package/dist/mint-components/{p-a67f2ccf.entry.js → p-c945c366.entry.js} +1 -1
- package/dist/mint-components/{p-36b91873.entry.js → p-fe5a6bbe.entry.js} +2 -2
- package/docs/docs.docx +0 -0
- package/package.json +1 -1
- package/dist/mint-components/p-4c47beb0.system.js +0 -1
- package/dist/mint-components/p-7caaeaf2.system.entry.js +0 -1
|
@@ -7973,6 +7973,16 @@ function useWidgetVerification() {
|
|
|
7973
7973
|
namespace: keys.SHOW_CODE_NAMESPACE,
|
|
7974
7974
|
initialValue: false,
|
|
7975
7975
|
});
|
|
7976
|
+
// Register the verification-email namespace at the widget-verification
|
|
7977
|
+
// host so that <sqm-email-verification> (writer) and <sqm-code-verification>
|
|
7978
|
+
// (reader) can communicate. This registration was accidentally removed in
|
|
7979
|
+
// commit cfbfad9 ("a bunch of review and cleanup of unused code"), which
|
|
7980
|
+
// caused setEmail() in the email step to throw TypeError and aborted the
|
|
7981
|
+
// rest of submitEmail before it could call setShowCode(true).
|
|
7982
|
+
index_module.In({
|
|
7983
|
+
namespace: keys.VERIFICATION_EMAIL_NAMESPACE,
|
|
7984
|
+
initialValue: undefined,
|
|
7985
|
+
});
|
|
7976
7986
|
const setContext = index_module.En(keys.VERIFICATION_PARENT_NAMESPACE);
|
|
7977
7987
|
const [loading, setLoading] = domContextHooks_module.useState(true);
|
|
7978
7988
|
const [showPartnerModal, setShowPartnerModal] = index_module.In({
|
|
@@ -74,8 +74,12 @@ function useUpsertUserEmail() {
|
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
function useWidgetEmailVerification(props) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
// NOTE: useSetParent (not useParent) so that calling these setters is a
|
|
78
|
+
// no-op fallback instead of throwing TypeError when the parent provider
|
|
79
|
+
// hasn't connected yet (e.g. inside <sl-dialog> on first paint). Throwing
|
|
80
|
+
// here would skip setLoading(false) and leave the button stuck spinning.
|
|
81
|
+
const setShowCode = index_module.En(keys.SHOW_CODE_NAMESPACE);
|
|
82
|
+
const setEmail = index_module.En(keys.VERIFICATION_EMAIL_NAMESPACE);
|
|
79
83
|
const [emailExists, setEmailExists] = domContextHooks_module.useState(false);
|
|
80
84
|
const [error, setError] = domContextHooks_module.useState(false);
|
|
81
85
|
const [mutationError, setMutationError] = domContextHooks_module.useState(false);
|
|
@@ -94,29 +98,43 @@ function useWidgetEmailVerification(props) {
|
|
|
94
98
|
setLoading(false);
|
|
95
99
|
}, [initialized]);
|
|
96
100
|
const submitEmail = async (e) => {
|
|
101
|
+
var _a, _b, _c, _d;
|
|
97
102
|
e.preventDefault();
|
|
98
103
|
if (!(data === null || data === void 0 ? void 0 : data.viewer))
|
|
99
104
|
return;
|
|
100
105
|
setLoading(true);
|
|
101
|
-
|
|
106
|
+
setMutationError(false);
|
|
107
|
+
setError(false);
|
|
108
|
+
// Resolve the address we'll actually verify. If the user already has an
|
|
109
|
+
// email on record, use it; otherwise pull the typed value from the form
|
|
110
|
+
// and upsert it. We capture this AFTER the upsert so the value we hand
|
|
111
|
+
// off to the code-verification step is never null.
|
|
112
|
+
let toAddress = data.viewer.email;
|
|
102
113
|
if (!toAddress) {
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
const newEmail = formData.get("email").toString();
|
|
114
|
+
const formData = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.formData;
|
|
115
|
+
const newEmail = (_c = (_b = formData === null || formData === void 0 ? void 0 : formData.get("email")) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
|
|
106
116
|
if (!emailRegex.test(newEmail)) {
|
|
107
117
|
setError(true);
|
|
118
|
+
setLoading(false);
|
|
108
119
|
return;
|
|
109
120
|
}
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
121
|
+
const upsertResult = await upsertUserEmail(newEmail);
|
|
122
|
+
if (!upsertResult || !((_d = upsertResult.upsertUser) === null || _d === void 0 ? void 0 : _d.email)) {
|
|
112
123
|
setError(true);
|
|
124
|
+
setLoading(false);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
toAddress = upsertResult.upsertUser.email;
|
|
113
128
|
}
|
|
114
129
|
// UI should not allow this call til initialisation is done
|
|
115
|
-
if (!initialized)
|
|
130
|
+
if (!initialized) {
|
|
131
|
+
setLoading(false);
|
|
116
132
|
return;
|
|
133
|
+
}
|
|
117
134
|
const result = await sendEmail();
|
|
118
|
-
if (!result || !result.success)
|
|
135
|
+
if (!result || !result.success) {
|
|
119
136
|
setMutationError(true);
|
|
137
|
+
}
|
|
120
138
|
else {
|
|
121
139
|
// This is used to let the code verification widget know an email was already sent
|
|
122
140
|
setEmail(toAddress);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMutation,
|
|
1
|
+
import { useMutation, useQuery, useSetParent, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useEffect, useState } from "@saasquatch/universal-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
4
|
import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE } from "../keys";
|
|
@@ -60,8 +60,12 @@ export function useUpsertUserEmail() {
|
|
|
60
60
|
];
|
|
61
61
|
}
|
|
62
62
|
export function useWidgetEmailVerification(props) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
// NOTE: useSetParent (not useParent) so that calling these setters is a
|
|
64
|
+
// no-op fallback instead of throwing TypeError when the parent provider
|
|
65
|
+
// hasn't connected yet (e.g. inside <sl-dialog> on first paint). Throwing
|
|
66
|
+
// here would skip setLoading(false) and leave the button stuck spinning.
|
|
67
|
+
const setShowCode = useSetParent(SHOW_CODE_NAMESPACE);
|
|
68
|
+
const setEmail = useSetParent(VERIFICATION_EMAIL_NAMESPACE);
|
|
65
69
|
const [emailExists, setEmailExists] = useState(false);
|
|
66
70
|
const [error, setError] = useState(false);
|
|
67
71
|
const [mutationError, setMutationError] = useState(false);
|
|
@@ -80,29 +84,43 @@ export function useWidgetEmailVerification(props) {
|
|
|
80
84
|
setLoading(false);
|
|
81
85
|
}, [initialized]);
|
|
82
86
|
const submitEmail = async (e) => {
|
|
87
|
+
var _a, _b, _c, _d;
|
|
83
88
|
e.preventDefault();
|
|
84
89
|
if (!(data === null || data === void 0 ? void 0 : data.viewer))
|
|
85
90
|
return;
|
|
86
91
|
setLoading(true);
|
|
87
|
-
|
|
92
|
+
setMutationError(false);
|
|
93
|
+
setError(false);
|
|
94
|
+
// Resolve the address we'll actually verify. If the user already has an
|
|
95
|
+
// email on record, use it; otherwise pull the typed value from the form
|
|
96
|
+
// and upsert it. We capture this AFTER the upsert so the value we hand
|
|
97
|
+
// off to the code-verification step is never null.
|
|
98
|
+
let toAddress = data.viewer.email;
|
|
88
99
|
if (!toAddress) {
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
const newEmail = formData.get("email").toString();
|
|
100
|
+
const formData = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.formData;
|
|
101
|
+
const newEmail = (_c = (_b = formData === null || formData === void 0 ? void 0 : formData.get("email")) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
|
|
92
102
|
if (!emailRegex.test(newEmail)) {
|
|
93
103
|
setError(true);
|
|
104
|
+
setLoading(false);
|
|
94
105
|
return;
|
|
95
106
|
}
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
107
|
+
const upsertResult = await upsertUserEmail(newEmail);
|
|
108
|
+
if (!upsertResult || !((_d = upsertResult.upsertUser) === null || _d === void 0 ? void 0 : _d.email)) {
|
|
98
109
|
setError(true);
|
|
110
|
+
setLoading(false);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
toAddress = upsertResult.upsertUser.email;
|
|
99
114
|
}
|
|
100
115
|
// UI should not allow this call til initialisation is done
|
|
101
|
-
if (!initialized)
|
|
116
|
+
if (!initialized) {
|
|
117
|
+
setLoading(false);
|
|
102
118
|
return;
|
|
119
|
+
}
|
|
103
120
|
const result = await sendEmail();
|
|
104
|
-
if (!result || !result.success)
|
|
121
|
+
if (!result || !result.success) {
|
|
105
122
|
setMutationError(true);
|
|
123
|
+
}
|
|
106
124
|
else {
|
|
107
125
|
// This is used to let the code verification widget know an email was already sent
|
|
108
126
|
setEmail(toAddress);
|
|
@@ -2,7 +2,7 @@ import { useLazyQuery, useParentState, useSetParent, } from "@saasquatch/compone
|
|
|
2
2
|
import { useState } from "@saasquatch/stencil-hooks";
|
|
3
3
|
import { useEffect } from "@saasquatch/universal-hooks";
|
|
4
4
|
import { gql } from "graphql-request";
|
|
5
|
-
import { PARTNER_CREATED_NAMESPACE, SHOW_CODE_NAMESPACE, SHOW_PARTNER_MODAL_NAMESPACE, VERIFICATION_PARENT_NAMESPACE, } from "./keys";
|
|
5
|
+
import { PARTNER_CREATED_NAMESPACE, SHOW_CODE_NAMESPACE, SHOW_PARTNER_MODAL_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, VERIFICATION_PARENT_NAMESPACE, } from "./keys";
|
|
6
6
|
const USER_LOOKUP = gql `
|
|
7
7
|
query checkUserVerification {
|
|
8
8
|
viewer {
|
|
@@ -27,6 +27,16 @@ export function useWidgetVerification() {
|
|
|
27
27
|
namespace: SHOW_CODE_NAMESPACE,
|
|
28
28
|
initialValue: false,
|
|
29
29
|
});
|
|
30
|
+
// Register the verification-email namespace at the widget-verification
|
|
31
|
+
// host so that <sqm-email-verification> (writer) and <sqm-code-verification>
|
|
32
|
+
// (reader) can communicate. This registration was accidentally removed in
|
|
33
|
+
// commit cfbfad9 ("a bunch of review and cleanup of unused code"), which
|
|
34
|
+
// caused setEmail() in the email step to throw TypeError and aborted the
|
|
35
|
+
// rest of submitEmail before it could call setShowCode(true).
|
|
36
|
+
useParentState({
|
|
37
|
+
namespace: VERIFICATION_EMAIL_NAMESPACE,
|
|
38
|
+
initialValue: undefined,
|
|
39
|
+
});
|
|
30
40
|
const setContext = useSetParent(VERIFICATION_PARENT_NAMESPACE);
|
|
31
41
|
const [loading, setLoading] = useState(true);
|
|
32
42
|
const [showPartnerModal, setShowPartnerModal] = useParentState({
|
|
@@ -5,4 +5,4 @@ const VERIFICATION_EMAIL_NAMESPACE = "sq:verification-email";
|
|
|
5
5
|
const VERIFICATION_PARENT_NAMESPACE = "sq:verification-context";
|
|
6
6
|
const VERIFICATION_EVENT_KEY = "sq:code-verified";
|
|
7
7
|
|
|
8
|
-
export { PARTNER_CREATED_NAMESPACE as P, SHOW_CODE_NAMESPACE as S, VERIFICATION_PARENT_NAMESPACE as V,
|
|
8
|
+
export { PARTNER_CREATED_NAMESPACE as P, SHOW_CODE_NAMESPACE as S, VERIFICATION_PARENT_NAMESPACE as V, VERIFICATION_EMAIL_NAMESPACE as a, SHOW_PARTNER_MODAL_NAMESPACE as b, VERIFICATION_EVENT_KEY as c };
|
|
@@ -15,7 +15,7 @@ import { g as generateUserError } from './useReferralTable-35e6d4c1.js';
|
|
|
15
15
|
import { a as INDIRECT_TAX_SPAIN_REGIONS, b as INDIRECT_TAX_PROVINCES, O as OtherRegionSlotView, I as InvoiceTableView, v as vatLabels, A as ADDRESS_REGIONS, U as UserInfoFormView } from './sqm-user-info-form-view-e732dc4d.js';
|
|
16
16
|
import { t as taxTypeToName, a as validTaxDocument, g as getCountryObj, o as objectIsFull } from './utils-8267d3d8.js';
|
|
17
17
|
import { F as FORM_STEPS, a as TAX_FORM_CONTEXT_NAMESPACE, S as SORTED_COUNTRIES_NAMESPACE, c as USER_QUERY_NAMESPACE, T as TAX_CONTEXT_NAMESPACE, f as FINANCE_NETWORK_SETTINGS_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE, d as COUNTRIES_QUERY_NAMESPACE, C as CURRENCIES_NAMESPACE } from './data-33c16dff.js';
|
|
18
|
-
import { c as VERIFICATION_EVENT_KEY } from './keys-
|
|
18
|
+
import { c as VERIFICATION_EVENT_KEY } from './keys-1054056a.js';
|
|
19
19
|
import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
|
|
20
20
|
import { a as useVeriffApp, g as getStatus, V as VERIFF_COMPLETE_EVENT_KEY } from './usePayoutStatus-fa504d49.js';
|
|
21
21
|
|
|
@@ -27,7 +27,7 @@ import { u as useDemoBigStat, V as useBigStat, B as BigStatView, C as CardFeedVi
|
|
|
27
27
|
import './sqm-portal-container-view-a8c708cd.js';
|
|
28
28
|
import { g as getCountryObj, L as LoadingView } from './utils-8267d3d8.js';
|
|
29
29
|
import { T as TAX_CONTEXT_NAMESPACE, a as TAX_FORM_CONTEXT_NAMESPACE, U as USER_FORM_CONTEXT_NAMESPACE, C as CURRENCIES_NAMESPACE, b as COUNTRIES_NAMESPACE, S as SORTED_COUNTRIES_NAMESPACE, c as USER_QUERY_NAMESPACE, G as GET_USER$2, d as COUNTRIES_QUERY_NAMESPACE, e as GET_COUNTRIES, f as FINANCE_NETWORK_SETTINGS_NAMESPACE, g as GET_FINANCE_NETWORK_SETTINGS, h as CURRENCIES_QUERY_NAMESPACE, i as GET_CURRENCIES } from './data-33c16dff.js';
|
|
30
|
-
import { S as SHOW_CODE_NAMESPACE, a as SHOW_PARTNER_MODAL_NAMESPACE, P as PARTNER_CREATED_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE
|
|
30
|
+
import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE, b as SHOW_PARTNER_MODAL_NAMESPACE, P as PARTNER_CREATED_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-1054056a.js';
|
|
31
31
|
import './eventKeys-f76b6a03.js';
|
|
32
32
|
import { u as usePayoutStatus } from './usePayoutStatus-fa504d49.js';
|
|
33
33
|
import { p as parseStates } from './parseStates-ed75e224.js';
|
|
@@ -7969,6 +7969,16 @@ function useWidgetVerification() {
|
|
|
7969
7969
|
namespace: SHOW_CODE_NAMESPACE,
|
|
7970
7970
|
initialValue: false,
|
|
7971
7971
|
});
|
|
7972
|
+
// Register the verification-email namespace at the widget-verification
|
|
7973
|
+
// host so that <sqm-email-verification> (writer) and <sqm-code-verification>
|
|
7974
|
+
// (reader) can communicate. This registration was accidentally removed in
|
|
7975
|
+
// commit cfbfad9 ("a bunch of review and cleanup of unused code"), which
|
|
7976
|
+
// caused setEmail() in the email step to throw TypeError and aborted the
|
|
7977
|
+
// rest of submitEmail before it could call setShowCode(true).
|
|
7978
|
+
In({
|
|
7979
|
+
namespace: VERIFICATION_EMAIL_NAMESPACE,
|
|
7980
|
+
initialValue: undefined,
|
|
7981
|
+
});
|
|
7972
7982
|
const setContext = En(VERIFICATION_PARENT_NAMESPACE);
|
|
7973
7983
|
const [loading, setLoading] = useState(true);
|
|
7974
7984
|
const [showPartnerModal, setShowPartnerModal] = In({
|
|
@@ -7,7 +7,7 @@ import { g as getProps } from './utils-334c1e34.js';
|
|
|
7
7
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
8
8
|
import { E as ErrorStyles } from './mixins-f750863a.js';
|
|
9
9
|
import { T as TextSpanView } from './sqm-text-span-view-4db9e33f.js';
|
|
10
|
-
import {
|
|
10
|
+
import { a as VERIFICATION_EMAIL_NAMESPACE, S as SHOW_CODE_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-1054056a.js';
|
|
11
11
|
import { u as useVerificationEmail } from './useVerificationEmail-cb3d51e3.js';
|
|
12
12
|
|
|
13
13
|
const style = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { h, r as registerInstance } from './index-38ad4957.js';
|
|
2
2
|
import { i as intl } from './global-39f55ec2.js';
|
|
3
3
|
import { k as useState, f as useEffect, n as h$1, u as useMemo } from './dom-context-hooks.module-50442785.js';
|
|
4
|
-
import { d as dist,
|
|
4
|
+
import { d as dist, r as En, w as wn, J, $ as $e, i as isDemo, L } from './index.module-cede12c6.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
6
|
import { g as getProps } from './utils-334c1e34.js';
|
|
7
7
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
8
8
|
import { T as TextSpanView } from './sqm-text-span-view-4db9e33f.js';
|
|
9
9
|
import { g as GET_FINANCE_NETWORK_SETTINGS } from './data-33c16dff.js';
|
|
10
10
|
import { a as PartnerInfoModalContentView, P as PartnerInfoModalView } from './sqm-partner-info-modal-view-bd8ff1c1.js';
|
|
11
|
-
import { S as SHOW_CODE_NAMESPACE,
|
|
11
|
+
import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE, P as PARTNER_CREATED_NAMESPACE } from './keys-1054056a.js';
|
|
12
12
|
import { T as TAX_FORM_UPDATED_EVENT_KEY } from './eventKeys-f76b6a03.js';
|
|
13
13
|
import { p as parseStates } from './parseStates-ed75e224.js';
|
|
14
14
|
import { u as useVerificationEmail } from './useVerificationEmail-cb3d51e3.js';
|
|
@@ -70,8 +70,12 @@ function useUpsertUserEmail() {
|
|
|
70
70
|
];
|
|
71
71
|
}
|
|
72
72
|
function useWidgetEmailVerification(props) {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
// NOTE: useSetParent (not useParent) so that calling these setters is a
|
|
74
|
+
// no-op fallback instead of throwing TypeError when the parent provider
|
|
75
|
+
// hasn't connected yet (e.g. inside <sl-dialog> on first paint). Throwing
|
|
76
|
+
// here would skip setLoading(false) and leave the button stuck spinning.
|
|
77
|
+
const setShowCode = En(SHOW_CODE_NAMESPACE);
|
|
78
|
+
const setEmail = En(VERIFICATION_EMAIL_NAMESPACE);
|
|
75
79
|
const [emailExists, setEmailExists] = useState(false);
|
|
76
80
|
const [error, setError] = useState(false);
|
|
77
81
|
const [mutationError, setMutationError] = useState(false);
|
|
@@ -90,29 +94,43 @@ function useWidgetEmailVerification(props) {
|
|
|
90
94
|
setLoading(false);
|
|
91
95
|
}, [initialized]);
|
|
92
96
|
const submitEmail = async (e) => {
|
|
97
|
+
var _a, _b, _c, _d;
|
|
93
98
|
e.preventDefault();
|
|
94
99
|
if (!(data === null || data === void 0 ? void 0 : data.viewer))
|
|
95
100
|
return;
|
|
96
101
|
setLoading(true);
|
|
97
|
-
|
|
102
|
+
setMutationError(false);
|
|
103
|
+
setError(false);
|
|
104
|
+
// Resolve the address we'll actually verify. If the user already has an
|
|
105
|
+
// email on record, use it; otherwise pull the typed value from the form
|
|
106
|
+
// and upsert it. We capture this AFTER the upsert so the value we hand
|
|
107
|
+
// off to the code-verification step is never null.
|
|
108
|
+
let toAddress = data.viewer.email;
|
|
98
109
|
if (!toAddress) {
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const newEmail = formData.get("email").toString();
|
|
110
|
+
const formData = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.formData;
|
|
111
|
+
const newEmail = (_c = (_b = formData === null || formData === void 0 ? void 0 : formData.get("email")) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "";
|
|
102
112
|
if (!emailRegex.test(newEmail)) {
|
|
103
113
|
setError(true);
|
|
114
|
+
setLoading(false);
|
|
104
115
|
return;
|
|
105
116
|
}
|
|
106
|
-
const
|
|
107
|
-
if (!
|
|
117
|
+
const upsertResult = await upsertUserEmail(newEmail);
|
|
118
|
+
if (!upsertResult || !((_d = upsertResult.upsertUser) === null || _d === void 0 ? void 0 : _d.email)) {
|
|
108
119
|
setError(true);
|
|
120
|
+
setLoading(false);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
toAddress = upsertResult.upsertUser.email;
|
|
109
124
|
}
|
|
110
125
|
// UI should not allow this call til initialisation is done
|
|
111
|
-
if (!initialized)
|
|
126
|
+
if (!initialized) {
|
|
127
|
+
setLoading(false);
|
|
112
128
|
return;
|
|
129
|
+
}
|
|
113
130
|
const result = await sendEmail();
|
|
114
|
-
if (!result || !result.success)
|
|
131
|
+
if (!result || !result.success) {
|
|
115
132
|
setMutationError(true);
|
|
133
|
+
}
|
|
116
134
|
else {
|
|
117
135
|
// This is used to let the code verification widget know an email was already sent
|
|
118
136
|
setEmail(toAddress);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h as h$1, c as Host } from './index-38ad4957.js';
|
|
2
2
|
import { b as browser, n as h, k as useState, f as useEffect } from './dom-context-hooks.module-50442785.js';
|
|
3
3
|
import { I as In, b as useCallback, i as isDemo } from './index.module-cede12c6.js';
|
|
4
|
-
import { V as VERIFICATION_PARENT_NAMESPACE } from './keys-
|
|
4
|
+
import { V as VERIFICATION_PARENT_NAMESPACE } from './keys-1054056a.js';
|
|
5
5
|
|
|
6
6
|
const debug = browser("sq:widget-verification");
|
|
7
7
|
function useTemplateChildren({ parent, callback }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var SHOW_CODE_NAMESPACE="sq:code-verification";var SHOW_PARTNER_MODAL_NAMESPACE="sq:show-partner-modal";var PARTNER_CREATED_NAMESPACE="sq:partner-created";var VERIFICATION_EMAIL_NAMESPACE="sq:verification-email";var VERIFICATION_PARENT_NAMESPACE="sq:verification-context";var VERIFICATION_EVENT_KEY="sq:code-verified";export{PARTNER_CREATED_NAMESPACE as P,SHOW_CODE_NAMESPACE as S,VERIFICATION_PARENT_NAMESPACE as V,
|
|
1
|
+
var SHOW_CODE_NAMESPACE="sq:code-verification";var SHOW_PARTNER_MODAL_NAMESPACE="sq:show-partner-modal";var PARTNER_CREATED_NAMESPACE="sq:partner-created";var VERIFICATION_EMAIL_NAMESPACE="sq:verification-email";var VERIFICATION_PARENT_NAMESPACE="sq:verification-context";var VERIFICATION_EVENT_KEY="sq:code-verified";export{PARTNER_CREATED_NAMESPACE as P,SHOW_CODE_NAMESPACE as S,VERIFICATION_PARENT_NAMESPACE as V,VERIFICATION_EMAIL_NAMESPACE as a,SHOW_PARTNER_MODAL_NAMESPACE as b,VERIFICATION_EVENT_KEY as c};
|