Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/pro-dashboard'
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovNikita committed Mar 12, 2024
2 parents 7819fd2 + 17296f2 commit 9aab859
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
9 changes: 8 additions & 1 deletion packages/core/src/service/walletService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,14 @@ export const updateWalletProperty = async (
wallet: WalletState,
props: Pick<
WalletState,
'name' | 'hiddenJettons' | 'shownJettons' | 'orderJettons' | 'lang' | 'fiat' | 'network'
| 'name'
| 'hiddenJettons'
| 'shownJettons'
| 'orderJettons'
| 'lang'
| 'fiat'
| 'network'
| 'emoji'
>
) => {
const updated: WalletState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const ConnectContent: FC<{
</Button>
<Button
size="large"
type="submit"
type="button"
primary
loading={isLoading}
disabled={isLoading}
Expand Down
36 changes: 19 additions & 17 deletions packages/uikit/src/components/create/WalletName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ const useUpdateNameMutation = (account: AccountState) => {
const sdk = useAppSdk();
const client = useQueryClient();

return useMutation<AccountState, Error, string>(async name => {
if (name.length < 3) {
throw new Error('Missing name');
return useMutation<AccountState, Error, { name: string; emoji: string }>(
async ({ name, emoji }) => {
if (name.length < 3) {
throw new Error('Missing name');
}

if (!account.activePublicKey) {
throw new Error('Missing activePublicKey');
}
const wallet = await getWalletState(sdk.storage, account.activePublicKey);
if (!wallet) {
throw new Error('Missing wallet');
}

await updateWalletProperty(sdk.storage, wallet, { name, emoji });
await client.invalidateQueries([QueryKey.account]);
return account;
}

if (!account.activePublicKey) {
throw new Error('Missing activePublicKey');
}
const wallet = await getWalletState(sdk.storage, account.activePublicKey);
if (!wallet) {
throw new Error('Missing wallet');
}

await updateWalletProperty(sdk.storage, wallet, { name });
await client.invalidateQueries([QueryKey.account]);
return account;
});
);
};

export const UpdateWalletName: FC<{
Expand All @@ -71,7 +73,7 @@ export const UpdateWalletName: FC<{

const onSubmit: React.FormEventHandler<HTMLFormElement> = async e => {
e.preventDefault();
onUpdate(await mutateAsync(name));
onUpdate(await mutateAsync({ name, emoji }));
};

const onChange = (value: string) => {
Expand Down
4 changes: 3 additions & 1 deletion packages/uikit/src/pages/import/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ const Create: FC<{ listOfAuth: AuthState['kind'][] }> = ({ listOfAuth }) => {
}

if (account && account.publicKeys.length > 1 && wallet && wallet.name == null) {
return <UpdateWalletName account={account} onUpdate={setAccount} walletEmoji={wallet.emoji} />;
return (
<UpdateWalletName account={account} onUpdate={setAccount} walletEmoji={wallet.emoji} />
);
}

if (sdk.notifications && !passNotifications) {
Expand Down

0 comments on commit 9aab859

Please sign in to comment.