diff --git a/packages/apps/dev-wallet/src/App/routes.tsx b/packages/apps/dev-wallet/src/App/routes.tsx index e2c01baa5f..91642a2f04 100644 --- a/packages/apps/dev-wallet/src/App/routes.tsx +++ b/packages/apps/dev-wallet/src/App/routes.tsx @@ -87,10 +87,6 @@ export const Routes: FC = () => { }> } /> } /> - } - /> } @@ -139,6 +135,10 @@ export const Routes: FC = () => { }> + } + /> } /> Not found!} /> diff --git a/packages/apps/dev-wallet/src/pages/unlock-profile/unlock-profile.tsx b/packages/apps/dev-wallet/src/pages/unlock-profile/unlock-profile.tsx index d7455cbfb5..e320798644 100644 --- a/packages/apps/dev-wallet/src/pages/unlock-profile/unlock-profile.tsx +++ b/packages/apps/dev-wallet/src/pages/unlock-profile/unlock-profile.tsx @@ -8,11 +8,11 @@ import { TextField, } from '@kadena/kode-ui'; import { useForm } from 'react-hook-form'; -import { Link, Navigate, useParams } from 'react-router-dom'; +import { Link, Navigate, useNavigate, useParams } from 'react-router-dom'; import { useWallet } from '../../modules/wallet/wallet.hook'; import { passwordContainer, profileContainer } from './styles.css.ts'; -export function UnlockProfile() { +export function UnlockProfile({ origin }: { origin: string }) { const { register, handleSubmit, @@ -20,7 +20,8 @@ export function UnlockProfile() { formState: { isValid, errors }, } = useForm<{ password: string }>(); const { profileId } = useParams(); - const { profileList, unlockProfile } = useWallet(); + const navigate = useNavigate(); + const { profileList, unlockProfile, isUnlocked } = useWallet(); const profile = profileList.find((p) => p.uuid === profileId); const incorrectPasswordMsg = 'Password is incorrect'; @@ -38,6 +39,11 @@ export function UnlockProfile() { if (!keySource) { throw new Error('No key source found'); } + if (isUnlocked) { + navigate('/'); + } else { + navigate(origin); + } } catch (e) { console.log(e); setError('password', { type: 'manual', message: incorrectPasswordMsg });