@saasquatch/mint-components 1.12.0-5 → 1.12.0-7
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/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 +47 -18
- package/dist/cjs/sqm-big-stat_39.cjs.entry.js +33 -6
- package/dist/cjs/sqm-code-verification.cjs.entry.js +34 -48
- package/dist/cjs/sqm-email-verification.cjs.entry.js +143 -21
- package/dist/cjs/{sqm-invoice-table-view-dbba9bb4.js → sqm-invoice-table-view-e530775f.js} +39 -0
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +19 -1
- package/dist/cjs/sqm-widget-verification-internal.cjs.entry.js +55 -7
- package/dist/cjs/sqm-widget-verification.cjs.entry.js +15 -18
- package/dist/cjs/useVerificationEmail-35aea294.js +170 -0
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/WidgetCodeVerification.stories.js +7 -0
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification-view.js +1 -1
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js +20 -2
- package/dist/collection/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.js +33 -24
- package/dist/collection/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.js +19 -42
- package/dist/collection/components/sqm-widget-verification/sqm-widget-verification-internal.js +56 -7
- package/dist/collection/components/sqm-widget-verification/sqm-widget-verification.js +17 -20
- 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 +38 -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-payout-status-alert/PayoutStatusAlert.stories.js +8 -0
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.js +10 -5
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.js +33 -1
- package/dist/collection/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.js +13 -2
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash/data.js +5 -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-dashboard/sqm-tax-and-cash-dashboard-view.js +11 -0
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.js +10 -9
- package/dist/collection/components/tax-and-cash/sqm-tax-and-cash-dashboard/useTaxAndCashDashboard.js +2 -1
- package/dist/collection/components/tax-and-cash/sqm-user-info-form/useUserInfoForm.js +14 -11
- 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 +48 -19
- package/dist/esm/sqm-big-stat_39.entry.js +34 -7
- package/dist/esm/sqm-code-verification.entry.js +36 -50
- package/dist/esm/sqm-email-verification.entry.js +127 -5
- package/dist/esm/{sqm-invoice-table-view-663674f2.js → sqm-invoice-table-view-22bb7240.js} +39 -0
- package/dist/esm/sqm-stencilbook.entry.js +19 -1
- package/dist/esm/sqm-widget-verification-internal.entry.js +55 -7
- package/dist/esm/sqm-widget-verification.entry.js +17 -20
- package/dist/esm/useVerificationEmail-02b78bd7.js +168 -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-22bb7240.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/useVerificationEmail-02b78bd7.js +1 -0
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-53d9df5e.entry.js → p-0aebee07.entry.js} +8 -3
- package/dist/mint-components/p-0e2d876d.entry.js +240 -0
- package/dist/mint-components/p-116c1809.entry.js +11 -0
- package/dist/mint-components/{p-99a09fab.entry.js → p-126a4f24.entry.js} +2 -2
- package/dist/mint-components/p-22b7bd75.system.entry.js +1 -0
- package/dist/mint-components/{p-d4138847.system.entry.js → p-28450e40.system.entry.js} +1 -1
- package/dist/mint-components/p-2b5b2586.system.js +1 -0
- package/dist/mint-components/p-39840341.js +1 -0
- package/dist/mint-components/p-4a43ffbd.js +1 -0
- package/dist/mint-components/p-55fe2ec0.system.entry.js +1 -0
- package/dist/mint-components/p-6fb496ac.entry.js +12 -0
- package/dist/mint-components/p-71b8adf7.system.js +1 -0
- package/dist/mint-components/p-7666cd3d.js +48 -0
- package/dist/mint-components/p-87bf9880.entry.js +25 -0
- package/dist/mint-components/p-8a7d2170.system.entry.js +1 -0
- package/dist/mint-components/p-a5eedbe2.system.entry.js +1 -0
- package/dist/mint-components/p-a60ec391.system.entry.js +1 -0
- package/dist/mint-components/p-b2a99637.system.js +1 -0
- package/dist/mint-components/p-ca423ca2.system.entry.js +1 -0
- package/dist/mint-components/p-e05ff098.system.js +1 -1
- package/dist/mint-components/p-e373b78a.entry.js +1 -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 +1 -0
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.d.ts +4 -0
- package/dist/types/components/sqm-widget-verification/sqm-code-verification/useCodeVerification.d.ts +2 -1
- package/dist/types/components/sqm-widget-verification/sqm-email-verification/useEmailVerification.d.ts +0 -6
- 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 +1 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert-view.d.ts +9 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/sqm-payout-status-alert.d.ts +4 -0
- package/dist/types/components/tax-and-cash/sqm-payout-status-alert/usePayoutStatus.d.ts +9 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash/data.d.ts +5 -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 +3 -0
- package/dist/types/components/tax-and-cash/sqm-tax-and-cash-dashboard/sqm-tax-and-cash-dashboard.d.ts +2 -2
- package/dist/types/components.d.ts +68 -52
- 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-33465f36.js +0 -155
- package/dist/collection/components/sqm-widget-verification/useWidgetVerification.js +0 -3
- package/dist/esm/useEmailVerification-8f2dc2bd.js +0 -152
- package/dist/esm-es5/sqm-invoice-table-view-663674f2.js +0 -1
- package/dist/esm-es5/useEmailVerification-8f2dc2bd.js +0 -1
- package/dist/mint-components/p-158e9d3a.entry.js +0 -1
- package/dist/mint-components/p-20c5ce3d.system.entry.js +0 -1
- package/dist/mint-components/p-219be817.system.entry.js +0 -1
- package/dist/mint-components/p-2c03096f.system.entry.js +0 -1
- package/dist/mint-components/p-4c9b6fbe.system.js +0 -1
- package/dist/mint-components/p-4d060f15.js +0 -1
- package/dist/mint-components/p-5810e318.entry.js +0 -1
- package/dist/mint-components/p-6029c42d.entry.js +0 -8
- package/dist/mint-components/p-6cae44d7.js +0 -1
- package/dist/mint-components/p-78c1bd77.system.js +0 -1
- package/dist/mint-components/p-80a32fe9.system.entry.js +0 -1
- package/dist/mint-components/p-a2baff3e.entry.js +0 -1
- package/dist/mint-components/p-b52b7e60.system.entry.js +0 -1
- package/dist/mint-components/p-f4dff47a.system.entry.js +0 -1
- package/dist/mint-components/p-faf019cf.system.js +0 -1
- package/dist/mint-components/p-fcb224ab.js +0 -25
- package/dist/mint-components/p-ff77d11f.entry.js +0 -240
- package/dist/types/components/sqm-widget-verification/useWidgetVerification.d.ts +0 -1
|
@@ -31,7 +31,7 @@ const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-96f
|
|
|
31
31
|
const sqmPortalVerifyEmailView = require('./sqm-portal-verify-email-view-7ffcc0d4.js');
|
|
32
32
|
const ShadowViewAddon = require('./ShadowViewAddon-13173901.js');
|
|
33
33
|
const sqmPortalContainerView = require('./sqm-portal-container-view-990a85a3.js');
|
|
34
|
-
const sqmInvoiceTableView = require('./sqm-invoice-table-view-
|
|
34
|
+
const sqmInvoiceTableView = require('./sqm-invoice-table-view-e530775f.js');
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -14413,6 +14413,7 @@ const bankingFormProps = {
|
|
|
14413
14413
|
loadingError: false,
|
|
14414
14414
|
},
|
|
14415
14415
|
callbacks: {
|
|
14416
|
+
onVerification: () => { },
|
|
14416
14417
|
onSubmit: async () => console.log("Submit"),
|
|
14417
14418
|
setPaymentMethodChecked: () => { },
|
|
14418
14419
|
setPaymentScheduleChecked: () => { },
|
|
@@ -15052,12 +15053,19 @@ const WidgetCodeVerification_stories = {
|
|
|
15052
15053
|
title: "Components/Widget Code Verification",
|
|
15053
15054
|
};
|
|
15054
15055
|
const defaultProps$l = {
|
|
15056
|
+
initialiseLoading: false,
|
|
15055
15057
|
email: "testemail@example.com",
|
|
15056
15058
|
loading: false,
|
|
15057
15059
|
verifyFailed: false,
|
|
15058
15060
|
emailResent: false,
|
|
15059
15061
|
};
|
|
15060
15062
|
const Default$j = () => (index.h("sqm-code-verification", { demoData: { states: defaultProps$l } }));
|
|
15063
|
+
const InitialLoading = () => (index.h("sqm-code-verification", { demoData: {
|
|
15064
|
+
states: {
|
|
15065
|
+
...defaultProps$l,
|
|
15066
|
+
initialiseLoading: true,
|
|
15067
|
+
},
|
|
15068
|
+
} }));
|
|
15061
15069
|
const Loading$8 = () => (index.h("sqm-code-verification", { demoData: {
|
|
15062
15070
|
states: {
|
|
15063
15071
|
...defaultProps$l,
|
|
@@ -15081,6 +15089,7 @@ const WidgetCodeVerification = /*#__PURE__*/Object.freeze({
|
|
|
15081
15089
|
__proto__: null,
|
|
15082
15090
|
'default': WidgetCodeVerification_stories,
|
|
15083
15091
|
Default: Default$j,
|
|
15092
|
+
InitialLoading: InitialLoading,
|
|
15084
15093
|
Loading: Loading$8,
|
|
15085
15094
|
CodeResent: CodeResent,
|
|
15086
15095
|
VerificationFailed: VerificationFailed
|
|
@@ -15106,9 +15115,17 @@ const PayoutStatusAlert_stories = {
|
|
|
15106
15115
|
const defaultProps$n = {
|
|
15107
15116
|
status: "INFORMATION_REQUIRED",
|
|
15108
15117
|
loading: false,
|
|
15118
|
+
showVerifyIdentity: false,
|
|
15109
15119
|
};
|
|
15110
15120
|
const InformationRequired = () => (index.h("sqm-payout-status-alert", { demoData: { states: defaultProps$n } }));
|
|
15111
15121
|
const VerifyIdentity = () => (index.h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps$n, status: "VERIFICATION_NEEDED" } } }));
|
|
15122
|
+
const VerifyIdentityOpen = () => (index.h("sqm-payout-status-alert", { demoData: {
|
|
15123
|
+
states: {
|
|
15124
|
+
...defaultProps$n,
|
|
15125
|
+
status: "VERIFICATION_NEEDED",
|
|
15126
|
+
showVerifyIdentity: true,
|
|
15127
|
+
},
|
|
15128
|
+
} }));
|
|
15112
15129
|
const Hold = () => (index.h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps$n, status: "HOLD" } } }));
|
|
15113
15130
|
const Loading$9 = () => (index.h("sqm-payout-status-alert", { demoData: { states: { ...defaultProps$n, loading: true } } }));
|
|
15114
15131
|
|
|
@@ -15117,6 +15134,7 @@ const PayoutStatusAlert = /*#__PURE__*/Object.freeze({
|
|
|
15117
15134
|
'default': PayoutStatusAlert_stories,
|
|
15118
15135
|
InformationRequired: InformationRequired,
|
|
15119
15136
|
VerifyIdentity: VerifyIdentity,
|
|
15137
|
+
VerifyIdentityOpen: VerifyIdentityOpen,
|
|
15120
15138
|
Hold: Hold,
|
|
15121
15139
|
Loading: Loading$9
|
|
15122
15140
|
});
|
|
@@ -2,13 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-b0129cd6.js');
|
|
5
|
+
const index$1 = require('./index-b0129cd6.js');
|
|
6
6
|
const stencilHooks_module = require('./stencil-hooks.module-a5a04d8a.js');
|
|
7
7
|
const index_module = require('./index.module-236d0403.js');
|
|
8
|
+
const index = require('./index-56d1fa5b.js');
|
|
8
9
|
const utils = require('./utils-6847bc06.js');
|
|
9
10
|
const keys = require('./keys-cff24974.js');
|
|
10
11
|
const extractProps = require('./extractProps-fd93ba62.js');
|
|
11
12
|
|
|
13
|
+
const USER_LOOKUP = index.dist.gql `
|
|
14
|
+
query viewer {
|
|
15
|
+
viewer {
|
|
16
|
+
... on User {
|
|
17
|
+
id
|
|
18
|
+
accountId
|
|
19
|
+
email
|
|
20
|
+
emailVerified
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
12
25
|
function useWidgetVerificationInternal() {
|
|
13
26
|
const userIdentity = index_module.K();
|
|
14
27
|
const [showCode, setShowCode] = index_module.Fn({
|
|
@@ -19,11 +32,36 @@ function useWidgetVerificationInternal() {
|
|
|
19
32
|
namespace: keys.VERIFICATION_EMAIL_NAMESPACE,
|
|
20
33
|
initialValue: userIdentity === null || userIdentity === void 0 ? void 0 : userIdentity.email,
|
|
21
34
|
});
|
|
22
|
-
|
|
35
|
+
const setContext = index_module.Sn(keys.VERIFICATION_PARENT_NAMESPACE);
|
|
36
|
+
const [loading, setLoading] = stencilHooks_module.useState(true);
|
|
37
|
+
const [fetch] = index_module.an(USER_LOOKUP);
|
|
38
|
+
stencilHooks_module.useEffect(() => {
|
|
39
|
+
const checkUser = async () => {
|
|
40
|
+
var _a;
|
|
41
|
+
try {
|
|
42
|
+
const res = await fetch({});
|
|
43
|
+
if (!res || res instanceof Error)
|
|
44
|
+
throw new Error();
|
|
45
|
+
if ((_a = res === null || res === void 0 ? void 0 : res.viewer) === null || _a === void 0 ? void 0 : _a.emailVerified)
|
|
46
|
+
setContext(true);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
console.error("Could not fetch user information", e);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
checkUser();
|
|
56
|
+
}, []);
|
|
57
|
+
const onVerification = () => {
|
|
58
|
+
setContext(true);
|
|
59
|
+
};
|
|
60
|
+
return { showCode, onVerification, loading };
|
|
23
61
|
}
|
|
24
62
|
const WidgetVerificationInternal = class {
|
|
25
63
|
constructor(hostRef) {
|
|
26
|
-
index.registerInstance(this, hostRef);
|
|
64
|
+
index$1.registerInstance(this, hostRef);
|
|
27
65
|
stencilHooks_module.h(this);
|
|
28
66
|
}
|
|
29
67
|
disconnectedCallback() { }
|
|
@@ -32,13 +70,19 @@ const WidgetVerificationInternal = class {
|
|
|
32
70
|
return extractProps.extractProps(props, prefix);
|
|
33
71
|
}
|
|
34
72
|
render() {
|
|
35
|
-
const { showCode } = index_module.isDemo()
|
|
73
|
+
const { showCode, onVerification, loading } = index_module.isDemo()
|
|
36
74
|
? useDemoWidgetVerificationInternal()
|
|
37
75
|
: useWidgetVerificationInternal();
|
|
76
|
+
// TODO: Shoelace spinner is throwing errors
|
|
77
|
+
if (loading)
|
|
78
|
+
return index$1.h("div", null);
|
|
79
|
+
// if (loading) {
|
|
80
|
+
// return <sl-spinner style="font-size: 2rem;"></sl-spinner>;
|
|
81
|
+
// }
|
|
38
82
|
if (showCode) {
|
|
39
|
-
return (index.h("sqm-code-verification", Object.assign({}, this.getStepTextProps("codeStep_"))));
|
|
83
|
+
return (index$1.h("sqm-code-verification", Object.assign({ onVerification: onVerification }, this.getStepTextProps("codeStep_"))));
|
|
40
84
|
}
|
|
41
|
-
return (index.h("sqm-email-verification", Object.assign({}, this.getStepTextProps("emailStep_"))));
|
|
85
|
+
return (index$1.h("sqm-email-verification", Object.assign({}, this.getStepTextProps("emailStep_"))));
|
|
42
86
|
}
|
|
43
87
|
};
|
|
44
88
|
function useDemoWidgetVerificationInternal() {
|
|
@@ -50,7 +94,11 @@ function useDemoWidgetVerificationInternal() {
|
|
|
50
94
|
namespace: keys.VERIFICATION_EMAIL_NAMESPACE,
|
|
51
95
|
initialValue: undefined,
|
|
52
96
|
});
|
|
53
|
-
|
|
97
|
+
const setContext = index_module.Sn(keys.VERIFICATION_PARENT_NAMESPACE);
|
|
98
|
+
const onVerification = () => {
|
|
99
|
+
setContext(true);
|
|
100
|
+
};
|
|
101
|
+
return { showCode, onVerification, loading: false };
|
|
54
102
|
}
|
|
55
103
|
|
|
56
104
|
exports.sqm_widget_verification_internal = WidgetVerificationInternal;
|
|
@@ -129,15 +129,12 @@ const WidgetVerification = class {
|
|
|
129
129
|
render() {
|
|
130
130
|
const [context, setContext] = index_module.Fn({
|
|
131
131
|
namespace: keys.VERIFICATION_PARENT_NAMESPACE,
|
|
132
|
-
initialValue:
|
|
132
|
+
initialValue: false,
|
|
133
133
|
});
|
|
134
|
-
const authToken = context === null || context === void 0 ? void 0 : context.token;
|
|
135
134
|
const [container, setContainer] = stencilHooks_module.useState(undefined);
|
|
136
135
|
const [slot, setSlot] = stencilHooks_module.useState(undefined);
|
|
137
|
-
if (!authToken)
|
|
138
|
-
debug("No user identity available");
|
|
139
136
|
const updateTemplates = index_module.useCallback(() => {
|
|
140
|
-
const isAuth =
|
|
137
|
+
const isAuth = context;
|
|
141
138
|
const templates = slot.querySelectorAll(`template`);
|
|
142
139
|
const template = Array.from(templates).find((t) => t.slot === (isAuth ? "verified" : "not-verified"));
|
|
143
140
|
if (template) {
|
|
@@ -185,7 +182,7 @@ const WidgetVerification = class {
|
|
|
185
182
|
target.style.height = "25px";
|
|
186
183
|
});
|
|
187
184
|
}
|
|
188
|
-
}, [container, slot,
|
|
185
|
+
}, [container, slot, context]);
|
|
189
186
|
stencilHooks_module.useEffect(() => {
|
|
190
187
|
if (!container || !slot) {
|
|
191
188
|
debug("DOM not ready:");
|
|
@@ -194,18 +191,18 @@ const WidgetVerification = class {
|
|
|
194
191
|
// Run on first render
|
|
195
192
|
updateTemplates();
|
|
196
193
|
return useTemplateChildren({ parent: slot, callback: updateTemplates });
|
|
197
|
-
}, [slot, container,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}, []);
|
|
194
|
+
}, [slot, container, context]);
|
|
195
|
+
// useEffect(() => {
|
|
196
|
+
// const host = useHost();
|
|
197
|
+
// const callback = (e: CustomEvent) => {
|
|
198
|
+
// e.stopPropagation();
|
|
199
|
+
// setContext({ token: e.detail.token });
|
|
200
|
+
// };
|
|
201
|
+
// host.addEventListener(VERIFICATION_EVENT_KEY, callback);
|
|
202
|
+
// return () => {
|
|
203
|
+
// host.removeEventListener(VERIFICATION_EVENT_KEY, callback);
|
|
204
|
+
// };
|
|
205
|
+
// }, []);
|
|
209
206
|
return (index.h(index.Host, null, index.h("div", { ref: setSlot, style: { display: "contents" } }, index.h("template", { slot: "not-verified" }, index.h("sqm-widget-verification-internal", Object.assign({}, utils.getProps(this)))), index.h("slot", { name: "not-verified" }), index.h("slot", { name: "verified" })), index.h("div", { ref: setContainer }, index.h("slot", { name: "shown" }))));
|
|
210
207
|
}
|
|
211
208
|
};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const stencilHooks_module = require('./stencil-hooks.module-a5a04d8a.js');
|
|
4
|
+
const index_module = require('./index.module-236d0403.js');
|
|
5
|
+
const index = require('./index-56d1fa5b.js');
|
|
6
|
+
|
|
7
|
+
const UserLookupQuery = index.dist.gql `
|
|
8
|
+
query userLookup {
|
|
9
|
+
viewer {
|
|
10
|
+
... on User {
|
|
11
|
+
id
|
|
12
|
+
accountId
|
|
13
|
+
email
|
|
14
|
+
impactConnection {
|
|
15
|
+
user {
|
|
16
|
+
id
|
|
17
|
+
email
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const ParticipantVerificationEmailMutation = index.dist.gql `
|
|
25
|
+
mutation requestUserEmailVerification($user: UserIdInput!) {
|
|
26
|
+
requestUserEmailVerification(user: $user) {
|
|
27
|
+
success
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const ImpactVerificationEmailMutation = index.dist.gql `
|
|
32
|
+
mutation requestImpactPublisherEmail2FA($user: UserIdInput!) {
|
|
33
|
+
requestImpactPublisherEmail2FA(user: $user) {
|
|
34
|
+
success
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
const VerifyUserEmailMutation = index.dist.gql `
|
|
39
|
+
mutation verifyUserEmail($user: UserIdInput!, $code: String!) {
|
|
40
|
+
verifyUserEmail(user: $user, code: $code) {
|
|
41
|
+
id
|
|
42
|
+
accountId
|
|
43
|
+
email
|
|
44
|
+
emailVerified
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
const SubmitImpactCodeMutation = index.dist.gql `
|
|
49
|
+
mutation submitImpactPublisherEmail2FACode(
|
|
50
|
+
$user: UserIdInput!
|
|
51
|
+
$code: String!
|
|
52
|
+
) {
|
|
53
|
+
submitImpactPublisherEmail2FACode(user: $user, code: $code) {
|
|
54
|
+
verifiedEmail
|
|
55
|
+
accessKey
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
// ! It's important when using this hook to ensure initialisation
|
|
60
|
+
// ! is done before calling any mutations
|
|
61
|
+
function useVerificationEmail() {
|
|
62
|
+
const userIdentity = index_module.K();
|
|
63
|
+
const [hasEmails, setHasEmails] = stencilHooks_module.useState({
|
|
64
|
+
participant: false,
|
|
65
|
+
impact: false,
|
|
66
|
+
});
|
|
67
|
+
const [fetch] = index_module.an(UserLookupQuery);
|
|
68
|
+
// Send mutations
|
|
69
|
+
const [sendParticipantEmail, { loading: participantEmailLoading, errors: participantEmailErrors },] = index_module.xe(ParticipantVerificationEmailMutation);
|
|
70
|
+
const [sendImpactEmail, { loading: impactEmailLoading, errors: impactEmailErrors },] = index_module.xe(ImpactVerificationEmailMutation);
|
|
71
|
+
const sendLoading = participantEmailLoading || impactEmailLoading;
|
|
72
|
+
const sendErrors = participantEmailErrors || impactEmailErrors;
|
|
73
|
+
// Verification mutations
|
|
74
|
+
const [verifyUserEmail, { loading: verifyMutationLoading, errors: verifyMutationErrors },] = index_module.xe(VerifyUserEmailMutation);
|
|
75
|
+
const [submitImpactCode, { loading: submitImpactCodeLoading, errors: submitImpactCodeErrors },] = index_module.xe(SubmitImpactCodeMutation);
|
|
76
|
+
const verifyLoading = verifyMutationLoading || submitImpactCodeLoading;
|
|
77
|
+
const verifyErrors = verifyMutationErrors || submitImpactCodeErrors;
|
|
78
|
+
const [initialized, setInitialized] = stencilHooks_module.useState(false);
|
|
79
|
+
const initialise = async () => {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
try {
|
|
82
|
+
const lookup = await fetch({});
|
|
83
|
+
if (!lookup || lookup instanceof Error)
|
|
84
|
+
throw new Error();
|
|
85
|
+
setHasEmails({
|
|
86
|
+
participant: !!((_a = lookup === null || lookup === void 0 ? void 0 : lookup.viewer) === null || _a === void 0 ? void 0 : _a.email),
|
|
87
|
+
impact: !!((_d = (_c = (_b = lookup === null || lookup === void 0 ? void 0 : lookup.viewer) === null || _b === void 0 ? void 0 : _b.impactConnection) === null || _c === void 0 ? void 0 : _c.user) === null || _d === void 0 ? void 0 : _d.email),
|
|
88
|
+
});
|
|
89
|
+
setInitialized(true);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
console.error("Could not initialise verification", e);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const sendVerificationEmail = async () => {
|
|
96
|
+
let result = null;
|
|
97
|
+
if (!initialized)
|
|
98
|
+
return result;
|
|
99
|
+
if (!hasEmails.participant && !hasEmails.impact)
|
|
100
|
+
return result;
|
|
101
|
+
try {
|
|
102
|
+
const request = hasEmails.impact ? sendImpactEmail : sendParticipantEmail;
|
|
103
|
+
const res = await request({
|
|
104
|
+
user: {
|
|
105
|
+
id: userIdentity.id,
|
|
106
|
+
accountId: userIdentity.accountId,
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
if (res instanceof Error || !res)
|
|
110
|
+
throw new Error();
|
|
111
|
+
result = hasEmails.impact
|
|
112
|
+
? res.requestImpactPublisherEmail2FA
|
|
113
|
+
: res.requestUserEmailVerification;
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
console.error("Could not send verification email", e);
|
|
117
|
+
}
|
|
118
|
+
finally {
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const verifyVerificationEmail = async (code) => {
|
|
123
|
+
var _a;
|
|
124
|
+
let result = null;
|
|
125
|
+
if (!initialized)
|
|
126
|
+
return result;
|
|
127
|
+
if (!hasEmails.participant && !hasEmails.impact)
|
|
128
|
+
return result;
|
|
129
|
+
try {
|
|
130
|
+
const request = hasEmails.impact ? submitImpactCode : verifyUserEmail;
|
|
131
|
+
const res = await request({
|
|
132
|
+
user: {
|
|
133
|
+
id: userIdentity.id,
|
|
134
|
+
accountId: userIdentity.accountId,
|
|
135
|
+
},
|
|
136
|
+
code,
|
|
137
|
+
});
|
|
138
|
+
if (res instanceof Error || !res)
|
|
139
|
+
throw new Error();
|
|
140
|
+
result = {
|
|
141
|
+
success: true,
|
|
142
|
+
accessKey: hasEmails.impact
|
|
143
|
+
? (_a = res.submitImpactPublisherEmail2FACode) === null || _a === void 0 ? void 0 : _a.accessKey : undefined,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
console.error("Could not verify email", e);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
stencilHooks_module.useEffect(() => {
|
|
154
|
+
if (!initialized)
|
|
155
|
+
initialise();
|
|
156
|
+
}, []);
|
|
157
|
+
return {
|
|
158
|
+
initialized,
|
|
159
|
+
send: [
|
|
160
|
+
sendVerificationEmail,
|
|
161
|
+
{ loading: sendLoading, errors: sendErrors },
|
|
162
|
+
],
|
|
163
|
+
verify: [
|
|
164
|
+
verifyVerificationEmail,
|
|
165
|
+
{ loading: verifyLoading, errors: verifyErrors },
|
|
166
|
+
],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
exports.useVerificationEmail = useVerificationEmail;
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
"./components/sqm-user-name/sqm-user-name.js",
|
|
111
111
|
"./components/sqm-widget-verification/sqm-widget-verification-internal.js",
|
|
112
112
|
"./components/sqm-widget-verification/sqm-widget-verification.js",
|
|
113
|
-
"./components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js",
|
|
114
113
|
"./components/sqm-widget-verification/sqm-code-verification/sqm-code-verification.js",
|
|
114
|
+
"./components/sqm-widget-verification/sqm-email-verification/sqm-email-verification.js",
|
|
115
115
|
"./components/tax-and-cash/sqm-payout-details-card/sqm-payout-details-card.js",
|
|
116
116
|
"./components/tax-and-cash/sqm-tax-and-cash/sqm-tax-and-cash.js"
|
|
117
117
|
],
|
|
@@ -3,12 +3,19 @@ export default {
|
|
|
3
3
|
title: "Components/Widget Code Verification",
|
|
4
4
|
};
|
|
5
5
|
const defaultProps = {
|
|
6
|
+
initialiseLoading: false,
|
|
6
7
|
email: "testemail@example.com",
|
|
7
8
|
loading: false,
|
|
8
9
|
verifyFailed: false,
|
|
9
10
|
emailResent: false,
|
|
10
11
|
};
|
|
11
12
|
export const Default = () => (h("sqm-code-verification", { demoData: { states: defaultProps } }));
|
|
13
|
+
export const InitialLoading = () => (h("sqm-code-verification", { demoData: {
|
|
14
|
+
states: {
|
|
15
|
+
...defaultProps,
|
|
16
|
+
initialiseLoading: true,
|
|
17
|
+
},
|
|
18
|
+
} }));
|
|
12
19
|
export const Loading = () => (h("sqm-code-verification", { demoData: {
|
|
13
20
|
states: {
|
|
14
21
|
...defaultProps,
|
|
@@ -122,7 +122,7 @@ export function WidgetCodeVerificationView(props) {
|
|
|
122
122
|
h("sl-input", { class: inputClass, name: "code" }),
|
|
123
123
|
h("sl-input", { class: inputClass, name: "code" })),
|
|
124
124
|
states.verifyFailed && (h("p", { class: sheet.classes.ErrorText }, text.invalidCodeText)),
|
|
125
|
-
h("sl-button", { class: sheet.classes.ContinueButton, onClick: callbacks.submitCode, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, text.verifyText)),
|
|
125
|
+
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)),
|
|
126
126
|
h("div", { class: sheet.classes.FooterContainer },
|
|
127
127
|
h(TextSpanView, { type: "p" }, resendCodeText)))));
|
|
128
128
|
}
|
|
@@ -233,7 +233,7 @@ export class WidgetCodeVerification {
|
|
|
233
233
|
"mutable": false,
|
|
234
234
|
"complexType": {
|
|
235
235
|
"original": "DemoData<WidgetCodeVerificationViewProps>",
|
|
236
|
-
"resolved": "{ states?: { loading: boolean; email: string; verifyFailed?: boolean; emailResent: boolean; }; refs?: { codeWrapperRef: any; }; }",
|
|
236
|
+
"resolved": "{ states?: { initialiseLoading: boolean; loading: boolean; email: string; verifyFailed?: boolean; emailResent: boolean; }; refs?: { codeWrapperRef: any; }; }",
|
|
237
237
|
"references": {
|
|
238
238
|
"DemoData": {
|
|
239
239
|
"location": "import",
|
|
@@ -257,6 +257,24 @@ export class WidgetCodeVerification {
|
|
|
257
257
|
}],
|
|
258
258
|
"text": ""
|
|
259
259
|
}
|
|
260
|
+
},
|
|
261
|
+
"onVerification": {
|
|
262
|
+
"type": "unknown",
|
|
263
|
+
"mutable": false,
|
|
264
|
+
"complexType": {
|
|
265
|
+
"original": "(token: string) => any",
|
|
266
|
+
"resolved": "(token: string) => any",
|
|
267
|
+
"references": {}
|
|
268
|
+
},
|
|
269
|
+
"required": false,
|
|
270
|
+
"optional": true,
|
|
271
|
+
"docs": {
|
|
272
|
+
"tags": [{
|
|
273
|
+
"text": undefined,
|
|
274
|
+
"name": "undocumented"
|
|
275
|
+
}],
|
|
276
|
+
"text": ""
|
|
277
|
+
}
|
|
260
278
|
}
|
|
261
279
|
}; }
|
|
262
280
|
}
|
|
@@ -276,7 +294,7 @@ function useDemoWidgetCodeVerification(props) {
|
|
|
276
294
|
},
|
|
277
295
|
callbacks: {
|
|
278
296
|
resendEmail: async () => setEmailResent(true),
|
|
279
|
-
submitCode: async () => setVerifiedContext(
|
|
297
|
+
submitCode: async () => setVerifiedContext(true),
|
|
280
298
|
},
|
|
281
299
|
text: props.getTextProps(),
|
|
282
300
|
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useMutation, useParent, useParentValue, useUserIdentity, } from "@saasquatch/component-boilerplate";
|
|
2
2
|
import { useEffect, useHost, useState } from "@saasquatch/stencil-hooks";
|
|
3
3
|
import { gql } from "graphql-request";
|
|
4
|
-
import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE,
|
|
5
|
-
import {
|
|
6
|
-
// TODO: Move to component-boilerplate
|
|
4
|
+
import { SHOW_CODE_NAMESPACE, VERIFICATION_EMAIL_NAMESPACE, } from "../keys";
|
|
5
|
+
import { useVerificationEmail } from "../useVerificationEmail";
|
|
7
6
|
export const VerifyEmailWithCodeMutation = gql `
|
|
8
|
-
mutation
|
|
9
|
-
|
|
7
|
+
mutation submitImpactPublisherEmail2FACode(
|
|
8
|
+
$user: UserIdInput!
|
|
9
|
+
$code: String!
|
|
10
|
+
) {
|
|
11
|
+
submitImpactPublisherEmail2FACode(user: $user, code: $code) {
|
|
10
12
|
verifiedEmail
|
|
11
13
|
accessKey
|
|
12
14
|
}
|
|
@@ -44,9 +46,10 @@ export function useWidgetCodeVerification(props) {
|
|
|
44
46
|
const [codeRef, setCodeRef] = useState(null);
|
|
45
47
|
const [validationError, setValidationError] = useState(false);
|
|
46
48
|
const [emailError, setEmailError] = useState(false);
|
|
47
|
-
// TODO: Need to handle error states for these errors
|
|
48
|
-
const [verifyUser, { loading: verifyLoading, errors: verifyErrors }] =
|
|
49
|
-
|
|
49
|
+
// // TODO: Need to handle error states for these errors
|
|
50
|
+
// const [verifyUser, { loading: verifyLoading, errors: verifyErrors }] =
|
|
51
|
+
// useCodeVerificationMutation();
|
|
52
|
+
const { initialized, send: [sendEmail, { loading: sendLoading, errors: sendErrors }], verify: [verifyEmail, { loading: verifyLoading, errors: verifyErrors }], } = useVerificationEmail();
|
|
50
53
|
useEffect(() => {
|
|
51
54
|
if (!codeRef)
|
|
52
55
|
return;
|
|
@@ -62,7 +65,7 @@ export function useWidgetCodeVerification(props) {
|
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
67
|
element.addEventListener("input", (e) => {
|
|
65
|
-
const input = e.
|
|
68
|
+
const input = e.data;
|
|
66
69
|
if (!input)
|
|
67
70
|
return;
|
|
68
71
|
if (idx === codeElements.length - 1) {
|
|
@@ -72,8 +75,10 @@ export function useWidgetCodeVerification(props) {
|
|
|
72
75
|
if (input.length > 1) {
|
|
73
76
|
const rest = input.slice(1);
|
|
74
77
|
e.target.value = input.slice(0, 1);
|
|
75
|
-
codeElements[idx + 1].
|
|
76
|
-
|
|
78
|
+
codeElements[idx + 1].dispatchEvent(new InputEvent("input", {
|
|
79
|
+
inputType: "insertFromPaste",
|
|
80
|
+
data: rest,
|
|
81
|
+
}));
|
|
77
82
|
}
|
|
78
83
|
codeElements[idx + 1].focus();
|
|
79
84
|
});
|
|
@@ -84,7 +89,10 @@ export function useWidgetCodeVerification(props) {
|
|
|
84
89
|
setValidationError(false);
|
|
85
90
|
};
|
|
86
91
|
const resendEmail = async () => {
|
|
87
|
-
|
|
92
|
+
// UI should only allow this to be called if initialized, but checking just in case
|
|
93
|
+
if (!initialized)
|
|
94
|
+
return;
|
|
95
|
+
const result = await sendEmail();
|
|
88
96
|
if (!result) {
|
|
89
97
|
setEmailError(true);
|
|
90
98
|
return;
|
|
@@ -104,16 +112,13 @@ export function useWidgetCodeVerification(props) {
|
|
|
104
112
|
codeElements.forEach((element) => {
|
|
105
113
|
code = `${code}${element.value}`;
|
|
106
114
|
});
|
|
115
|
+
// UI should only allow this to be called if initialized, but checking just in case
|
|
116
|
+
if (!initialized)
|
|
117
|
+
return;
|
|
107
118
|
setValidationError(false);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const event = new CustomEvent(VERIFICATION_EVENT_KEY, {
|
|
112
|
-
detail: { token: res.verifyUserEmail.accessKey },
|
|
113
|
-
composed: true,
|
|
114
|
-
bubbles: true,
|
|
115
|
-
});
|
|
116
|
-
host.dispatchEvent(event);
|
|
119
|
+
const res = await verifyEmail(code);
|
|
120
|
+
if (res === null || res === void 0 ? void 0 : res.success) {
|
|
121
|
+
props.onVerification(res.accessKey);
|
|
117
122
|
reset();
|
|
118
123
|
}
|
|
119
124
|
else {
|
|
@@ -121,12 +126,15 @@ export function useWidgetCodeVerification(props) {
|
|
|
121
126
|
}
|
|
122
127
|
};
|
|
123
128
|
useEffect(() => {
|
|
129
|
+
// Wait for mutations to be determined from user lookup
|
|
130
|
+
if (!initialized)
|
|
131
|
+
return;
|
|
124
132
|
// email should already exist if user has completed email-verification
|
|
125
133
|
if (!email)
|
|
126
134
|
resendEmail();
|
|
127
135
|
else
|
|
128
136
|
setEmailSent(true);
|
|
129
|
-
}, []);
|
|
137
|
+
}, [initialized]);
|
|
130
138
|
return {
|
|
131
139
|
refs: {
|
|
132
140
|
codeWrapperRef: setCodeRef,
|
|
@@ -134,8 +142,9 @@ export function useWidgetCodeVerification(props) {
|
|
|
134
142
|
states: {
|
|
135
143
|
email,
|
|
136
144
|
emailResent,
|
|
137
|
-
resendError:
|
|
138
|
-
|
|
145
|
+
resendError: sendErrors || verifyErrors,
|
|
146
|
+
initialiseLoading: !initialized,
|
|
147
|
+
loading: sendLoading || verifyLoading,
|
|
139
148
|
verifyFailed: !!validationError,
|
|
140
149
|
},
|
|
141
150
|
callbacks: {
|