From 825d61fa6014b996d6ed82628f1c7aae0dbf67d6 Mon Sep 17 00:00:00 2001 From: GHesericsu <60202455+GHesericsu@users.noreply.github.com> Date: Fri, 13 Oct 2023 14:28:14 +0100 Subject: [PATCH] feat: add close modal to remove signer --- src/components/Settings.tsx | 21 ++++++++++++++------- src/components/Transactions.tsx | 14 +++++++------- src/hooks/useMC.ts | 13 +++++++++---- src/pages/account/[accountId]/index.tsx | 2 +- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 7a144bc..e16655a 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -118,17 +118,20 @@ const Settings = (props: { accountId: string }) => { if (!txn) { return; } + const jwt = await getJwtToken(props.accountId); if (!jwt) { return; } - await createMCTransactionDB(txn.toXDR(), jwt); - addTxnNotification({ - title: 'Success', - message: 'Add a signer transaction has been submitted', - type: TxnResponse.Success, - timestamp: Date.now(), - }); + const mcTxnRes = await createMCTransactionDB(txn.toXDR(), jwt); + if (mcTxnRes?.preimageHash) { + addTxnNotification({ + title: 'Success', + message: 'Add a signer transaction has been submitted', + type: TxnResponse.Success, + timestamp: Date.now(), + }); + } } catch (err) { handleErrors('Error in adding signer', err); useLoadingModal.setAction({ @@ -167,6 +170,10 @@ const Settings = (props: { accountId: string }) => { useLoadingModal.setAction({ type: 'CLOSE', }); + } finally { + useLoadingModal.setAction({ + type: 'CLOSE', + }); } }; diff --git a/src/components/Transactions.tsx b/src/components/Transactions.tsx index dacd7ff..d435676 100644 --- a/src/components/Transactions.tsx +++ b/src/components/Transactions.tsx @@ -23,7 +23,7 @@ import dayjs from 'dayjs'; import { useEffect, useState } from 'react'; interface ITransactionsProps { - address?: string; + accountAddress?: string; } const StatusStepMap: Record = { @@ -33,7 +33,7 @@ const StatusStepMap: Record = { [MultiSigTransactionStatus.Executed]: 3, }; -const Transactions = ({ address }: ITransactionsProps) => { +const Transactions = ({ accountAddress }: ITransactionsProps) => { const [jwt] = useMCStore((s) => [s.jwt]); const { getJwtToken } = useMC(); const [activeAccordion, setActiveAccordion] = useState(null); @@ -62,27 +62,27 @@ const Transactions = ({ address }: ITransactionsProps) => { useEffect(() => { // fixme - change when we have a new jwt feature - if (address && jwt) { + if (accountAddress && jwt) { listTransactions.call( { offset: Math.max(pagination.offset - 1, 0), limit: 5, search: debouncedSearchTerm, - multicliqueAccountAddress: `${address}`, + multicliqueAccountAddress: `${accountAddress}`, }, jwt ); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [address, debouncedSearchTerm, JSON.stringify(pagination), jwt]); + }, [accountAddress, debouncedSearchTerm, JSON.stringify(pagination), jwt]); const handleSearch = (e: any) => { setSearchTerm(e.target.value); }; const handleLoadTransactions = async () => { - if (address) { - await getJwtToken(address); + if (accountAddress) { + await getJwtToken(accountAddress); } }; diff --git a/src/hooks/useMC.ts b/src/hooks/useMC.ts index 582e272..e02a76c 100644 --- a/src/hooks/useMC.ts +++ b/src/hooks/useMC.ts @@ -307,7 +307,6 @@ const useMC = () => { refresh: token.refresh, }); } - console.log(refreshedToken); updateJwt(refreshedToken); return refreshedToken; } catch (err) { @@ -602,7 +601,7 @@ const useMC = () => { return; } - if (!isValidXDR(xdr.trim().toString(), MCConfig.networkPassphrase)) { + if (!isValidXDR(xdr, MCConfig.networkPassphrase)) { handleErrors('Invalid XDR'); return null; } @@ -614,7 +613,7 @@ const useMC = () => { const mcTxnRes = await TransactionService.createMultiCliqueTransaction( { - xdr: xdr.trim().toString(), + xdr, }, jwtToken ); @@ -638,11 +637,17 @@ const useMC = () => { jwtToken ); - console.log('updatedTxn', updatedTxn); return updatedTxn; } catch (err) { handleErrors('Error in creating multiclique offchain transaction ', err); + loadingModal.setAction({ + type: 'CLOSE', + }); return null; + } finally { + loadingModal.setAction({ + type: 'CLOSE', + }); } }; diff --git a/src/pages/account/[accountId]/index.tsx b/src/pages/account/[accountId]/index.tsx index 872d271..47356fb 100644 --- a/src/pages/account/[accountId]/index.tsx +++ b/src/pages/account/[accountId]/index.tsx @@ -131,7 +131,7 @@ const Account = () => {
{currentTab === 'Dashboard' && } {currentTab === 'Transactions' && ( - + )} {currentTab === 'Settings' && (