From 3cfa294cde2a9be9ad41109095a96fd3ef1d2d37 Mon Sep 17 00:00:00 2001 From: saml33 Date: Wed, 4 Jan 2023 13:38:17 +1100 Subject: [PATCH] hide settle funds button for unowned account --- components/trade/OpenOrders.tsx | 80 ++++++++++++++-------------- components/trade/UnsettledTrades.tsx | 56 ++++++++++--------- 2 files changed, 73 insertions(+), 63 deletions(-) diff --git a/components/trade/OpenOrders.tsx b/components/trade/OpenOrders.tsx index 3af6ed47..6573c50a 100644 --- a/components/trade/OpenOrders.tsx +++ b/components/trade/OpenOrders.tsx @@ -473,46 +473,48 @@ const OpenOrders = () => { )} -
-
- {modifyOrderId !== o.orderId.toString() ? ( - <> - showEditOrderForm(o, tickSize)} - > - - - - o instanceof PerpOrder - ? handleCancelPerpOrder(o) - : handleCancelSerumOrder(o) - } - > - {cancelId === o.orderId.toString() ? ( - - ) : ( - - )} - - - ) : ( - <> - modifyOrder(o)}> - {loadingModifyOrder ? ( - - ) : ( - - )} - - - - - - )} + {connected ? ( +
+
+ {modifyOrderId !== o.orderId.toString() ? ( + <> + showEditOrderForm(o, tickSize)} + > + + + + o instanceof PerpOrder + ? handleCancelPerpOrder(o) + : handleCancelSerumOrder(o) + } + > + {cancelId === o.orderId.toString() ? ( + + ) : ( + + )} + + + ) : ( + <> + modifyOrder(o)}> + {loadingModifyOrder ? ( + + ) : ( + + )} + + + + + + )} +
-
+ ) : null}
) }) diff --git a/components/trade/UnsettledTrades.tsx b/components/trade/UnsettledTrades.tsx index c4f82b05..306fc5d7 100644 --- a/components/trade/UnsettledTrades.tsx +++ b/components/trade/UnsettledTrades.tsx @@ -14,6 +14,7 @@ import useMangoGroup from 'hooks/useMangoGroup' import { PerpMarket, PerpPosition } from '@blockworks-foundation/mango-v4' import TableMarketName from './TableMarketName' import useMangoAccount from 'hooks/useMangoAccount' +import { useWallet } from '@solana/wallet-adapter-react' const UnsettledTrades = ({ unsettledSpotBalances, @@ -28,6 +29,7 @@ const UnsettledTrades = ({ const { width } = useViewport() const showTableView = width ? width > breakpoints.md : false const { mangoAccount } = useMangoAccount() + const { connected } = useWallet() const handleSettleSerumFunds = useCallback(async (mktAddress: string) => { const client = mangoStore.getState().client @@ -144,7 +146,7 @@ const UnsettledTrades = ({ {t('market')} {t('trade:amount')} - + {connected ? : null} @@ -180,22 +182,24 @@ const UnsettledTrades = ({ ) : null} - -
- - handleSettleSerumFunds(mktAddress)} - size="small" - > - {settleMktAddress === mktAddress ? ( - - ) : ( - - )} - - -
- + {connected ? ( + +
+ + handleSettleSerumFunds(mktAddress)} + size="small" + > + {settleMktAddress === mktAddress ? ( + + ) : ( + + )} + + +
+ + ) : null} ) })} @@ -264,13 +268,17 @@ const UnsettledTrades = ({ ) : null} - handleSettleSerumFunds(mktAddress)}> - {settleMktAddress === mktAddress ? ( - - ) : ( - - )} - + {connected ? ( + handleSettleSerumFunds(mktAddress)} + > + {settleMktAddress === mktAddress ? ( + + ) : ( + + )} + + ) : null} )