@dynamic-labs/sdk-react-core 4.65.0 → 4.67.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 +32 -0
- package/package.cjs +4 -4
- package/package.js +4 -4
- package/package.json +15 -15
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +1 -0
- package/src/lib/Main.cjs +1 -0
- package/src/lib/Main.js +1 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.cjs +18 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.d.ts +1 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/hasElevatedAccessToken.js +14 -0
- package/src/lib/client/extension/functions/hasElevatedAccessToken/index.d.ts +1 -0
- package/src/lib/client/extension/index.d.ts +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +20 -19
- package/src/lib/context/DynamicContext/DynamicContext.js +20 -19
- package/src/lib/context/DynamicContext/types/SettingsOverrides.d.ts +10 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/constants/values.cjs +2 -0
- package/src/lib/utils/constants/values.js +2 -0
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +7 -3
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +4 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +7 -3
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.cjs +7 -2
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.d.ts +2 -1
- package/src/lib/utils/hooks/useNetworkConfigurationsFromProjectSettings/useNetworkConfigurationsFromProjectSettings.js +7 -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/useStepUpAuthentication/index.d.ts +1 -1
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.cjs +102 -23
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.d.ts +35 -15
- package/src/lib/utils/hooks/useStepUpAuthentication/useStepUpAuthentication.js +103 -24
- 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/useWalletConnectorNetwork/useWalletConnectorNetwork.cjs +3 -2
- package/src/lib/utils/hooks/useWalletConnectorNetwork/useWalletConnectorNetwork.js +3 -2
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.cjs +24 -2
- package/src/lib/utils/hooks/useWalletPassword/useWalletPassword.js +24 -2
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.cjs +10 -6
- package/src/lib/views/CollectUserDataView/UserDataFields/UserPhoneField/UserPhoneField.js +11 -7
- 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/SendBalanceView/SendBalanceView.cjs +1 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +1 -0
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.cjs +9 -1
- package/src/lib/views/SetupPasswordForWalletCreationView/SetupPasswordForWalletCreationView.js +9 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +21 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +21 -1
- package/src/lib/views/WalletList/data.cjs +1 -0
- package/src/lib/views/WalletList/data.d.ts +1 -1
- package/src/lib/views/WalletList/data.js +1 -0
- 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
|
@@ -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
|
};
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../../../../_virtual/_tslib.cjs');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var React = require('react');
|
|
9
|
+
var reactI18next = require('react-i18next');
|
|
8
10
|
var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
9
11
|
var SetupPasswordConfirmView = require('../SetupPasswordConfirmView/SetupPasswordConfirmView.cjs');
|
|
10
12
|
var SetupPasswordEnterView = require('../SetupPasswordEnterView/SetupPasswordEnterView.cjs');
|
|
11
|
-
require('../../../../../../_virtual/_tslib.cjs');
|
|
12
13
|
require('@dynamic-labs/utils');
|
|
13
14
|
require('@dynamic-labs/iconic');
|
|
14
15
|
require('../../../../context/ViewContext/ViewContext.cjs');
|
|
@@ -16,10 +17,13 @@ var SetupPasswordKnowledgeCheckView = require('../SetupPasswordKnowledgeCheckVie
|
|
|
16
17
|
var SetupPasswordSuccessView = require('../SetupPasswordSuccessView/SetupPasswordSuccessView.cjs');
|
|
17
18
|
var SetupPasswordTermsView = require('../SetupPasswordTermsView/SetupPasswordTermsView.cjs');
|
|
18
19
|
|
|
19
|
-
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
20
|
+
const SetupPasswordView = ({ onComplete, onCancel, onDone, skipKnowledgeCheck = false, }) => {
|
|
21
|
+
const { t } = reactI18next.useTranslation();
|
|
20
22
|
const { setDynamicWidgetView, setIsOpen } = DynamicWidgetContext.useWidgetContext();
|
|
21
23
|
const [currentStep, setCurrentStep] = React.useState('terms');
|
|
22
24
|
const [password, setPassword] = React.useState('');
|
|
25
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
26
|
+
const [submitError, setSubmitError] = React.useState(null);
|
|
23
27
|
const goToAccountAndSecurity = React.useCallback(() => {
|
|
24
28
|
setDynamicWidgetView('account-and-security-settings');
|
|
25
29
|
}, [setDynamicWidgetView]);
|
|
@@ -41,20 +45,34 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
41
45
|
const handleEnterBack = React.useCallback(() => {
|
|
42
46
|
setCurrentStep('terms');
|
|
43
47
|
}, []);
|
|
44
|
-
const
|
|
45
|
-
|
|
48
|
+
const runOnComplete = React.useCallback((pwd) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
setIsSubmitting(true);
|
|
50
|
+
setSubmitError(null);
|
|
51
|
+
try {
|
|
52
|
+
yield onComplete(pwd);
|
|
46
53
|
setCurrentStep('success');
|
|
47
54
|
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
setSubmitError(t('dyn_setup_password.confirm.error.failed'));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
setIsSubmitting(false);
|
|
60
|
+
}
|
|
61
|
+
}), [onComplete, t]);
|
|
62
|
+
const handleConfirmContinue = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
if (skipKnowledgeCheck) {
|
|
64
|
+
yield runOnComplete(password);
|
|
65
|
+
}
|
|
48
66
|
else {
|
|
49
67
|
setCurrentStep('knowledge-check');
|
|
50
68
|
}
|
|
51
|
-
}, [skipKnowledgeCheck]);
|
|
69
|
+
}), [skipKnowledgeCheck, runOnComplete, password]);
|
|
52
70
|
const handleConfirmBack = React.useCallback(() => {
|
|
53
71
|
setCurrentStep('enter');
|
|
54
72
|
}, []);
|
|
55
|
-
const handleKnowledgeCheckContinue = React.useCallback(() => {
|
|
56
|
-
|
|
57
|
-
}, []);
|
|
73
|
+
const handleKnowledgeCheckContinue = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
+
yield runOnComplete(password);
|
|
75
|
+
}), [runOnComplete, password]);
|
|
58
76
|
const handleKnowledgeCheckBack = React.useCallback(() => {
|
|
59
77
|
setCurrentStep('confirm');
|
|
60
78
|
}, []);
|
|
@@ -62,10 +80,7 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
62
80
|
setDynamicWidgetView('wallets');
|
|
63
81
|
}, [setDynamicWidgetView]);
|
|
64
82
|
const handleSuccess = React.useCallback(() => {
|
|
65
|
-
|
|
66
|
-
// Navigate to appropriate view based on where we came from:
|
|
67
|
-
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
68
|
-
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
83
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
69
84
|
if (onCancel) {
|
|
70
85
|
goToWallets();
|
|
71
86
|
setIsOpen(false);
|
|
@@ -73,23 +88,16 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
73
88
|
else {
|
|
74
89
|
goToAccountAndSecurity();
|
|
75
90
|
}
|
|
76
|
-
}, [
|
|
77
|
-
onComplete,
|
|
78
|
-
password,
|
|
79
|
-
onCancel,
|
|
80
|
-
goToAccountAndSecurity,
|
|
81
|
-
goToWallets,
|
|
82
|
-
setIsOpen,
|
|
83
|
-
]);
|
|
91
|
+
}, [onDone, onCancel, goToAccountAndSecurity, goToWallets, setIsOpen]);
|
|
84
92
|
switch (currentStep) {
|
|
85
93
|
case 'terms':
|
|
86
94
|
return (jsxRuntime.jsx(SetupPasswordTermsView.SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|
|
87
95
|
case 'enter':
|
|
88
96
|
return (jsxRuntime.jsx(SetupPasswordEnterView.SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack }));
|
|
89
97
|
case 'confirm':
|
|
90
|
-
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack }));
|
|
98
|
+
return (jsxRuntime.jsx(SetupPasswordConfirmView.SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack, isLoading: isSubmitting && skipKnowledgeCheck, error: skipKnowledgeCheck ? submitError : null }));
|
|
91
99
|
case 'knowledge-check':
|
|
92
|
-
return (jsxRuntime.jsx(SetupPasswordKnowledgeCheckView.SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack }));
|
|
100
|
+
return (jsxRuntime.jsx(SetupPasswordKnowledgeCheckView.SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack, isLoading: isSubmitting, error: submitError }));
|
|
93
101
|
case 'success':
|
|
94
102
|
return jsxRuntime.jsx(SetupPasswordSuccessView.SetupPasswordSuccessView, { onDone: handleSuccess });
|
|
95
103
|
default:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
export type SetupPasswordViewProps = {
|
|
3
|
-
onComplete: (password: string) => void;
|
|
3
|
+
onComplete: (password: string) => Promise<void> | void;
|
|
4
4
|
onCancel?: () => void;
|
|
5
|
+
onDone?: () => void;
|
|
5
6
|
skipKnowledgeCheck?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const SetupPasswordView: FC<SetupPasswordViewProps>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
2
3
|
import { jsx } from 'react/jsx-runtime';
|
|
3
4
|
import { useState, useCallback } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
4
6
|
import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
5
7
|
import { SetupPasswordConfirmView } from '../SetupPasswordConfirmView/SetupPasswordConfirmView.js';
|
|
6
8
|
import { SetupPasswordEnterView } from '../SetupPasswordEnterView/SetupPasswordEnterView.js';
|
|
7
|
-
import '../../../../../../_virtual/_tslib.js';
|
|
8
9
|
import '@dynamic-labs/utils';
|
|
9
10
|
import '@dynamic-labs/iconic';
|
|
10
11
|
import '../../../../context/ViewContext/ViewContext.js';
|
|
@@ -12,10 +13,13 @@ import { SetupPasswordKnowledgeCheckView } from '../SetupPasswordKnowledgeCheckV
|
|
|
12
13
|
import { SetupPasswordSuccessView } from '../SetupPasswordSuccessView/SetupPasswordSuccessView.js';
|
|
13
14
|
import { SetupPasswordTermsView } from '../SetupPasswordTermsView/SetupPasswordTermsView.js';
|
|
14
15
|
|
|
15
|
-
const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }) => {
|
|
16
|
+
const SetupPasswordView = ({ onComplete, onCancel, onDone, skipKnowledgeCheck = false, }) => {
|
|
17
|
+
const { t } = useTranslation();
|
|
16
18
|
const { setDynamicWidgetView, setIsOpen } = useWidgetContext();
|
|
17
19
|
const [currentStep, setCurrentStep] = useState('terms');
|
|
18
20
|
const [password, setPassword] = useState('');
|
|
21
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
22
|
+
const [submitError, setSubmitError] = useState(null);
|
|
19
23
|
const goToAccountAndSecurity = useCallback(() => {
|
|
20
24
|
setDynamicWidgetView('account-and-security-settings');
|
|
21
25
|
}, [setDynamicWidgetView]);
|
|
@@ -37,20 +41,34 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
37
41
|
const handleEnterBack = useCallback(() => {
|
|
38
42
|
setCurrentStep('terms');
|
|
39
43
|
}, []);
|
|
40
|
-
const
|
|
41
|
-
|
|
44
|
+
const runOnComplete = useCallback((pwd) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
setIsSubmitting(true);
|
|
46
|
+
setSubmitError(null);
|
|
47
|
+
try {
|
|
48
|
+
yield onComplete(pwd);
|
|
42
49
|
setCurrentStep('success');
|
|
43
50
|
}
|
|
51
|
+
catch (_a) {
|
|
52
|
+
setSubmitError(t('dyn_setup_password.confirm.error.failed'));
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
setIsSubmitting(false);
|
|
56
|
+
}
|
|
57
|
+
}), [onComplete, t]);
|
|
58
|
+
const handleConfirmContinue = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
if (skipKnowledgeCheck) {
|
|
60
|
+
yield runOnComplete(password);
|
|
61
|
+
}
|
|
44
62
|
else {
|
|
45
63
|
setCurrentStep('knowledge-check');
|
|
46
64
|
}
|
|
47
|
-
}, [skipKnowledgeCheck]);
|
|
65
|
+
}), [skipKnowledgeCheck, runOnComplete, password]);
|
|
48
66
|
const handleConfirmBack = useCallback(() => {
|
|
49
67
|
setCurrentStep('enter');
|
|
50
68
|
}, []);
|
|
51
|
-
const handleKnowledgeCheckContinue = useCallback(() => {
|
|
52
|
-
|
|
53
|
-
}, []);
|
|
69
|
+
const handleKnowledgeCheckContinue = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
70
|
+
yield runOnComplete(password);
|
|
71
|
+
}), [runOnComplete, password]);
|
|
54
72
|
const handleKnowledgeCheckBack = useCallback(() => {
|
|
55
73
|
setCurrentStep('confirm');
|
|
56
74
|
}, []);
|
|
@@ -58,10 +76,7 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
58
76
|
setDynamicWidgetView('wallets');
|
|
59
77
|
}, [setDynamicWidgetView]);
|
|
60
78
|
const handleSuccess = useCallback(() => {
|
|
61
|
-
|
|
62
|
-
// Navigate to appropriate view based on where we came from:
|
|
63
|
-
// - If onCancel was provided (auto-create flow), go to wallets then close widget
|
|
64
|
-
// - If onCancel wasn't provided (settings flow), go to account settings
|
|
79
|
+
onDone === null || onDone === void 0 ? void 0 : onDone();
|
|
65
80
|
if (onCancel) {
|
|
66
81
|
goToWallets();
|
|
67
82
|
setIsOpen(false);
|
|
@@ -69,23 +84,16 @@ const SetupPasswordView = ({ onComplete, onCancel, skipKnowledgeCheck = false, }
|
|
|
69
84
|
else {
|
|
70
85
|
goToAccountAndSecurity();
|
|
71
86
|
}
|
|
72
|
-
}, [
|
|
73
|
-
onComplete,
|
|
74
|
-
password,
|
|
75
|
-
onCancel,
|
|
76
|
-
goToAccountAndSecurity,
|
|
77
|
-
goToWallets,
|
|
78
|
-
setIsOpen,
|
|
79
|
-
]);
|
|
87
|
+
}, [onDone, onCancel, goToAccountAndSecurity, goToWallets, setIsOpen]);
|
|
80
88
|
switch (currentStep) {
|
|
81
89
|
case 'terms':
|
|
82
90
|
return (jsx(SetupPasswordTermsView, { onContinue: handleTermsContinue, onBack: onCancel ? undefined : handleCancel }));
|
|
83
91
|
case 'enter':
|
|
84
92
|
return (jsx(SetupPasswordEnterView, { onContinue: handleEnterContinue, onBack: handleEnterBack }));
|
|
85
93
|
case 'confirm':
|
|
86
|
-
return (jsx(SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack }));
|
|
94
|
+
return (jsx(SetupPasswordConfirmView, { password: password, onContinue: handleConfirmContinue, onBack: handleConfirmBack, isLoading: isSubmitting && skipKnowledgeCheck, error: skipKnowledgeCheck ? submitError : null }));
|
|
87
95
|
case 'knowledge-check':
|
|
88
|
-
return (jsx(SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack }));
|
|
96
|
+
return (jsx(SetupPasswordKnowledgeCheckView, { onContinue: handleKnowledgeCheckContinue, onBack: handleKnowledgeCheckBack, isLoading: isSubmitting, error: submitError }));
|
|
89
97
|
case 'success':
|
|
90
98
|
return jsx(SetupPasswordSuccessView, { onDone: handleSuccess });
|
|
91
99
|
default:
|