@dynamic-labs/sdk-react-core 4.65.0 → 4.66.0
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/CHANGELOG.md +13 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +13 -13
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +5 -2
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +5 -2
- package/src/lib/utils/hooks/useSignEip7702Authorization/index.d.ts +1 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.cjs +162 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.d.ts +78 -0
- package/src/lib/utils/hooks/useSignEip7702Authorization/useSignEip7702Authorization.js +158 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +3 -1
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +3 -1
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +24 -2
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +24 -2
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.cjs +1 -1
- package/src/lib/views/MfaDisplayBackupCodesView/MfaDisplayBackupCodesView.js +1 -1
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.cjs +5 -21
- package/src/lib/views/ResetPasswordForSettingsView/ResetPasswordForSettingsView.js +5 -21
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs +26 -5
- package/src/lib/widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js +26 -5
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js +3 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordKnowledgeCheckView/SetupPasswordKnowledgeCheckView.js +2 -2
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.cjs +30 -22
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/views/SetupPasswordView/SetupPasswordView.js +30 -22
|
@@ -156,7 +156,9 @@ const useWalletCreation = () => {
|
|
|
156
156
|
try {
|
|
157
157
|
// If passcodeRequired is enabled, prompt user to set up password first
|
|
158
158
|
const password = yield setupPassword();
|
|
159
|
-
yield createWalletAccount(requirements, password
|
|
159
|
+
yield createWalletAccount(requirements, password, undefined, {
|
|
160
|
+
skipCloseAuthFlow: Boolean(password),
|
|
161
|
+
});
|
|
160
162
|
const duration = Date.now() - startTime;
|
|
161
163
|
// Log successful wallet creation to DataDog
|
|
162
164
|
logger.instrument('Auto wallet creation successful', {
|
|
@@ -18,6 +18,7 @@ require('../../constants/values.cjs');
|
|
|
18
18
|
require('@dynamic-labs/sdk-api-core');
|
|
19
19
|
require('../../../shared/consts/index.cjs');
|
|
20
20
|
var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
21
|
+
var useRefreshUser = require('../useRefreshUser/useRefreshUser.cjs');
|
|
21
22
|
|
|
22
23
|
const INITIAL_STATE = {
|
|
23
24
|
error: null,
|
|
@@ -26,6 +27,7 @@ const INITIAL_STATE = {
|
|
|
26
27
|
};
|
|
27
28
|
const useWalletPassword = () => {
|
|
28
29
|
const { getWaasWalletConnector } = useDynamicWaas.useDynamicWaas();
|
|
30
|
+
const refreshUser = useRefreshUser.useRefreshUser();
|
|
29
31
|
const [state, setState] = React.useState(INITIAL_STATE);
|
|
30
32
|
const resetState = React.useCallback(() => {
|
|
31
33
|
setState(INITIAL_STATE);
|
|
@@ -46,6 +48,16 @@ const useWalletPassword = () => {
|
|
|
46
48
|
newPassword,
|
|
47
49
|
});
|
|
48
50
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
51
|
+
try {
|
|
52
|
+
yield refreshUser();
|
|
53
|
+
}
|
|
54
|
+
catch (refreshError) {
|
|
55
|
+
logger.logger.warn('Failed to refresh user after setting password', {
|
|
56
|
+
accountAddress,
|
|
57
|
+
chainName,
|
|
58
|
+
refreshError,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
49
61
|
return true;
|
|
50
62
|
}
|
|
51
63
|
catch (error) {
|
|
@@ -58,7 +70,7 @@ const useWalletPassword = () => {
|
|
|
58
70
|
});
|
|
59
71
|
return false;
|
|
60
72
|
}
|
|
61
|
-
}), [getWaasWalletConnector]);
|
|
73
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
62
74
|
const updatePassword = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
75
|
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
64
76
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -76,6 +88,16 @@ const useWalletPassword = () => {
|
|
|
76
88
|
newPassword,
|
|
77
89
|
});
|
|
78
90
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
91
|
+
try {
|
|
92
|
+
yield refreshUser();
|
|
93
|
+
}
|
|
94
|
+
catch (refreshError) {
|
|
95
|
+
logger.logger.warn('Failed to refresh user after updating password', {
|
|
96
|
+
accountAddress,
|
|
97
|
+
chainName,
|
|
98
|
+
refreshError,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
79
101
|
return true;
|
|
80
102
|
}
|
|
81
103
|
catch (error) {
|
|
@@ -88,7 +110,7 @@ const useWalletPassword = () => {
|
|
|
88
110
|
});
|
|
89
111
|
return false;
|
|
90
112
|
}
|
|
91
|
-
}), [getWaasWalletConnector]);
|
|
113
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
92
114
|
const unlockWallet = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
93
115
|
const { accountAddress, chainName, password } = params;
|
|
94
116
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -14,6 +14,7 @@ import '../../constants/values.js';
|
|
|
14
14
|
import '@dynamic-labs/sdk-api-core';
|
|
15
15
|
import '../../../shared/consts/index.js';
|
|
16
16
|
import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
|
|
17
|
+
import { useRefreshUser } from '../useRefreshUser/useRefreshUser.js';
|
|
17
18
|
|
|
18
19
|
const INITIAL_STATE = {
|
|
19
20
|
error: null,
|
|
@@ -22,6 +23,7 @@ const INITIAL_STATE = {
|
|
|
22
23
|
};
|
|
23
24
|
const useWalletPassword = () => {
|
|
24
25
|
const { getWaasWalletConnector } = useDynamicWaas();
|
|
26
|
+
const refreshUser = useRefreshUser();
|
|
25
27
|
const [state, setState] = useState(INITIAL_STATE);
|
|
26
28
|
const resetState = useCallback(() => {
|
|
27
29
|
setState(INITIAL_STATE);
|
|
@@ -42,6 +44,16 @@ const useWalletPassword = () => {
|
|
|
42
44
|
newPassword,
|
|
43
45
|
});
|
|
44
46
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
47
|
+
try {
|
|
48
|
+
yield refreshUser();
|
|
49
|
+
}
|
|
50
|
+
catch (refreshError) {
|
|
51
|
+
logger.warn('Failed to refresh user after setting password', {
|
|
52
|
+
accountAddress,
|
|
53
|
+
chainName,
|
|
54
|
+
refreshError,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
45
57
|
return true;
|
|
46
58
|
}
|
|
47
59
|
catch (error) {
|
|
@@ -54,7 +66,7 @@ const useWalletPassword = () => {
|
|
|
54
66
|
});
|
|
55
67
|
return false;
|
|
56
68
|
}
|
|
57
|
-
}), [getWaasWalletConnector]);
|
|
69
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
58
70
|
const updatePassword = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
71
|
const { accountAddress, chainName, newPassword, existingPassword } = params;
|
|
60
72
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -72,6 +84,16 @@ const useWalletPassword = () => {
|
|
|
72
84
|
newPassword,
|
|
73
85
|
});
|
|
74
86
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: false })));
|
|
87
|
+
try {
|
|
88
|
+
yield refreshUser();
|
|
89
|
+
}
|
|
90
|
+
catch (refreshError) {
|
|
91
|
+
logger.warn('Failed to refresh user after updating password', {
|
|
92
|
+
accountAddress,
|
|
93
|
+
chainName,
|
|
94
|
+
refreshError,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
75
97
|
return true;
|
|
76
98
|
}
|
|
77
99
|
catch (error) {
|
|
@@ -84,7 +106,7 @@ const useWalletPassword = () => {
|
|
|
84
106
|
});
|
|
85
107
|
return false;
|
|
86
108
|
}
|
|
87
|
-
}), [getWaasWalletConnector]);
|
|
109
|
+
}), [getWaasWalletConnector, refreshUser]);
|
|
88
110
|
const unlockWallet = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89
111
|
const { accountAddress, chainName, password } = params;
|
|
90
112
|
setState((prev) => (Object.assign(Object.assign({}, prev), { error: null, isLoading: true })));
|
|
@@ -124,8 +124,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
|
|
|
124
124
|
const { data: codes, isLoading } = usePromise.usePromise(() => getRecoveryCodes(regenerateCodes));
|
|
125
125
|
const codesAsString = (codes || []).join('\n');
|
|
126
126
|
const handleCompleteAcknowledgement = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
127
|
-
setShowAuthFlow(false);
|
|
128
127
|
yield completeAcknowledgement();
|
|
128
|
+
setShowAuthFlow(false);
|
|
129
129
|
});
|
|
130
130
|
const handleDownload = (e) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
131
131
|
e.preventDefault();
|
|
@@ -120,8 +120,8 @@ const MfaDisplayBackupCodesView = ({ regenerateCodes = false, }) => {
|
|
|
120
120
|
const { data: codes, isLoading } = usePromise(() => getRecoveryCodes(regenerateCodes));
|
|
121
121
|
const codesAsString = (codes || []).join('\n');
|
|
122
122
|
const handleCompleteAcknowledgement = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
|
-
setShowAuthFlow(false);
|
|
124
123
|
yield completeAcknowledgement();
|
|
124
|
+
setShowAuthFlow(false);
|
|
125
125
|
});
|
|
126
126
|
const handleDownload = (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
127
127
|
e.preventDefault();
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var React = require('react');
|
|
9
8
|
require('../../context/DynamicContext/DynamicContext.cjs');
|
|
@@ -11,7 +10,7 @@ require('../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
|
11
10
|
require('@dynamic-labs/iconic');
|
|
12
11
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
12
|
require('../../context/ViewContext/ViewContext.cjs');
|
|
14
|
-
|
|
13
|
+
require('../../shared/logger.cjs');
|
|
15
14
|
require('@dynamic-labs/wallet-book');
|
|
16
15
|
require('@dynamic-labs/utils');
|
|
17
16
|
require('../../utils/constants/colors.cjs');
|
|
@@ -19,6 +18,7 @@ require('../../utils/constants/values.cjs');
|
|
|
19
18
|
require('@dynamic-labs/sdk-api-core');
|
|
20
19
|
require('../../shared/consts/index.cjs');
|
|
21
20
|
require('../../events/dynamicEvents.cjs');
|
|
21
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
22
22
|
require('../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
23
|
require('../../context/ErrorContext/ErrorContext.cjs');
|
|
24
24
|
require('@dynamic-labs/multi-wallet');
|
|
@@ -42,7 +42,6 @@ require('react-dom');
|
|
|
42
42
|
require('../../utils/functions/compareChains/compareChains.cjs');
|
|
43
43
|
require('../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
44
44
|
require('../../context/ThemeContext/ThemeContext.cjs');
|
|
45
|
-
var useSmartWallets = require('../../utils/hooks/useSmartWallets/useSmartWallets.cjs');
|
|
46
45
|
require('../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
47
46
|
require('bs58');
|
|
48
47
|
require('@dynamic-labs/types');
|
|
@@ -92,7 +91,6 @@ require('../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
|
92
91
|
require('../../context/FooterAnimationContext/index.cjs');
|
|
93
92
|
require('../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
94
93
|
require('../../context/PasskeyContext/PasskeyContext.cjs');
|
|
95
|
-
var useWalletPassword = require('../../utils/hooks/useWalletPassword/useWalletPassword.cjs');
|
|
96
94
|
var ResetPasswordView = require('../../widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.cjs');
|
|
97
95
|
require('../../context/OnrampContext/OnrampContext.cjs');
|
|
98
96
|
require('../../store/state/sendBalances.cjs');
|
|
@@ -110,24 +108,10 @@ require('../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
|
110
108
|
var useInternalDynamicContext = require('../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
111
109
|
|
|
112
110
|
const ResetPasswordForSettingsView = () => {
|
|
113
|
-
const {
|
|
114
|
-
const
|
|
115
|
-
const { updatePassword } = useWalletPassword.useWalletPassword();
|
|
116
|
-
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
117
|
-
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
118
|
-
const handleComplete = React.useCallback((oldPassword, newPassword) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
120
|
-
logger.logger.error('No wallet address or chain available for password reset');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
yield updatePassword({
|
|
124
|
-
accountAddress: wallet.address,
|
|
125
|
-
chainName: wallet.chain,
|
|
126
|
-
existingPassword: oldPassword,
|
|
127
|
-
newPassword,
|
|
128
|
-
});
|
|
111
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
112
|
+
const handleComplete = React.useCallback(() => {
|
|
129
113
|
setShowAuthFlow(false);
|
|
130
|
-
}
|
|
114
|
+
}, [setShowAuthFlow]);
|
|
131
115
|
return jsxRuntime.jsx(ResetPasswordView.ResetPasswordView, { onComplete: handleComplete });
|
|
132
116
|
};
|
|
133
117
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
3
2
|
import { jsx } from 'react/jsx-runtime';
|
|
4
3
|
import { useCallback } from 'react';
|
|
5
4
|
import '../../context/DynamicContext/DynamicContext.js';
|
|
@@ -7,7 +6,7 @@ import '../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
|
7
6
|
import '@dynamic-labs/iconic';
|
|
8
7
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
8
|
import '../../context/ViewContext/ViewContext.js';
|
|
10
|
-
import
|
|
9
|
+
import '../../shared/logger.js';
|
|
11
10
|
import '@dynamic-labs/wallet-book';
|
|
12
11
|
import '@dynamic-labs/utils';
|
|
13
12
|
import '../../utils/constants/colors.js';
|
|
@@ -15,6 +14,7 @@ import '../../utils/constants/values.js';
|
|
|
15
14
|
import '@dynamic-labs/sdk-api-core';
|
|
16
15
|
import '../../shared/consts/index.js';
|
|
17
16
|
import '../../events/dynamicEvents.js';
|
|
17
|
+
import '../../../../_virtual/_tslib.js';
|
|
18
18
|
import '../../context/CaptchaContext/CaptchaContext.js';
|
|
19
19
|
import '../../context/ErrorContext/ErrorContext.js';
|
|
20
20
|
import '@dynamic-labs/multi-wallet';
|
|
@@ -38,7 +38,6 @@ import 'react-dom';
|
|
|
38
38
|
import '../../utils/functions/compareChains/compareChains.js';
|
|
39
39
|
import '../Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
40
40
|
import '../../context/ThemeContext/ThemeContext.js';
|
|
41
|
-
import { useSmartWallets } from '../../utils/hooks/useSmartWallets/useSmartWallets.js';
|
|
42
41
|
import '../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
43
42
|
import 'bs58';
|
|
44
43
|
import '@dynamic-labs/types';
|
|
@@ -88,7 +87,6 @@ import '../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
|
88
87
|
import '../../context/FooterAnimationContext/index.js';
|
|
89
88
|
import '../MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
90
89
|
import '../../context/PasskeyContext/PasskeyContext.js';
|
|
91
|
-
import { useWalletPassword } from '../../utils/hooks/useWalletPassword/useWalletPassword.js';
|
|
92
90
|
import { ResetPasswordView } from '../../widgets/DynamicWidget/views/ResetPasswordView/ResetPasswordView.js';
|
|
93
91
|
import '../../context/OnrampContext/OnrampContext.js';
|
|
94
92
|
import '../../store/state/sendBalances.js';
|
|
@@ -106,24 +104,10 @@ import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
|
106
104
|
import { useInternalDynamicContext } from '../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
107
105
|
|
|
108
106
|
const ResetPasswordForSettingsView = () => {
|
|
109
|
-
const {
|
|
110
|
-
const
|
|
111
|
-
const { updatePassword } = useWalletPassword();
|
|
112
|
-
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
113
|
-
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
114
|
-
const handleComplete = useCallback((oldPassword, newPassword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
115
|
-
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
116
|
-
logger.error('No wallet address or chain available for password reset');
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
yield updatePassword({
|
|
120
|
-
accountAddress: wallet.address,
|
|
121
|
-
chainName: wallet.chain,
|
|
122
|
-
existingPassword: oldPassword,
|
|
123
|
-
newPassword,
|
|
124
|
-
});
|
|
107
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
108
|
+
const handleComplete = useCallback(() => {
|
|
125
109
|
setShowAuthFlow(false);
|
|
126
|
-
}
|
|
110
|
+
}, [setShowAuthFlow]);
|
|
127
111
|
return jsx(ResetPasswordView, { onComplete: handleComplete });
|
|
128
112
|
};
|
|
129
113
|
|
package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs
CHANGED
|
@@ -115,9 +115,17 @@ const SetupPasswordForWalletCreationView = () => {
|
|
|
115
115
|
}, [setShowAuthFlow]);
|
|
116
116
|
const handleComplete = React.useCallback((password) => {
|
|
117
117
|
dynamicEvents.dynamicEvents.emit('embeddedWalletPasswordSetupCompleted', password);
|
|
118
|
+
// Return a Promise that resolves when embeddedWalletCreated fires.
|
|
119
|
+
// This keeps the knowledge check screen in loading state while wallet creation
|
|
120
|
+
// is in progress, then transitions to the done screen on success.
|
|
121
|
+
return new Promise((resolve) => {
|
|
122
|
+
dynamicEvents.dynamicEvents.once('embeddedWalletCreated', () => resolve());
|
|
123
|
+
});
|
|
124
|
+
}, []);
|
|
125
|
+
const handleDone = React.useCallback(() => {
|
|
118
126
|
setShowAuthFlow(false);
|
|
119
127
|
}, [setShowAuthFlow]);
|
|
120
|
-
return (jsxRuntime.jsx(SetupPasswordView.SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel }));
|
|
128
|
+
return (jsxRuntime.jsx(SetupPasswordView.SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel, onDone: handleDone }));
|
|
121
129
|
};
|
|
122
130
|
|
|
123
131
|
exports.SetupPasswordForWalletCreationView = SetupPasswordForWalletCreationView;
|
package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js
CHANGED
|
@@ -111,9 +111,17 @@ const SetupPasswordForWalletCreationView = () => {
|
|
|
111
111
|
}, [setShowAuthFlow]);
|
|
112
112
|
const handleComplete = useCallback((password) => {
|
|
113
113
|
dynamicEvents.emit('embeddedWalletPasswordSetupCompleted', password);
|
|
114
|
+
// Return a Promise that resolves when embeddedWalletCreated fires.
|
|
115
|
+
// This keeps the knowledge check screen in loading state while wallet creation
|
|
116
|
+
// is in progress, then transitions to the done screen on success.
|
|
117
|
+
return new Promise((resolve) => {
|
|
118
|
+
dynamicEvents.once('embeddedWalletCreated', () => resolve());
|
|
119
|
+
});
|
|
120
|
+
}, []);
|
|
121
|
+
const handleDone = useCallback(() => {
|
|
114
122
|
setShowAuthFlow(false);
|
|
115
123
|
}, [setShowAuthFlow]);
|
|
116
|
-
return (jsx(SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel }));
|
|
124
|
+
return (jsx(SetupPasswordView, { onComplete: handleComplete, onCancel: handleCancel, onDone: handleDone }));
|
|
117
125
|
};
|
|
118
126
|
|
|
119
127
|
export { SetupPasswordForWalletCreationView };
|
|
@@ -116,7 +116,7 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
116
116
|
const { t } = reactI18next.useTranslation();
|
|
117
117
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
118
118
|
const { getEOAWallet } = useSmartWallets.useSmartWallets();
|
|
119
|
-
const { unlockWallet } = useWalletPassword.useWalletPassword();
|
|
119
|
+
const { unlockWallet, updatePassword } = useWalletPassword.useWalletPassword();
|
|
120
120
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
121
121
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
122
122
|
const [currentStep, setCurrentStep] = React.useState('current');
|
|
@@ -124,6 +124,8 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
124
124
|
const [newPassword, setNewPassword] = React.useState('');
|
|
125
125
|
const [verifyError, setVerifyError] = React.useState(null);
|
|
126
126
|
const [isVerifying, setIsVerifying] = React.useState(false);
|
|
127
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
128
|
+
const [submitError, setSubmitError] = React.useState(null);
|
|
127
129
|
const handleCurrentPasswordContinue = React.useCallback((password) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
128
130
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
129
131
|
logger.logger.error('No wallet address or chain available for password verification');
|
|
@@ -156,9 +158,28 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
156
158
|
const handleEnterBack = React.useCallback(() => {
|
|
157
159
|
setCurrentStep('current');
|
|
158
160
|
}, []);
|
|
159
|
-
const handleConfirmContinue = React.useCallback(() => {
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
const handleConfirmContinue = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
163
|
+
logger.logger.error('No wallet address or chain available for password reset');
|
|
164
|
+
setSubmitError(t('dyn_reset_password.confirm.error.failed'));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
setIsSubmitting(true);
|
|
168
|
+
setSubmitError(null);
|
|
169
|
+
const success = yield updatePassword({
|
|
170
|
+
accountAddress: wallet.address,
|
|
171
|
+
chainName: wallet.chain,
|
|
172
|
+
existingPassword: currentPassword,
|
|
173
|
+
newPassword,
|
|
174
|
+
});
|
|
175
|
+
setIsSubmitting(false);
|
|
176
|
+
if (success) {
|
|
177
|
+
setCurrentStep('success');
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
setSubmitError(t('dyn_reset_password.confirm.error.failed'));
|
|
181
|
+
}
|
|
182
|
+
}), [wallet, updatePassword, currentPassword, newPassword, t]);
|
|
162
183
|
const handleConfirmBack = React.useCallback(() => {
|
|
163
184
|
setCurrentStep('enter');
|
|
164
185
|
}, []);
|
|
@@ -171,7 +192,7 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
171
192
|
case 'enter':
|
|
172
193
|
return (jsxRuntime.jsx(SetupPasswordEnterView.SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack, title: t('dyn_reset_password.enter.title'), description: t('dyn_reset_password.enter.description'), oldPassword: currentPassword }));
|
|
173
194
|
case 'confirm':
|
|
174
|
-
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true }));
|
|
195
|
+
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true, isLoading: isSubmitting, error: submitError }));
|
|
175
196
|
case 'success':
|
|
176
197
|
return (jsxRuntime.jsx(SetupPasswordSuccessView.SetupPasswordSuccessView, { onDone: handleSuccess, title: t('dyn_reset_password.success.title'), description: t('dyn_reset_password.success.description') }));
|
|
177
198
|
default:
|
|
@@ -112,7 +112,7 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
112
112
|
const { t } = useTranslation();
|
|
113
113
|
const { primaryWallet, setShowAuthFlow } = useInternalDynamicContext();
|
|
114
114
|
const { getEOAWallet } = useSmartWallets();
|
|
115
|
-
const { unlockWallet } = useWalletPassword();
|
|
115
|
+
const { unlockWallet, updatePassword } = useWalletPassword();
|
|
116
116
|
const eoaWallet = primaryWallet && getEOAWallet(primaryWallet);
|
|
117
117
|
const wallet = eoaWallet !== null && eoaWallet !== void 0 ? eoaWallet : primaryWallet;
|
|
118
118
|
const [currentStep, setCurrentStep] = useState('current');
|
|
@@ -120,6 +120,8 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
120
120
|
const [newPassword, setNewPassword] = useState('');
|
|
121
121
|
const [verifyError, setVerifyError] = useState(null);
|
|
122
122
|
const [isVerifying, setIsVerifying] = useState(false);
|
|
123
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
124
|
+
const [submitError, setSubmitError] = useState(null);
|
|
123
125
|
const handleCurrentPasswordContinue = useCallback((password) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
126
|
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
125
127
|
logger.error('No wallet address or chain available for password verification');
|
|
@@ -152,9 +154,28 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
152
154
|
const handleEnterBack = useCallback(() => {
|
|
153
155
|
setCurrentStep('current');
|
|
154
156
|
}, []);
|
|
155
|
-
const handleConfirmContinue = useCallback(() => {
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
const handleConfirmContinue = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
+
if (!(wallet === null || wallet === void 0 ? void 0 : wallet.address) || !(wallet === null || wallet === void 0 ? void 0 : wallet.chain)) {
|
|
159
|
+
logger.error('No wallet address or chain available for password reset');
|
|
160
|
+
setSubmitError(t('dyn_reset_password.confirm.error.failed'));
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
setIsSubmitting(true);
|
|
164
|
+
setSubmitError(null);
|
|
165
|
+
const success = yield updatePassword({
|
|
166
|
+
accountAddress: wallet.address,
|
|
167
|
+
chainName: wallet.chain,
|
|
168
|
+
existingPassword: currentPassword,
|
|
169
|
+
newPassword,
|
|
170
|
+
});
|
|
171
|
+
setIsSubmitting(false);
|
|
172
|
+
if (success) {
|
|
173
|
+
setCurrentStep('success');
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
setSubmitError(t('dyn_reset_password.confirm.error.failed'));
|
|
177
|
+
}
|
|
178
|
+
}), [wallet, updatePassword, currentPassword, newPassword, t]);
|
|
158
179
|
const handleConfirmBack = useCallback(() => {
|
|
159
180
|
setCurrentStep('enter');
|
|
160
181
|
}, []);
|
|
@@ -167,7 +188,7 @@ const ResetPasswordView = ({ onComplete, }) => {
|
|
|
167
188
|
case 'enter':
|
|
168
189
|
return (jsx(SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack, title: t('dyn_reset_password.enter.title'), description: t('dyn_reset_password.enter.description'), oldPassword: currentPassword }));
|
|
169
190
|
case 'confirm':
|
|
170
|
-
return (jsx(SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true }));
|
|
191
|
+
return (jsx(SetupPasswordConfirmView, { password: newPassword, onContinue: handleConfirmContinue, onBack: handleConfirmBack, title: t('dyn_reset_password.confirm.title'), description: t('dyn_reset_password.confirm.description'), showAcknowledgment: true, isLoading: isSubmitting, error: submitError }));
|
|
171
192
|
case 'success':
|
|
172
193
|
return (jsx(SetupPasswordSuccessView, { onDone: handleSuccess, title: t('dyn_reset_password.success.title'), description: t('dyn_reset_password.success.description') }));
|
|
173
194
|
default:
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.cjs
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var reactI18next = require('react-i18next');
|
|
9
|
+
var Alert = require('../../../../components/Alert/Alert.cjs');
|
|
9
10
|
var Checkbox = require('../../../../components/Checkbox/Checkbox.cjs');
|
|
10
11
|
var Icon = require('../../../../components/Icon/Icon.cjs');
|
|
11
12
|
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
@@ -21,7 +22,7 @@ var secureAction = require('../../../../shared/assets/secure-action.cjs');
|
|
|
21
22
|
require('@dynamic-labs/iconic');
|
|
22
23
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
23
24
|
|
|
24
|
-
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, }) => {
|
|
25
|
+
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, isLoading = false, error = null, }) => {
|
|
25
26
|
const { t } = reactI18next.useTranslation();
|
|
26
27
|
const [confirmPassword, setConfirmPassword] = React.useState('');
|
|
27
28
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
@@ -53,7 +54,7 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, descrip
|
|
|
53
54
|
: t('dyn_setup_password.confirm.mismatch');
|
|
54
55
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: backButton, children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: title !== null && title !== void 0 ? title : t('dyn_setup_password.confirm.title') }) }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view', children: [jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsxRuntime.jsx(Icon.Icon, { color: 'brand-primary', children: jsxRuntime.jsx(secureAction.ReactComponent, { width: 64, height: 64 }) }) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: description !== null && description !== void 0 ? description : t('dyn_setup_password.confirm.description') }), jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsxRuntime.jsx(Input.Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
55
56
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
56
|
-
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsxRuntime.jsx(Icon.Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsxRuntime.jsx(checkCircle.ReactComponent, {})) : (jsxRuntime.jsx(exclamationCircle.ReactComponent, {})) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxRuntime.jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
57
|
+
jsxRuntime.jsx(ToggleVisibilityButton.ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxRuntime.jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsxRuntime.jsx(Icon.Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsxRuntime.jsx(checkCircle.ReactComponent, {})) : (jsxRuntime.jsx(exclamationCircle.ReactComponent, {})) }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxRuntime.jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsxRuntime.jsx(Checkbox.Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), error && (jsxRuntime.jsx(Alert.Alert, { variant: 'error', icon: jsxRuntime.jsx(exclamationCircle.ReactComponent, {}), className: 'setup-password-confirm-view__error', children: error })), jsxRuntime.jsx("div", { className: 'setup-password-confirm-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid || isLoading, loading: isLoading, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
57
58
|
color: 'inherit',
|
|
58
59
|
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] })] }));
|
|
59
60
|
};
|
package/src/lib/widgets/DynamicWidget/views/SetupPasswordConfirmView/SetupPasswordConfirmView.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useState, useCallback } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Alert } from '../../../../components/Alert/Alert.js';
|
|
5
6
|
import { Checkbox } from '../../../../components/Checkbox/Checkbox.js';
|
|
6
7
|
import { Icon } from '../../../../components/Icon/Icon.js';
|
|
7
8
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
@@ -17,7 +18,7 @@ import { ReactComponent as SvgSecureAction } from '../../../../shared/assets/sec
|
|
|
17
18
|
import '@dynamic-labs/iconic';
|
|
18
19
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
19
20
|
|
|
20
|
-
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, }) => {
|
|
21
|
+
const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, description, showAcknowledgment = false, isLoading = false, error = null, }) => {
|
|
21
22
|
const { t } = useTranslation();
|
|
22
23
|
const [confirmPassword, setConfirmPassword] = useState('');
|
|
23
24
|
const [showPassword, setShowPassword] = useState(false);
|
|
@@ -49,7 +50,7 @@ const SetupPasswordConfirmView = ({ password, onContinue, onBack, title, descrip
|
|
|
49
50
|
: t('dyn_setup_password.confirm.mismatch');
|
|
50
51
|
return (jsxs(Fragment, { children: [jsx(ModalHeader, { leading: backButton, children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_setup_password.confirm.title', children: title !== null && title !== void 0 ? title : t('dyn_setup_password.confirm.title') }) }), jsxs("div", { className: 'setup-password-confirm-view', children: [jsxs("div", { className: 'setup-password-confirm-view__body', children: [jsx("div", { className: 'setup-password-confirm-view__icon-container', children: jsx(Icon, { color: 'brand-primary', children: jsx(SvgSecureAction, { width: 64, height: 64 }) }) }), jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_setup_password.confirm.description', className: 'setup-password-confirm-view__description', children: description !== null && description !== void 0 ? description : t('dyn_setup_password.confirm.description') }), jsxs("div", { className: 'setup-password-confirm-view__input-container', children: [jsx(Input, { id: 'setup-password-confirm-password-input', type: showPassword ? 'text' : 'password', label: t('dyn_setup_password.confirm.label'), placeholder: t('dyn_setup_password.confirm.placeholder'), value: confirmPassword, onChange: handlePasswordChange, variant: 'regular', error: !passwordsMatch && hasInteracted && confirmPassword.length > 0, suffix:
|
|
51
52
|
// eslint-disable-next-line react/jsx-wrap-multilines
|
|
52
|
-
jsx(ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsx(Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsx(SvgCheckCircle, {})) : (jsx(SvgExclamationCircle, {})) }), jsx(Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsx(Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsx(Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), jsx("div", { className: 'setup-password-confirm-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
53
|
+
jsx(ToggleVisibilityButton, { initialState: true, onClick: handleToggleVisibility }) }), showMatchMessage && (jsxs("div", { className: 'setup-password-confirm-view__match-indicator', children: [jsx(Icon, { color: passwordsMatch ? 'success-1' : 'text-error', size: 'medium', children: passwordsMatch ? (jsx(SvgCheckCircle, {})) : (jsx(SvgExclamationCircle, {})) }), jsx(Typography, { variant: 'body_small', color: passwordsMatch ? 'secondary' : 'error-1', children: matchMessage })] }))] })] }), showAcknowledgment && (jsxs("label", { className: 'setup-password-confirm-view__acknowledgment', children: [jsx(Checkbox, { checked: acknowledged, onChange: handleAcknowledgmentChange, ariaLabel: t('dyn_reset_password.confirm.acknowledgment') }), jsx(Typography, { variant: 'body_small', color: 'secondary', copykey: 'dyn_reset_password.confirm.acknowledgment', children: t('dyn_reset_password.confirm.acknowledgment') })] })), error && (jsx(Alert, { variant: 'error', icon: jsx(SvgExclamationCircle, {}), className: 'setup-password-confirm-view__error', children: error })), jsx("div", { className: 'setup-password-confirm-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-confirm-continue-button', onClick: handleContinue, disabled: !isValid || isLoading, loading: isLoading, copykey: 'dyn_setup_password.button.continue', buttonVariant: 'brand-primary', typographyProps: {
|
|
53
54
|
color: 'inherit',
|
|
54
55
|
}, expanded: true, children: t('dyn_setup_password.button.continue') }) })] })] }));
|
|
55
56
|
};
|
|
@@ -36,7 +36,7 @@ const OPTIONS = [
|
|
|
36
36
|
value: 'c',
|
|
37
37
|
},
|
|
38
38
|
];
|
|
39
|
-
const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack }) => {
|
|
39
|
+
const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack, isLoading = false, error = null }) => {
|
|
40
40
|
const { t } = reactI18next.useTranslation();
|
|
41
41
|
const [selectedAnswer, setSelectedAnswer] = React.useState('');
|
|
42
42
|
const [showError, setShowError] = React.useState(false);
|
|
@@ -67,7 +67,7 @@ const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack }) => {
|
|
|
67
67
|
: isSelected
|
|
68
68
|
? 'brand-primary'
|
|
69
69
|
: 'tertiary', weight: 'bold', className: 'setup-password-knowledge-check-view__option-label', children: option.label }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: 'primary', children: t(option.translationKey) })] }, option.value));
|
|
70
|
-
}) })] })] }), jsxRuntime.jsxs("div", { children: [showError && (jsxRuntime.jsx(Alert.Alert, { variant: 'error', icon: jsxRuntime.jsx(exclamationCircle.ReactComponent, {}), className: 'setup-password-knowledge-check-view__error', children: t('dyn_setup_password.knowledge_check.error') })), jsxRuntime.jsx("div", { className: 'setup-password-knowledge-check-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-knowledge-check-continue-button', onClick: handleContinue, disabled: !selectedAnswer, copykey: 'dyn_setup_password.button.confirm', buttonVariant: 'brand-primary', typographyProps: {
|
|
70
|
+
}) })] })] }), jsxRuntime.jsxs("div", { children: [showError && (jsxRuntime.jsx(Alert.Alert, { variant: 'error', icon: jsxRuntime.jsx(exclamationCircle.ReactComponent, {}), className: 'setup-password-knowledge-check-view__error', children: t('dyn_setup_password.knowledge_check.error') })), error && (jsxRuntime.jsx(Alert.Alert, { variant: 'error', icon: jsxRuntime.jsx(exclamationCircle.ReactComponent, {}), className: 'setup-password-knowledge-check-view__error', children: error })), jsxRuntime.jsx("div", { className: 'setup-password-knowledge-check-view__actions', children: jsxRuntime.jsx(TypographyButton.TypographyButton, { dataTestId: 'setup-password-knowledge-check-continue-button', onClick: handleContinue, disabled: !selectedAnswer || isLoading, loading: isLoading, copykey: 'dyn_setup_password.button.confirm', buttonVariant: 'brand-primary', typographyProps: {
|
|
71
71
|
color: 'inherit',
|
|
72
72
|
}, expanded: true, children: t('dyn_setup_password.button.confirm') }) })] })] }) })] }));
|
|
73
73
|
};
|
|
@@ -2,5 +2,7 @@ import { FC } from 'react';
|
|
|
2
2
|
export type SetupPasswordKnowledgeCheckViewProps = {
|
|
3
3
|
onContinue: () => void;
|
|
4
4
|
onBack: () => void;
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
error?: string | null;
|
|
5
7
|
};
|
|
6
8
|
export declare const SetupPasswordKnowledgeCheckView: FC<SetupPasswordKnowledgeCheckViewProps>;
|
|
@@ -32,7 +32,7 @@ const OPTIONS = [
|
|
|
32
32
|
value: 'c',
|
|
33
33
|
},
|
|
34
34
|
];
|
|
35
|
-
const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack }) => {
|
|
35
|
+
const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack, isLoading = false, error = null }) => {
|
|
36
36
|
const { t } = useTranslation();
|
|
37
37
|
const [selectedAnswer, setSelectedAnswer] = useState('');
|
|
38
38
|
const [showError, setShowError] = useState(false);
|
|
@@ -63,7 +63,7 @@ const SetupPasswordKnowledgeCheckView = ({ onContinue, onBack }) => {
|
|
|
63
63
|
: isSelected
|
|
64
64
|
? 'brand-primary'
|
|
65
65
|
: 'tertiary', weight: 'bold', className: 'setup-password-knowledge-check-view__option-label', children: option.label }), jsx(Typography, { variant: 'body_small', color: 'primary', children: t(option.translationKey) })] }, option.value));
|
|
66
|
-
}) })] })] }), jsxs("div", { children: [showError && (jsx(Alert, { variant: 'error', icon: jsx(SvgExclamationCircle, {}), className: 'setup-password-knowledge-check-view__error', children: t('dyn_setup_password.knowledge_check.error') })), jsx("div", { className: 'setup-password-knowledge-check-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-knowledge-check-continue-button', onClick: handleContinue, disabled: !selectedAnswer, copykey: 'dyn_setup_password.button.confirm', buttonVariant: 'brand-primary', typographyProps: {
|
|
66
|
+
}) })] })] }), jsxs("div", { children: [showError && (jsx(Alert, { variant: 'error', icon: jsx(SvgExclamationCircle, {}), className: 'setup-password-knowledge-check-view__error', children: t('dyn_setup_password.knowledge_check.error') })), error && (jsx(Alert, { variant: 'error', icon: jsx(SvgExclamationCircle, {}), className: 'setup-password-knowledge-check-view__error', children: error })), jsx("div", { className: 'setup-password-knowledge-check-view__actions', children: jsx(TypographyButton, { dataTestId: 'setup-password-knowledge-check-continue-button', onClick: handleContinue, disabled: !selectedAnswer || isLoading, loading: isLoading, copykey: 'dyn_setup_password.button.confirm', buttonVariant: 'brand-primary', typographyProps: {
|
|
67
67
|
color: 'inherit',
|
|
68
68
|
}, expanded: true, children: t('dyn_setup_password.button.confirm') }) })] })] }) })] }));
|
|
69
69
|
};
|