From 16c7d0226da898ea2fc2cb26cbd9eef456f6ae49 Mon Sep 17 00:00:00 2001 From: hornilla-jowelyn <137761725+hornilla-jowelyn@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:04:49 +0800 Subject: [PATCH] added loaders to txn actions when processing and fixed nav menu responsiveness (#97) --- src/components/Transactions.tsx | 32 +++++++++++++++++++++++++ src/pages/account/[accountId]/index.tsx | 10 ++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/components/Transactions.tsx b/src/components/Transactions.tsx index eb7b844..da67a52 100644 --- a/src/components/Transactions.tsx +++ b/src/components/Transactions.tsx @@ -7,6 +7,7 @@ import { TransactionBadge, UserTally, } from '@/components'; +import { useLoadingScreenContext } from '@/context/LoadingScreen'; import { useDebounce } from '@/hooks/useDebounce'; import useMC from '@/hooks/useMC'; import useMCStore from '@/stores/MCStore'; @@ -45,6 +46,8 @@ const Transactions = ({ address }: ITransactionsProps) => { ]); const { approveTxnDB, getJwtToken, rejectTxnDB, executeMCTxn } = useMC(); + const loaders = useLoadingScreenContext(); + const [activeAccordion, setActiveAccordion] = useState(null); const [searchTerm, setSearchTerm] = useState(''); const debouncedSearchTerm = useDebounce(searchTerm, 1000); @@ -97,12 +100,21 @@ const Transactions = ({ address }: ITransactionsProps) => { } try { + loaders.setAction({ + type: 'SHOW_TRANSACTION_PROCESSING', + }); await approveTxnDB(txn, jwt); + loaders.setAction({ + type: 'CLOSE', + }); await new Promise((resolve) => { setTimeout(resolve, 2000); }); fetchTransactions(jwt); } catch { + loaders.setAction({ + type: 'CLOSE', + }); handleErrors('Error in approving transaction'); } }; @@ -113,12 +125,21 @@ const Transactions = ({ address }: ITransactionsProps) => { } try { + loaders.setAction({ + type: 'SHOW_TRANSACTION_PROCESSING', + }); await rejectTxnDB(txn, jwt); + loaders.setAction({ + type: 'CLOSE', + }); await new Promise((resolve) => { setTimeout(resolve, 2000); }); fetchTransactions(jwt); } catch { + loaders.setAction({ + type: 'CLOSE', + }); handleErrors('Error in approving transaction'); } }; @@ -129,12 +150,23 @@ const Transactions = ({ address }: ITransactionsProps) => { } try { + loaders.setAction({ + type: 'SHOW_TRANSACTION_PROCESSING', + }); + await executeMCTxn(txn, jwt); + loaders.setAction({ + type: 'CLOSE', + }); await new Promise((resolve) => { setTimeout(resolve, 2000); }); + fetchTransactions(jwt); } catch { + loaders.setAction({ + type: 'CLOSE', + }); handleErrors('Error in approving transaction'); } }; diff --git a/src/pages/account/[accountId]/index.tsx b/src/pages/account/[accountId]/index.tsx index fb7204e..f93f724 100644 --- a/src/pages/account/[accountId]/index.tsx +++ b/src/pages/account/[accountId]/index.tsx @@ -76,7 +76,7 @@ const Account = () => { }[] = useMemo( () => [ { - icon: , + icon: , label: 'Dashboard', }, // { @@ -84,16 +84,16 @@ const Account = () => { // label: 'Assets', // }, { - icon: , + icon: , label: 'Transactions', badgeCount: multicliqueAccount?.statistics?.transactions?.data, }, { - icon: , + icon: , label: 'Manage ELIO DAO Policy', }, { - icon: , + icon: , label: 'Settings', }, ], @@ -151,7 +151,7 @@ const Account = () => { active={currentTab === tab.label} onClick={() => setCurrentTab(tab.label)}> {tab.icon} - {tab.label} +
{tab.label}
{Boolean(tab.badgeCount) && ( {tab.badgeCount}