@saasquatch/mint-components 1.12.0-1 → 1.12.0-10
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/{ShadowViewAddon-88821c64.js → ShadowViewAddon-040cffad.js} +6 -3
- package/dist/cjs/extractProps-fd93ba62.js +21 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/sqm-banking-info-form_16.cjs.entry.js +91 -72
- package/dist/cjs/sqm-big-stat_39.cjs.entry.js +128 -63
- package/dist/cjs/sqm-code-verification.cjs.entry.js +67 -77
- package/dist/cjs/sqm-email-verification.cjs.entry.js +158 -12
- package/dist/cjs/{sqm-invoice-table-view-ce9a34ac.js → sqm-invoice-table-view-c58966f8.js} +79 -0
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +56 -14
- package/dist/cjs/sqm-widget-verification-internal.cjs.entry.js +81 -11
- package/dist/cjs/sqm-widget-verification.cjs.entry.js +102 -19
- package/dist/cjs/usePayoutStatus-b9fb7399.js +70 -0
- package/dist/cjs/useVerificationEmail-6aacdb71.js +169 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/sqm-big-stat/useBigStat.js +6 -3
- package/dist/collection/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.js +1 -2
- package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll-view.js +1 -0
- package/dist/collection/components/sqm-payout-button-scroll/sqm-payout-button-scroll.js +16 -3
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.js +9 -2
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.js +20 -10
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js +34 -63
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.js +38 -29
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.js +23 -3
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.js +17 -4
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js +65 -11
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +76 -20
- package/dist/collection/components/sqm-widget-verification/sqm-widget-verification-internal.js +327 -15
- package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +447 -22
- package/dist/collection/components/sqm-widget-verification/useVerificationEmail.js +165 -0
- package/dist/collection/components/tax-and-cash/BankingForm.stories.js +1 -0
- package/dist/collection/components/tax-and-cash/TaxForm.stories.js +78 -0
- package/dist/collection/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form.js +2 -1
- package/dist/collection/components/tax-and-cash/sqm-banking-info-form/useBankingInfoForm.js +7 -0
- package/dist/collection/components/tax-and-cash/sqm-docusign-form/docusign-iframe/DocusignIframe.js +0 -1
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.js +10 -0
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +72 -13
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +146 -9
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +30 -15
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +6 -0
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js +8 -8
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/useTaxAndCash.js +2 -2
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.js +22 -16
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +99 -88
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +8 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +16 -11
- package/dist/esm/{ShadowViewAddon-65c8679e.js → ShadowViewAddon-69b61037.js} +6 -3
- package/dist/esm/extractProps-ae1afbb3.js +19 -0
- package/dist/esm/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/sqm-banking-info-form_16.entry.js +91 -72
- package/dist/esm/sqm-big-stat_39.entry.js +127 -62
- package/dist/esm/sqm-code-verification.entry.js +69 -79
- package/dist/esm/sqm-email-verification.entry.js +159 -13
- package/dist/esm/{sqm-invoice-table-view-08c03ba7.js → sqm-invoice-table-view-d1cfdaf4.js} +79 -0
- package/dist/esm/sqm-stencilbook.entry.js +56 -14
- package/dist/esm/sqm-widget-verification-internal.entry.js +84 -14
- package/dist/esm/sqm-widget-verification.entry.js +104 -21
- package/dist/esm/usePayoutStatus-1a635054.js +67 -0
- package/dist/esm/useVerificationEmail-c32696ba.js +167 -0
- package/dist/esm-es5/ShadowViewAddon-69b61037.js +1 -0
- package/dist/esm-es5/extractProps-ae1afbb3.js +1 -0
- package/dist/esm-es5/{keys-a1496e39.js → keys-db1897ae.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-banking-info-form_16.entry.js +1 -1
- package/dist/esm-es5/sqm-big-stat_39.entry.js +1 -1
- package/dist/esm-es5/sqm-code-verification.entry.js +1 -1
- package/dist/esm-es5/sqm-email-verification.entry.js +1 -1
- package/dist/esm-es5/sqm-invoice-table-view-d1cfdaf4.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/esm-es5/sqm-widget-verification-internal.entry.js +1 -1
- package/dist/esm-es5/sqm-widget-verification.entry.js +1 -1
- package/dist/esm-es5/usePayoutStatus-1a635054.js +1 -0
- package/dist/esm-es5/useVerificationEmail-c32696ba.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/p-15c7a1d2.system.entry.js +1 -0
- package/dist/mint-components/p-1712a9fd.entry.js +11 -0
- package/dist/mint-components/p-1e616d45.system.js +1 -0
- package/dist/mint-components/{p-721a89c6.entry.js → p-24092973.entry.js} +2 -2
- package/dist/mint-components/p-26468242.js +1 -0
- package/dist/mint-components/p-331d060e.entry.js +223 -0
- package/dist/mint-components/p-39840341.js +1 -0
- package/dist/mint-components/p-4364001c.entry.js +12 -0
- package/dist/mint-components/p-4bd7a472.js +1 -0
- package/dist/mint-components/p-517224ef.js +19 -0
- package/dist/mint-components/p-5a23b560.system.entry.js +1 -0
- package/dist/mint-components/p-8300d8c8.system.js +1 -0
- package/dist/mint-components/p-8bddb468.system.entry.js +1 -0
- package/dist/mint-components/p-9596e97c.system.entry.js +1 -0
- package/dist/mint-components/p-974070c4.system.entry.js +1 -0
- package/dist/mint-components/{p-b651706a.js → p-9eae245f.js} +6 -3
- package/dist/mint-components/p-a8645c1b.system.js +1 -0
- package/dist/mint-components/p-b2a99637.system.js +1 -0
- package/dist/mint-components/{p-66a04cca.system.entry.js → p-b62faaa5.system.entry.js} +1 -1
- package/dist/mint-components/p-c41e1df8.entry.js +195 -0
- package/dist/mint-components/p-c510fb88.entry.js +1 -0
- package/dist/mint-components/p-ca809fdd.system.js +1 -1
- package/dist/mint-components/p-d7806f31.js +48 -0
- package/dist/mint-components/p-e01ac27c.system.js +1 -0
- package/dist/mint-components/p-e45a8501.system.entry.js +1 -0
- package/dist/mint-components/p-e990dc21.system.js +1 -0
- package/dist/mint-components/p-f340214f.entry.js +25 -0
- package/dist/types/components/sqm-payout-button-scroll/PayoutButtonScroll.stories.d.ts +0 -1
- package/dist/types/components/sqm-payout-button-scroll/sqm-payout-button-scroll.d.ts +7 -0
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.d.ts +1 -0
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.d.ts +3 -3
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.d.ts +4 -10
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.d.ts +2 -0
- package/dist/types/components/sqm-widget-verification/sqm-email-verification/WidgetEmailVerification.stories.d.ts +4 -1
- package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification-view.d.ts +6 -1
- package/dist/types/components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.d.ts +10 -2
- package/dist/types/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.d.ts +3 -2
- package/dist/types/components/sqm-widget-verification/sqm-widget-verification-internal.d.ts +15 -0
- package/dist/types/components/sqm-widget-verification/sqm-widget-verification.d.ts +79 -0
- package/dist/types/components/sqm-widget-verification/useVerificationEmail.d.ts +14 -0
- package/dist/types/components/tax-and-cash/TaxForm.stories.d.ts +1 -0
- package/dist/types/components/tax-and-cash/sqm-banking-info-form/sqm-banking-info-form-view.d.ts +1 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/PayoutStatusAlert.stories.d.ts +2 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +12 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +41 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +12 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +6 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.d.ts +2 -2
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard-view.d.ts +10 -3
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +19 -18
- package/dist/types/components.d.ts +366 -92
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/useEmailVerification-30a1c7f6.js +0 -75
- package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +0 -3
- package/dist/esm/useEmailVerification-7135732c.js +0 -72
- package/dist/esm-es5/ShadowViewAddon-65c8679e.js +0 -1
- package/dist/esm-es5/sqm-invoice-table-view-08c03ba7.js +0 -1
- package/dist/esm-es5/useEmailVerification-7135732c.js +0 -1
- package/dist/mint-components/p-117b4705.system.js +0 -1
- package/dist/mint-components/p-1bd0cda8.system.entry.js +0 -1
- package/dist/mint-components/p-1ee62d9f.system.entry.js +0 -1
- package/dist/mint-components/p-1f9a9b70.system.entry.js +0 -1
- package/dist/mint-components/p-23fdd44e.entry.js +0 -1
- package/dist/mint-components/p-36f7caec.system.entry.js +0 -1
- package/dist/mint-components/p-39397731.entry.js +0 -1
- package/dist/mint-components/p-39af4acd.entry.js +0 -240
- package/dist/mint-components/p-4c9b6fbe.system.js +0 -1
- package/dist/mint-components/p-65e2c043.system.js +0 -1
- package/dist/mint-components/p-663303b7.entry.js +0 -8
- package/dist/mint-components/p-6cae44d7.js +0 -1
- package/dist/mint-components/p-7f5c7bf7.system.entry.js +0 -1
- package/dist/mint-components/p-8a337864.js +0 -7
- package/dist/mint-components/p-a02afa72.system.js +0 -1
- package/dist/mint-components/p-a5a9aa07.entry.js +0 -189
- package/dist/mint-components/p-c763c0b2.js +0 -1
- package/dist/mint-components/p-e93e5740.entry.js +0 -1
- package/dist/mint-components/p-e9ca48fc.system.entry.js +0 -1
- package/dist/types/components/sqm-widget-verification/useWidgetVerification.d.ts +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { h, r as registerInstance } from './index-17b4da69.js';
|
|
2
2
|
import { l, k as useState, f as useEffect, n as h$1 } from './stencil-hooks.module-ac12ca1c.js';
|
|
3
3
|
import { i as intl } from './global-6306a9b8.js';
|
|
4
|
-
import { d as dist, M as Mn, D as Dn,
|
|
4
|
+
import { d as dist, M as Mn, D as Dn, i as isDemo, S as Sn } from './index.module-6c840c4e.js';
|
|
5
5
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
6
6
|
import { E as ErrorStyles } from './mixins-f60a614c.js';
|
|
7
7
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
8
8
|
import { g as getProps } from './utils-334c1e34.js';
|
|
9
9
|
import { T as TextSpanView } from './sqm-text-span-view-8d140661.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { a as VERIFICATION_EMAIL_NAMESPACE, S as SHOW_CODE_NAMESPACE, V as VERIFICATION_PARENT_NAMESPACE } from './keys-db1897ae.js';
|
|
11
|
+
import { u as useVerificationEmail } from './useVerificationEmail-c32696ba.js';
|
|
12
12
|
|
|
13
13
|
const style = {
|
|
14
14
|
Wrapper: {
|
|
@@ -92,7 +92,16 @@ function WidgetCodeVerificationView(props) {
|
|
|
92
92
|
id: "resendCodeText",
|
|
93
93
|
defaultMessage: text.resendCodeText,
|
|
94
94
|
}, {
|
|
95
|
-
resendCodeLink: (h("a", { href:
|
|
95
|
+
resendCodeLink: (h("a", { href: "", style: { textDecoration: "none" }, onClick: (e) => {
|
|
96
|
+
e.preventDefault();
|
|
97
|
+
callbacks.resendEmail();
|
|
98
|
+
} }, text.resendCodeLabel)),
|
|
99
|
+
});
|
|
100
|
+
const codeResentSuccessfully = intl.formatMessage({
|
|
101
|
+
id: "codeResentSuccessfully",
|
|
102
|
+
defaultMessage: text.codeResentSuccessfullyText,
|
|
103
|
+
}, {
|
|
104
|
+
email: states.email,
|
|
96
105
|
});
|
|
97
106
|
const inputClass = states.verifyFailed
|
|
98
107
|
? sheet.classes.CodeInputError
|
|
@@ -103,11 +112,14 @@ function WidgetCodeVerificationView(props) {
|
|
|
103
112
|
styleString),
|
|
104
113
|
h("div", { class: sheet.classes.Wrapper },
|
|
105
114
|
h("div", { class: sheet.classes.HeaderContainer },
|
|
106
|
-
h(TextSpanView, { type: "p" },
|
|
107
|
-
|
|
108
|
-
:
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
h(TextSpanView, { type: "p" }, intl.formatMessage({
|
|
116
|
+
id: `emailHeaderText`,
|
|
117
|
+
defaultMessage: states.verifyFailed
|
|
118
|
+
? text.reverifyCodeHeaderText
|
|
119
|
+
: text.verifyCodeHeaderText,
|
|
120
|
+
}, { email: states.email }))),
|
|
121
|
+
states.emailResent && (h("sqm-form-message", { type: "success", exportparts: "successalert-icon" },
|
|
122
|
+
h("b", null, codeResentSuccessfully))),
|
|
111
123
|
h("div", { class: sheet.classes.InputsContainer },
|
|
112
124
|
h("div", { ref: refs.codeWrapperRef, class: sheet.classes.CodeInputContainer },
|
|
113
125
|
h("sl-input", { class: inputClass, name: "code" }),
|
|
@@ -117,45 +129,22 @@ function WidgetCodeVerificationView(props) {
|
|
|
117
129
|
h("sl-input", { class: inputClass, name: "code" }),
|
|
118
130
|
h("sl-input", { class: inputClass, name: "code" })),
|
|
119
131
|
states.verifyFailed && (h("p", { class: sheet.classes.ErrorText }, text.invalidCodeText)),
|
|
120
|
-
h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
|
|
132
|
+
h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, disabled: states.loading || states.initialiseLoading, loading: states.loading || states.initialiseLoading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
|
|
121
133
|
h("div", { class: sheet.classes.FooterContainer },
|
|
122
|
-
h(TextSpanView, { type: "p" }, resendCodeText)
|
|
123
|
-
h(TextSpanView, { type: "p" },
|
|
124
|
-
h("a", { href: "/", style: { textDecoration: "none" } }, text.useDifferentEmailText))))));
|
|
134
|
+
h(TextSpanView, { type: "p" }, resendCodeText)))));
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
// TODO: Move to component-boilerplate
|
|
128
137
|
const VerifyEmailWithCodeMutation = dist.gql `
|
|
129
|
-
mutation
|
|
130
|
-
|
|
138
|
+
mutation submitImpactPublisherEmail2FACode(
|
|
139
|
+
$user: UserIdInput!
|
|
140
|
+
$code: String!
|
|
141
|
+
) {
|
|
142
|
+
submitImpactPublisherEmail2FACode(user: $user, code: $code) {
|
|
131
143
|
verifiedEmail
|
|
132
144
|
accessKey
|
|
133
145
|
}
|
|
134
146
|
}
|
|
135
147
|
`;
|
|
136
|
-
function useCodeVerificationMutation() {
|
|
137
|
-
const user = K();
|
|
138
|
-
const [request, { loading, data, errors }] = xe(VerifyEmailWithCodeMutation);
|
|
139
|
-
const verifyUserWithCodeMutation = async (code) => {
|
|
140
|
-
try {
|
|
141
|
-
const result = await request({
|
|
142
|
-
user: {
|
|
143
|
-
id: user.id,
|
|
144
|
-
accountId: user.accountId,
|
|
145
|
-
},
|
|
146
|
-
code,
|
|
147
|
-
});
|
|
148
|
-
if (result instanceof Error || !result)
|
|
149
|
-
throw new Error();
|
|
150
|
-
return result;
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
console.error("Failed to verify user", e);
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
return [verifyUserWithCodeMutation, { loading, data, errors }];
|
|
158
|
-
}
|
|
159
148
|
function useWidgetCodeVerification(props) {
|
|
160
149
|
const host = l();
|
|
161
150
|
const [_, setShowCode] = Mn(SHOW_CODE_NAMESPACE);
|
|
@@ -164,9 +153,8 @@ function useWidgetCodeVerification(props) {
|
|
|
164
153
|
const [emailResent, setEmailResent] = useState(false);
|
|
165
154
|
const [codeRef, setCodeRef] = useState(null);
|
|
166
155
|
const [validationError, setValidationError] = useState(false);
|
|
167
|
-
|
|
168
|
-
const [
|
|
169
|
-
const [request, { loading: resendLoading, data, errors: resendErrors }] = useVerificationEmailMutation();
|
|
156
|
+
const [emailError, setEmailError] = useState(false);
|
|
157
|
+
const { initialized, send: [sendEmail, { loading: sendLoading, errors: sendErrors }], verify: [verifyEmail, { loading: verifyLoading, errors: verifyErrors }], } = useVerificationEmail();
|
|
170
158
|
useEffect(() => {
|
|
171
159
|
if (!codeRef)
|
|
172
160
|
return;
|
|
@@ -182,7 +170,7 @@ function useWidgetCodeVerification(props) {
|
|
|
182
170
|
}
|
|
183
171
|
});
|
|
184
172
|
element.addEventListener("input", (e) => {
|
|
185
|
-
const input = e.
|
|
173
|
+
const input = e.data;
|
|
186
174
|
if (!input)
|
|
187
175
|
return;
|
|
188
176
|
if (idx === codeElements.length - 1) {
|
|
@@ -192,8 +180,10 @@ function useWidgetCodeVerification(props) {
|
|
|
192
180
|
if (input.length > 1) {
|
|
193
181
|
const rest = input.slice(1);
|
|
194
182
|
e.target.value = input.slice(0, 1);
|
|
195
|
-
codeElements[idx + 1].
|
|
196
|
-
|
|
183
|
+
codeElements[idx + 1].dispatchEvent(new InputEvent("input", {
|
|
184
|
+
inputType: "insertFromPaste",
|
|
185
|
+
data: rest,
|
|
186
|
+
}));
|
|
197
187
|
}
|
|
198
188
|
codeElements[idx + 1].focus();
|
|
199
189
|
});
|
|
@@ -204,14 +194,16 @@ function useWidgetCodeVerification(props) {
|
|
|
204
194
|
setValidationError(false);
|
|
205
195
|
};
|
|
206
196
|
const resendEmail = async () => {
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
197
|
+
// UI should only allow this to be called if initialized, but checking just in case
|
|
198
|
+
if (!initialized)
|
|
199
|
+
return;
|
|
200
|
+
const result = await sendEmail();
|
|
201
|
+
if (!result) {
|
|
202
|
+
setEmailError(true);
|
|
203
|
+
return;
|
|
214
204
|
}
|
|
205
|
+
if (emailSent)
|
|
206
|
+
setEmailResent(true);
|
|
215
207
|
setEmailSent(true);
|
|
216
208
|
};
|
|
217
209
|
const submitCode = async () => {
|
|
@@ -225,16 +217,13 @@ function useWidgetCodeVerification(props) {
|
|
|
225
217
|
codeElements.forEach((element) => {
|
|
226
218
|
code = `${code}${element.value}`;
|
|
227
219
|
});
|
|
220
|
+
// UI should only allow this to be called if initialized, but checking just in case
|
|
221
|
+
if (!initialized)
|
|
222
|
+
return;
|
|
228
223
|
setValidationError(false);
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const event = new CustomEvent(VERIFICATION_EVENT_KEY, {
|
|
233
|
-
detail: { token: res.verifyUserEmail.accessKey },
|
|
234
|
-
composed: true,
|
|
235
|
-
bubbles: true,
|
|
236
|
-
});
|
|
237
|
-
host.dispatchEvent(event);
|
|
224
|
+
const res = await verifyEmail(code);
|
|
225
|
+
if (res === null || res === void 0 ? void 0 : res.success) {
|
|
226
|
+
props.onVerification(res.accessKey);
|
|
238
227
|
reset();
|
|
239
228
|
}
|
|
240
229
|
else {
|
|
@@ -242,10 +231,15 @@ function useWidgetCodeVerification(props) {
|
|
|
242
231
|
}
|
|
243
232
|
};
|
|
244
233
|
useEffect(() => {
|
|
234
|
+
// Wait for mutations to be determined from user lookup
|
|
235
|
+
if (!initialized)
|
|
236
|
+
return;
|
|
245
237
|
// email should already exist if user has completed email-verification
|
|
246
238
|
if (!email)
|
|
247
239
|
resendEmail();
|
|
248
|
-
|
|
240
|
+
else
|
|
241
|
+
setEmailSent(true);
|
|
242
|
+
}, [initialized]);
|
|
249
243
|
return {
|
|
250
244
|
refs: {
|
|
251
245
|
codeWrapperRef: setCodeRef,
|
|
@@ -253,7 +247,9 @@ function useWidgetCodeVerification(props) {
|
|
|
253
247
|
states: {
|
|
254
248
|
email,
|
|
255
249
|
emailResent,
|
|
256
|
-
|
|
250
|
+
resendError: sendErrors || verifyErrors,
|
|
251
|
+
initialiseLoading: !initialized,
|
|
252
|
+
loading: sendLoading || verifyLoading,
|
|
257
253
|
verifyFailed: !!validationError,
|
|
258
254
|
},
|
|
259
255
|
callbacks: {
|
|
@@ -270,7 +266,7 @@ const WidgetCodeVerification = class {
|
|
|
270
266
|
/**
|
|
271
267
|
* @uiName Verify code widget header text
|
|
272
268
|
*/
|
|
273
|
-
this.verifyCodeHeaderText = "Enter the code sent to email
|
|
269
|
+
this.verifyCodeHeaderText = "Enter the code sent to {email} from our referral provider, impact.com.";
|
|
274
270
|
/**
|
|
275
271
|
* @uiName Reverify code widget header text
|
|
276
272
|
*/
|
|
@@ -285,27 +281,16 @@ const WidgetCodeVerification = class {
|
|
|
285
281
|
* @uiName Resend code label
|
|
286
282
|
*/
|
|
287
283
|
this.resendCodeLabel = "Resend code";
|
|
288
|
-
/**
|
|
289
|
-
* The link that appears in the resend code link
|
|
290
|
-
* @uiName Resend code link
|
|
291
|
-
*/
|
|
292
|
-
// AL: TODO connect route to resend verification code
|
|
293
|
-
this.resendCodeLink = "/resend-code";
|
|
294
284
|
/**
|
|
295
285
|
* Link text displayed under verify button
|
|
296
286
|
* @uiName Resend code text
|
|
297
287
|
*/
|
|
298
288
|
this.codeResentSuccessfullyText = "Another code has been sent to {email}";
|
|
299
|
-
/**
|
|
300
|
-
* Link text displayed under the verify button
|
|
301
|
-
* @uiName Use different email text
|
|
302
|
-
*/
|
|
303
|
-
this.useDifferentEmailText = "Use a different email";
|
|
304
289
|
/**
|
|
305
290
|
* Error text displayed under verification input
|
|
306
291
|
* @uiName Invalid code text
|
|
307
292
|
*/
|
|
308
|
-
this.invalidCodeText = "
|
|
293
|
+
this.invalidCodeText = "Please check your code and try again. If you’re still having trouble, try resending your code.";
|
|
309
294
|
/**
|
|
310
295
|
* @uiName Verify code button text
|
|
311
296
|
*/
|
|
@@ -329,17 +314,22 @@ const WidgetCodeVerification = class {
|
|
|
329
314
|
}
|
|
330
315
|
};
|
|
331
316
|
function useDemoWidgetCodeVerification(props) {
|
|
317
|
+
const [emailResent, setEmailResent] = useState(false);
|
|
318
|
+
const setVerifiedContext = Sn(VERIFICATION_PARENT_NAMESPACE);
|
|
332
319
|
return cjs({
|
|
333
320
|
states: {
|
|
334
321
|
loading: false,
|
|
335
|
-
email: "",
|
|
336
|
-
|
|
322
|
+
email: "test@example.com",
|
|
323
|
+
emailResent,
|
|
324
|
+
resendError: true,
|
|
325
|
+
verifyFailed: true,
|
|
337
326
|
},
|
|
338
327
|
refs: {
|
|
339
328
|
codeWrapperRef: () => { },
|
|
340
329
|
},
|
|
341
330
|
callbacks: {
|
|
342
|
-
|
|
331
|
+
resendEmail: async () => setEmailResent(true),
|
|
332
|
+
submitCode: async () => setVerifiedContext(true),
|
|
343
333
|
},
|
|
344
334
|
text: props.getTextProps(),
|
|
345
335
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
@@ -1,12 +1,134 @@
|
|
|
1
1
|
import { h, r as registerInstance } from './index-17b4da69.js';
|
|
2
|
-
import { n as h$1 } from './stencil-hooks.module-ac12ca1c.js';
|
|
3
|
-
import { i as isDemo } from './index.module-6c840c4e.js';
|
|
2
|
+
import { k as useState, f as useEffect, n as h$1 } from './stencil-hooks.module-ac12ca1c.js';
|
|
3
|
+
import { d as dist, M as Mn, E as En, K, c as xe, i as isDemo, S as Sn } from './index.module-6c840c4e.js';
|
|
4
4
|
import { c as cjs } from './cjs-bdfb4486.js';
|
|
5
5
|
import { c as createStyleSheet } from './JSS-67b5cff8.js';
|
|
6
6
|
import { g as getProps } from './utils-334c1e34.js';
|
|
7
7
|
import { T as TextSpanView } from './sqm-text-span-view-8d140661.js';
|
|
8
|
-
import './keys-
|
|
9
|
-
import { u as
|
|
8
|
+
import { S as SHOW_CODE_NAMESPACE, a as VERIFICATION_EMAIL_NAMESPACE } from './keys-db1897ae.js';
|
|
9
|
+
import { u as useVerificationEmail } from './useVerificationEmail-c32696ba.js';
|
|
10
|
+
|
|
11
|
+
const UpsertUserEmailMutation = dist.gql `
|
|
12
|
+
mutation upsertUser($userInput: UserInput!) {
|
|
13
|
+
user(userInput: $userInput) {
|
|
14
|
+
id
|
|
15
|
+
accountId
|
|
16
|
+
email
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const UserLookupQuery = dist.gql `
|
|
21
|
+
query user {
|
|
22
|
+
viewer {
|
|
23
|
+
... on User {
|
|
24
|
+
id
|
|
25
|
+
accountId
|
|
26
|
+
email
|
|
27
|
+
impactConnection {
|
|
28
|
+
user {
|
|
29
|
+
id
|
|
30
|
+
email
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
function useUpsertUserEmail() {
|
|
38
|
+
const user = K();
|
|
39
|
+
const [request, { loading: loading, data, errors }] = xe(UpsertUserEmailMutation);
|
|
40
|
+
const upsertUserEmail = async (email) => {
|
|
41
|
+
try {
|
|
42
|
+
const result = await request({
|
|
43
|
+
user: {
|
|
44
|
+
id: user.id,
|
|
45
|
+
accountId: user.accountId,
|
|
46
|
+
email,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (result instanceof Error || !result)
|
|
50
|
+
throw new Error();
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
console.error("Could not set email on user", e);
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
return [
|
|
59
|
+
upsertUserEmail,
|
|
60
|
+
{
|
|
61
|
+
loading,
|
|
62
|
+
data,
|
|
63
|
+
errors,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
function useWidgetEmailVerification(props) {
|
|
68
|
+
const [_, setShowCode] = Mn(SHOW_CODE_NAMESPACE);
|
|
69
|
+
const [email, setEmail] = Mn(VERIFICATION_EMAIL_NAMESPACE);
|
|
70
|
+
const [emailExists, setEmailExists] = useState(false);
|
|
71
|
+
const [error, setError] = useState(false);
|
|
72
|
+
const [mutationError, setMutationError] = useState(false);
|
|
73
|
+
const { initialized, send: [sendEmail, { loading: sendLoading, errors }], } = useVerificationEmail();
|
|
74
|
+
const [upsertUserEmail] = useUpsertUserEmail();
|
|
75
|
+
const [loading, setLoading] = useState(true);
|
|
76
|
+
const { data, loading: initialLoading } = En(UserLookupQuery, {});
|
|
77
|
+
const emailRegex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!(data === null || data === void 0 ? void 0 : data.viewer))
|
|
80
|
+
return;
|
|
81
|
+
setEmailExists(!!data.viewer.email);
|
|
82
|
+
}, [data]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (initialized)
|
|
85
|
+
setLoading(false);
|
|
86
|
+
}, [initialized]);
|
|
87
|
+
const submitEmail = async (e) => {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
if (!(data === null || data === void 0 ? void 0 : data.viewer))
|
|
90
|
+
return;
|
|
91
|
+
setLoading(true);
|
|
92
|
+
const toAddress = data.viewer.email;
|
|
93
|
+
if (!toAddress) {
|
|
94
|
+
// If no email on the user, set one
|
|
95
|
+
const formData = e.detail.formData;
|
|
96
|
+
const newEmail = formData.get("email").toString();
|
|
97
|
+
if (!emailRegex.test(newEmail)) {
|
|
98
|
+
setError(true);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const result = await upsertUserEmail(newEmail);
|
|
102
|
+
if (!result || !result.user.email)
|
|
103
|
+
setError(true);
|
|
104
|
+
}
|
|
105
|
+
// UI should not allow this call til initialisation is done
|
|
106
|
+
if (!initialized)
|
|
107
|
+
return;
|
|
108
|
+
const result = await sendEmail();
|
|
109
|
+
if (!result || !result.success)
|
|
110
|
+
setMutationError(true);
|
|
111
|
+
else {
|
|
112
|
+
// This is used to let the code verification widget know an email was already sent
|
|
113
|
+
setEmail(toAddress);
|
|
114
|
+
setShowCode(true);
|
|
115
|
+
}
|
|
116
|
+
setLoading(false);
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
callbacks: {
|
|
120
|
+
submitEmail,
|
|
121
|
+
},
|
|
122
|
+
states: {
|
|
123
|
+
loading,
|
|
124
|
+
initialLoading: initialLoading && !initialized,
|
|
125
|
+
error,
|
|
126
|
+
email: data === null || data === void 0 ? void 0 : data.viewer.email,
|
|
127
|
+
sendCodeError: mutationError,
|
|
128
|
+
},
|
|
129
|
+
text: props.getTextProps(),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
10
132
|
|
|
11
133
|
const style = {
|
|
12
134
|
Wrapper: {
|
|
@@ -22,6 +144,16 @@ const style = {
|
|
|
22
144
|
flexDirection: "column",
|
|
23
145
|
maxWidth: "320px",
|
|
24
146
|
},
|
|
147
|
+
ErrorAlertContainer: {
|
|
148
|
+
"&::part(base)": {
|
|
149
|
+
backgroundColor: "var(--sl-color-red-100)",
|
|
150
|
+
borderTop: "none",
|
|
151
|
+
},
|
|
152
|
+
"&::part(message)": {
|
|
153
|
+
display: "flex",
|
|
154
|
+
flexDirection: "column",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
25
157
|
ContinueButton: {
|
|
26
158
|
width: "100%",
|
|
27
159
|
maxWidth: "100px",
|
|
@@ -70,15 +202,18 @@ function WidgetEmailVerificationView(props) {
|
|
|
70
202
|
h("style", { type: "text/css" },
|
|
71
203
|
vanillaStyle,
|
|
72
204
|
styleString),
|
|
73
|
-
states.
|
|
74
|
-
" ",
|
|
205
|
+
states.sendCodeError && (h("sl-alert", { exportparts: "base: alert-base, icon:alert-icon", type: "danger", class: sheet.classes.ErrorAlertContainer, open: true },
|
|
206
|
+
h("sl-icon", { slot: "icon", name: "exclamation-octagon" }),
|
|
207
|
+
h("b", null, text.sendCodeErrorHeader),
|
|
208
|
+
text.sendCodeErrorDescription)),
|
|
209
|
+
states.initialLoading ? (renderLoadingSkeleton()) : (h("div", { class: sheet.classes.Wrapper },
|
|
75
210
|
h(TextSpanView, { type: "p" }, text.verifyEmailHeaderText),
|
|
76
211
|
h("sl-form", { "onSl-submit": callbacks.submitEmail },
|
|
77
212
|
h("div", { class: sheet.classes.InputsContainer },
|
|
78
|
-
h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email",
|
|
213
|
+
h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", label: text.emailLabel, value: states.email, type: "email", id: "email", name: "email", disabled: !!states.email || states.loading }, (states.error
|
|
79
214
|
? {
|
|
80
215
|
class: sheet.classes.ErrorInput,
|
|
81
|
-
helpText:
|
|
216
|
+
helpText: text.emailValidationErrorText,
|
|
82
217
|
}
|
|
83
218
|
: {}))),
|
|
84
219
|
h("sl-button", { submit: true, class: sheet.classes.ContinueButton, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.sendCodeText)))))));
|
|
@@ -92,9 +227,13 @@ const WidgetEmailVerification = class {
|
|
|
92
227
|
*/
|
|
93
228
|
this.verifyEmailHeaderText = "Start by verifying your email. We’ll send you a code through our referral provider, impact.com.";
|
|
94
229
|
/**
|
|
95
|
-
* @uiName
|
|
230
|
+
* @uiName Send code to email alert header
|
|
231
|
+
*/
|
|
232
|
+
this.sendCodeErrorHeader = "There was an error sending your code.";
|
|
233
|
+
/**
|
|
234
|
+
* @uiName Send code to email alert description
|
|
96
235
|
*/
|
|
97
|
-
this.
|
|
236
|
+
this.sendCodeErrorDescription = "Please try again. If this problem continues, contact our program support team.";
|
|
98
237
|
/**
|
|
99
238
|
* @uiName Email input label
|
|
100
239
|
*/
|
|
@@ -103,6 +242,10 @@ const WidgetEmailVerification = class {
|
|
|
103
242
|
* @uiName Send code button text
|
|
104
243
|
*/
|
|
105
244
|
this.sendCodeText = "Send code";
|
|
245
|
+
/**
|
|
246
|
+
* @uiName Send code button text
|
|
247
|
+
*/
|
|
248
|
+
this.emailValidationErrorText = "Please enter a valid email";
|
|
106
249
|
h$1(this);
|
|
107
250
|
}
|
|
108
251
|
disconnectedCallback() { }
|
|
@@ -117,14 +260,17 @@ const WidgetEmailVerification = class {
|
|
|
117
260
|
}
|
|
118
261
|
};
|
|
119
262
|
function useDemoWidgetEmailVerification(props) {
|
|
263
|
+
const setShowCode = Sn(SHOW_CODE_NAMESPACE);
|
|
120
264
|
return cjs({
|
|
121
265
|
states: {
|
|
122
|
-
error:
|
|
266
|
+
error: true,
|
|
267
|
+
initialLoading: false,
|
|
123
268
|
loading: false,
|
|
124
|
-
email: "",
|
|
269
|
+
email: "test@example.com",
|
|
270
|
+
sendCodeError: true,
|
|
125
271
|
},
|
|
126
272
|
callbacks: {
|
|
127
|
-
submitEmail: async () =>
|
|
273
|
+
submitEmail: async () => setShowCode(true),
|
|
128
274
|
},
|
|
129
275
|
text: props.getTextProps(),
|
|
130
276
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|