From c56fc05216a250d1515d50d1e1d10de670e7d26f Mon Sep 17 00:00:00 2001 From: saml33 Date: Sun, 19 Mar 2023 21:28:13 +1100 Subject: [PATCH] swap history mobile display --- components/TokenList.tsx | 6 +- components/shared/BalancesTable.tsx | 6 +- components/stats/TokenStats.tsx | 4 +- components/swap/SwapHistoryTable.tsx | 297 +++++++++++++-------------- 4 files changed, 148 insertions(+), 165 deletions(-) diff --git a/components/TokenList.tsx b/components/TokenList.tsx index 530c9aed..c180c402 100644 --- a/components/TokenList.tsx +++ b/components/TokenList.tsx @@ -269,7 +269,7 @@ const MobileTokenListItem = ({ bank }: { bank: BankWithBalance }) => { {({ open }) => ( <>
@@ -304,7 +304,7 @@ const MobileTokenListItem = ({ bank }: { bank: BankWithBalance }) => {
@@ -315,7 +315,7 @@ const MobileTokenListItem = ({ bank }: { bank: BankWithBalance }) => { enterTo="opacity-100" > -
+

{t('trade:in-orders')} diff --git a/components/shared/BalancesTable.tsx b/components/shared/BalancesTable.tsx index 9ed1f003..ea429edc 100644 --- a/components/shared/BalancesTable.tsx +++ b/components/shared/BalancesTable.tsx @@ -137,7 +137,7 @@ const BalancesTable = () => { {({ open }) => ( <> @@ -173,7 +173,7 @@ const BalancesTable = () => {

@@ -183,7 +183,7 @@ const BalancesTable = () => { enterTo="opacity-100" > -
+

{t('trade:in-orders')} diff --git a/components/stats/TokenStats.tsx b/components/stats/TokenStats.tsx index e85fd958..d7604ede 100644 --- a/components/stats/TokenStats.tsx +++ b/components/stats/TokenStats.tsx @@ -263,7 +263,7 @@ const TokenStats = () => { {({ open }) => ( <> @@ -296,7 +296,7 @@ const TokenStats = () => { enterTo="opacity-100" > -

+

{t('total-deposits')} diff --git a/components/swap/SwapHistoryTable.tsx b/components/swap/SwapHistoryTable.tsx index e600df46..91c1b65d 100644 --- a/components/swap/SwapHistoryTable.tsx +++ b/components/swap/SwapHistoryTable.tsx @@ -1,16 +1,12 @@ -import { Fragment, useCallback, useEffect, useState } from 'react' -import { - ArrowRightIcon, - ChevronDownIcon, - NoSymbolIcon, -} from '@heroicons/react/20/solid' +import { useCallback, useEffect, useState } from 'react' +import { ChevronDownIcon, NoSymbolIcon } from '@heroicons/react/20/solid' import dayjs from 'dayjs' import { useTranslation } from 'next-i18next' import Image from 'next/legacy/image' import { breakpoints } from '../../utils/theme' import { useViewport } from '../../hooks/useViewport' -import { IconButton, LinkButton } from '../shared/Button' -import { Transition } from '@headlessui/react' +import { LinkButton } from '../shared/Button' +import { Disclosure, Transition } from '@headlessui/react' import SheenLoader from '../shared/SheenLoader' import mangoStore from '@store/mangoStore' import { countLeadingZeros, floorToDecimal } from '../../utils/numbers' @@ -31,7 +27,6 @@ const SwapHistoryTable = () => { const swapHistory = mangoStore((s) => s.mangoAccount.swapHistory.data) const loadSwapHistory = mangoStore((s) => s.mangoAccount.swapHistory.loading) const { mangoTokens } = useJupiterMints() - const [showSwapDetails, setSwapDetails] = useState('') const [offset, setOffset] = useState(0) const actions = mangoStore.getState().actions const { mangoAccountAddress } = useMangoAccount() @@ -64,10 +59,6 @@ const SwapHistoryTable = () => { ) }, [actions, offset, mangoAccountAddress]) - const handleShowSwapDetails = (signature: string) => { - showSwapDetails ? setSwapDetails('') : setSwapDetails(signature) - } - return mangoAccountAddress && (swapHistory.length || loadSwapHistory) ? ( <> {showTableView ? ( @@ -256,7 +247,7 @@ const SwapHistoryTable = () => { ) : (

- {swapHistory.map((h) => { + {swapHistory.map((h, i) => { const { block_datetime, signature, @@ -282,158 +273,150 @@ const SwapHistoryTable = () => { ? loan_origination_fee.toFixed(4) : 0 - let baseLogoURI - let quoteLogoURI - const inSymbol = formatTokenSymbol(swap_in_symbol) const outSymbol = formatTokenSymbol(swap_out_symbol) - if (mangoTokens.length) { - baseLogoURI = mangoTokens.find( - (t) => t.symbol.toUpperCase() === inSymbol.toUpperCase() - )?.logoURI - quoteLogoURI = mangoTokens.find( - (t) => t.symbol.toUpperCase() === outSymbol.toUpperCase() - )?.logoURI - } - const inDecimals = countLeadingZeros(swap_in_amount) + 2 const outDecimals = countLeadingZeros(swap_out_amount) + 2 return ( -
-
-
-
-
- -
-
-

- {' '} - - {inSymbol} - -

-

- - {t('price')}: - {' '} - -

-
-
- -
-
- -
-
-

- {' '} - - {outSymbol} - -

-

- - {t('price')}: - {' '} - + {({ open }) => ( + <> + +

+
+

+ {dayjs(block_datetime).format('ddd D MMM')} +

+

+ {dayjs(block_datetime).format('h:mma')} +

+
+
+
+

+ {' '} + + {inSymbol} + {' '} + + to + {' '} + {' '} + + {outSymbol} + +

+
+ -

+
-
-
- handleShowSwapDetails(signature)} - size="medium" - > - - -
- -
-
-

{t('date')}

-

- {dayjs(block_datetime).format('ddd D MMM')} -

-

- {dayjs(block_datetime).format('h:mma')} -

-
-
-

{t('borrow')}

-

- {borrowAmount}{' '} - - {inSymbol} - -

-
-
-

{t('borrow-fee')}

-

${borrowFee}

-
- -
-
-
+ + + +
+
+

+ {t('value')} +

+

+ +

+
+
+

+ {`${swap_in_symbol} ${t('price')}`} +

+

+ +

+
+
+

+ {`${swap_out_symbol} ${t('price')}`} +

+

+ +

+
+ {borrowAmount ? ( + <> +
+

+ {t('borrow')} +

+

+ {borrowAmount}{' '} + + {inSymbol} + +

+
+
+

+ {t('borrow-fee')} +

+

+ ${borrowFee} +

+
+ + ) : null} + +
+
+
+ + )} + ) })}