Skip to content

Commit

Permalink
feat: use event from local scope
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Araujo committed Mar 8, 2024
1 parent 0c72d2d commit b1c8acd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,24 @@ export const RestoreRecoveryPhrase = (): JSX.Element => {
passphraseError: t('core.walletSetupMnemonicStep.passphraseError')
};

const onSubmitForm = useCallback(async () => {
event.preventDefault();

try {
const { source } = await createWallet(data);
await analytics.sendMergeEvent(source.account.extendedAccountPublicKey);
} catch (error) {
if (error instanceof WalletConflictError) {
toast.notify({ duration: TOAST_DEFAULT_DURATION, text: t('multiWallet.walletAlreadyExists') });
} else {
throw error;
const onSubmitForm = useCallback(
async (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => {
event.preventDefault();
try {
const { source } = await createWallet(data);
await analytics.sendMergeEvent(source.account.extendedAccountPublicKey);
} catch (error) {
if (error instanceof WalletConflictError) {
toast.notify({ duration: TOAST_DEFAULT_DURATION, text: t('multiWallet.walletAlreadyExists') });
} else {
throw error;
}
}
}
clearSecrets();
history.push(walletRoutePaths.assets);
}, [data, clearSecrets, createWallet, history, t, analytics]);
clearSecrets();
history.push(walletRoutePaths.assets);
},
[data, clearSecrets, createWallet, history, t, analytics]
);

return (
<WalletSetupMnemonicVerificationStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface WalletSetupMnemonicVerificationStepProps {
mnemonic: string[];
onChange: (words: string[]) => void;
onCancel: () => void;
onSubmit: () => void;
onSubmit: (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => void;
onStepNext?: (currentStep: number) => void;
isSubmitEnabled: boolean;
mnemonicWordsInStep?: number;
Expand Down Expand Up @@ -43,14 +43,14 @@ export const WalletSetupMnemonicVerificationStep = ({
onCancel();
};

const handleNext = () => {
const handleNext = (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => {
if (onStepNext) onStepNext(mnemonicStep);
if (mnemonicStep < mnemonicSteps - 1) {
setMnemonicStep(mnemonicStep + 1);
return;
}

onSubmit();
onSubmit(event);
};

const getStepInfoText = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface WalletSetupStepLayoutProps {
description?: React.ReactNode;
linkText?: React.ReactNode;
stepInfoText?: string;
onNext?: () => void;
onNext?: (event: Readonly<React.MouseEvent<HTMLButtonElement>>) => void;
onBack?: () => void;
onSkip?: () => void;
nextLabel?: string;
Expand Down

0 comments on commit b1c8acd

Please sign in to comment.