style(wallet settings): move save button

This commit is contained in:
plebeius.eth
2024-03-25 16:12:03 +01:00
parent 1052c33fba
commit dcdb84d0ed
2 changed files with 23 additions and 29 deletions

View File

@@ -2,8 +2,8 @@
margin-bottom: 7px;
}
.saveWallets{
margin-top: 7px;
.save {
margin-left: 5px;
}
.walletTitle {
@@ -45,10 +45,6 @@
text-decoration: underline;
}
.pasteSignature button {
margin-left: 5px;
}
.show {
display: block;
}

View File

@@ -74,6 +74,24 @@ const CryptoWalletsForm = ({ account }: { account: Account | undefined }) => {
setShowWallet(newShowWallet);
};
const save = () => {
const wallets: { [key: string]: { address: string; timestamp: number; signature: { signature: string; type: string } } } = {};
walletsArray.forEach((wallet) => {
if (wallet.chainTicker && wallet.address && wallet.signature && wallet.timestamp) {
wallets[wallet.chainTicker] = {
address: wallet.address,
timestamp: wallet.timestamp,
signature: {
signature: wallet.signature,
type: 'eip191',
},
};
}
});
setAccount({ ...account, author: { ...account.author, wallets } });
alert(t('saved'));
};
const walletsInputs = walletsArray.map((wallet, index) => (
<>
<div className={styles.walletTitle}>
@@ -107,41 +125,21 @@ const CryptoWalletsForm = ({ account }: { account: Account | undefined }) => {
<div className={styles.walletField}>
<div className={styles.walletFieldTitle}>{t('paste_signature')}</div>
<input onChange={(e) => setWalletsArrayProperty(index, 'signature', e.target.value)} value={wallet.signature} placeholder='0x...' />
<button className={styles.save} onClick={save}>
{t('save')}
</button>
</div>
</div>
</div>
</>
));
const save = () => {
const wallets: { [key: string]: { address: string; timestamp: number; signature: { signature: string; type: string } } } = {};
walletsArray.forEach((wallet) => {
if (wallet.chainTicker && wallet.address && wallet.signature && wallet.timestamp) {
wallets[wallet.chainTicker] = {
address: wallet.address,
timestamp: wallet.timestamp,
signature: {
signature: wallet.signature,
type: 'eip191',
},
};
}
});
setAccount({ ...account, author: { ...account.author, wallets } });
alert(t('saved'));
};
return (
<>
<div className={styles.addWallet}>
<Trans i18nKey='add_wallet' components={{ 1: <button onClick={() => setWalletsArray([...walletsArray, defaultWalletObject])} /> }} />
</div>
{walletsInputs}
{walletsArray.length > 0 && (
<div className={styles.saveWallets}>
<Trans i18nKey='save_wallets' values={{ save: t('save') }} components={{ 1: <button onClick={save} /> }} />
</div>
)}
</>
);
};