diff --git a/src/components/MultiHopTrade/MultiHopTrade.tsx b/src/components/MultiHopTrade/MultiHopTrade.tsx index 358d62c6769..b979f92766e 100644 --- a/src/components/MultiHopTrade/MultiHopTrade.tsx +++ b/src/components/MultiHopTrade/MultiHopTrade.tsx @@ -85,15 +85,17 @@ export const MultiHopTrade = memo( }, [defaultBuyAsset, defaultSellAsset, dispatch, routeBuyAsset]) return ( - - - - - - - - - + <> + + + + + + + + + + ) }, ) diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx index 958c1c7b842..46b3f75d00e 100644 --- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx +++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/MultiHopTradeConfirm.tsx @@ -1,12 +1,4 @@ -import { - Card, - CardBody, - CardHeader, - Heading, - Stack, - useDisclosure, - usePrevious, -} from '@chakra-ui/react' +import { Card, CardBody, CardHeader, Heading, useDisclosure, usePrevious } from '@chakra-ui/react' import { memo, useCallback, useEffect } from 'react' import { useHistory } from 'react-router-dom' import { WithBackButton } from 'components/MultiHopTrade/components/WithBackButton' @@ -14,41 +6,24 @@ import { TradeRoutePaths } from 'components/MultiHopTrade/types' import { SlideTransition } from 'components/SlideTransition' import { Text } from 'components/Text' import { swappers as swappersSlice } from 'state/slices/swappersSlice/swappersSlice' -import { - selectActiveSwapperName, - selectFirstHop, - selectIsActiveQuoteMultiHop, - selectLastHop, - selectTradeExecutionState, -} from 'state/slices/tradeQuoteSlice/selectors' +import { selectTradeExecutionState } from 'state/slices/tradeQuoteSlice/selectors' import { tradeQuoteSlice } from 'state/slices/tradeQuoteSlice/tradeQuoteSlice' import { MultiHopExecutionState } from 'state/slices/tradeQuoteSlice/types' import { useAppDispatch, useAppSelector } from 'state/store' +import { TradeSuccess } from '../TradeSuccess/TradeSuccess' import { Footer } from './components/Footer' -import { Hop } from './components/Hop' +import { Hops } from './components/Hops' import { useIsApprovalInitiallyNeeded } from './hooks/useIsApprovalInitiallyNeeded' const cardBorderRadius = { base: 'xl' } export const MultiHopTradeConfirm = memo(() => { const dispatch = useAppDispatch() - const swapperName = useAppSelector(selectActiveSwapperName) - const firstHop = useAppSelector(selectFirstHop) - const lastHop = useAppSelector(selectLastHop) - const isMultiHopTrade = useAppSelector(selectIsActiveQuoteMultiHop) const tradeExecutionState = useAppSelector(selectTradeExecutionState) const previousTradeExecutionState = usePrevious(tradeExecutionState) const history = useHistory() - const { isOpen: isFirstHopOpen, onToggle: onToggleFirstHop } = useDisclosure({ - defaultIsOpen: true, - }) - - const { isOpen: isSecondHopOpen, onToggle: onToggleSecondHop } = useDisclosure({ - defaultIsOpen: true, - }) - const { isApprovalInitiallyNeeded, isLoading } = useIsApprovalInitiallyNeeded() // set initial approval requirements @@ -63,6 +38,14 @@ export const MultiHopTradeConfirm = memo(() => { history.push(TradeRoutePaths.Input) }, [dispatch, history]) + const { isOpen: isFirstHopOpen, onToggle: onToggleFirstHop } = useDisclosure({ + defaultIsOpen: true, + }) + + const { isOpen: isSecondHopOpen, onToggle: onToggleSecondHop } = useDisclosure({ + defaultIsOpen: true, + }) + // toggle hop open states as we transition to the next hop useEffect(() => { if ( @@ -81,50 +64,40 @@ export const MultiHopTradeConfirm = memo(() => { tradeExecutionState, ]) - // TODO: redirect to completed page when trade is complete - // useEffect(() => { - // if ( - // previousTradeExecutionState !== tradeExecutionState && - // tradeExecutionState === MultiHopExecutionState.TradeComplete - // ) { - // history.push(TradeRoutePaths.Complete) - // } - // }, [history, previousTradeExecutionState, tradeExecutionState]) - - if (!firstHop || !swapperName) return null - return ( - + - - - - {isMultiHopTrade && lastHop && ( - + + + ) : ( + <> + + - )} - - + +