Skip to content

Commit

Permalink
fix: rename wallet while creating or importing
Browse files Browse the repository at this point in the history
  • Loading branch information
siandreev committed Jul 16, 2024
1 parent 0412ea3 commit 186347c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 11 additions & 2 deletions packages/uikit/src/components/create/WalletName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const UpdateWalletName: FC<{
walletEmoji: string;
name?: string;
submitHandler: ({ name, emoji }: { name: string; emoji: string }) => void;
}> = ({ walletEmoji, submitHandler, name: nameProp }) => {
isLoading?: boolean;
}> = ({ walletEmoji, submitHandler, name: nameProp, isLoading }) => {
const { t } = useTranslation();

const ref = useRef<HTMLInputElement | null>(null);
Expand Down Expand Up @@ -67,7 +68,15 @@ export const UpdateWalletName: FC<{
/>
<EmojisList keepShortListForMS={500} onClick={setEmoji} />

<Button size="large" fullWidth marginTop primary disabled={!isValid} type="submit">
<Button
size="large"
fullWidth
marginTop
primary
disabled={!isValid}
type="submit"
loading={isLoading}
>
{t('add_edit_favorite_save')}
</Button>
</Block>
Expand Down
13 changes: 11 additions & 2 deletions packages/uikit/src/pages/import/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import { useTranslation } from '../../hooks/translation';
import { FinalView } from './Password';
import { Subscribe } from './Subscribe';
import { StandardTonWalletState } from '@tonkeeper/core/dist/entries/wallet';
import { useCreateStandardTonWalletsByMnemonic, useWalletsState } from '../../state/wallet';
import {
useCreateStandardTonWalletsByMnemonic,
useMutateRenameWallet,
useWalletsState
} from '../../state/wallet';

const Create = () => {
const sdk = useAppSdk();
Expand All @@ -27,6 +31,7 @@ const Create = () => {
isLoading: isCreateWalletLoading,
reset: resetCreateWallets
} = useCreateStandardTonWalletsByMnemonic();
const { mutateAsync: renameWallet, isLoading: renameLoading } = useMutateRenameWallet();

const existingWallets = useWalletsState();
const [mnemonic, setMnemonic] = useState<string[] | undefined>();
Expand Down Expand Up @@ -157,9 +162,13 @@ const Create = () => {
...w!,
...val
}));
setPassName(true);
renameWallet({
id: wallet.id,
...val
}).then(() => setPassName(true));
}}
walletEmoji={wallet.emoji}
isLoading={renameLoading}
/>
);
}
Expand Down
13 changes: 11 additions & 2 deletions packages/uikit/src/pages/import/Import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { ImportWords } from '../../components/create/Words';
import { useAppSdk } from '../../hooks/appSdk';
import { FinalView } from './Password';
import { Subscribe } from './Subscribe';
import { useCreateStandardTonWalletsByMnemonic, useWalletsState } from '../../state/wallet';
import {
useCreateStandardTonWalletsByMnemonic,
useMutateRenameWallet,
useWalletsState
} from '../../state/wallet';
import { StandardTonWalletState, WalletVersion } from '@tonkeeper/core/dist/entries/wallet';
import { ChoseWalletVersions } from '../../components/create/ChoseWalletVersions';

Expand All @@ -22,6 +26,7 @@ const Import = () => {
const [passName, setPassName] = useState(false);
const [passNotifications, setPassNotification] = useState(false);
const existingWallets = useWalletsState();
const { mutateAsync: renameWallet, isLoading: renameLoading } = useMutateRenameWallet();

const {
mutateAsync: createWalletsAsync,
Expand Down Expand Up @@ -89,9 +94,13 @@ const Import = () => {
name={wallets[0].name}
submitHandler={val => {
setWallets(w => [{ ...w![0], ...val }]);
setPassName(true);
renameWallet({
id: wallets![0].id,
...val
}).then(() => setPassName(true));
}}
walletEmoji={wallets[0].emoji}
isLoading={renameLoading}
/>
);
}
Expand Down

0 comments on commit 186347c

Please sign in to comment.