|
1 | 1 | import { Trade, TradeType } from '@uniswap/sdk' |
2 | 2 | import React, { useContext } from 'react' |
3 | | -import { ChevronRight } from 'react-feather' |
4 | | -import { Flex } from 'rebass' |
5 | 3 | import { ThemeContext } from 'styled-components' |
6 | 4 | import { Field } from '../../state/swap/actions' |
| 5 | +import { useUserSlippageTolerance } from '../../state/user/hooks' |
7 | 6 | import { TYPE } from '../../theme' |
8 | 7 | import { computeSlippageAdjustedAmounts, computeTradePriceBreakdown } from '../../utils/prices' |
9 | 8 | import { AutoColumn } from '../Column' |
10 | | -import { SectionBreak } from './styleds' |
11 | 9 | import QuestionHelper from '../QuestionHelper' |
12 | 10 | import { RowBetween, RowFixed } from '../Row' |
13 | 11 | import FormattedPriceImpact from './FormattedPriceImpact' |
14 | | -import TokenLogo from '../TokenLogo' |
15 | | -import flatMap from 'lodash.flatmap' |
16 | | -import { useUserSlippageTolerance } from '../../state/user/hooks' |
| 12 | +import { SectionBreak } from './styleds' |
| 13 | +import SwapRoute from './SwapRoute' |
17 | 14 |
|
18 | 15 | function TradeSummary({ trade, allowedSlippage }: { trade: Trade; allowedSlippage: number }) { |
19 | 16 | const theme = useContext(ThemeContext) |
@@ -79,49 +76,19 @@ export function AdvancedSwapDetails({ trade }: AdvancedSwapDetailsProps) { |
79 | 76 | return ( |
80 | 77 | <AutoColumn gap="md"> |
81 | 78 | {trade && <TradeSummary trade={trade} allowedSlippage={allowedSlippage} />} |
82 | | - {showRoute && <SectionBreak />} |
83 | 79 | {showRoute && ( |
84 | | - <AutoColumn style={{ padding: '0 24px' }}> |
85 | | - <RowFixed> |
86 | | - <TYPE.black fontSize={14} fontWeight={400} color={theme.text2}> |
87 | | - Route |
88 | | - </TYPE.black> |
89 | | - <QuestionHelper text="Routing through these tokens resulted in the best price for your trade." /> |
90 | | - </RowFixed> |
91 | | - <Flex |
92 | | - px="1rem" |
93 | | - py="0.5rem" |
94 | | - my="0.5rem" |
95 | | - style={{ border: `1px solid ${theme.bg3}`, borderRadius: '1rem' }} |
96 | | - flexWrap="wrap" |
97 | | - width="100%" |
98 | | - justifyContent="space-evenly" |
99 | | - alignItems="center" |
100 | | - > |
101 | | - {flatMap( |
102 | | - trade.route.path, |
103 | | - // add a null in-between each item |
104 | | - (token, i, array) => { |
105 | | - const lastItem = i === array.length - 1 |
106 | | - return lastItem ? [token] : [token, null] |
107 | | - } |
108 | | - ).map((token, i) => { |
109 | | - // use null as an indicator to insert chevrons |
110 | | - if (token === null) { |
111 | | - return <ChevronRight key={i} color={theme.text2} /> |
112 | | - } else { |
113 | | - return ( |
114 | | - <Flex my="0.5rem" alignItems="center" key={token.address} style={{ flexShrink: 0 }}> |
115 | | - <TokenLogo address={token.address} size="1.5rem" /> |
116 | | - <TYPE.black fontSize={14} color={theme.text1} ml="0.5rem"> |
117 | | - {token.symbol} |
118 | | - </TYPE.black> |
119 | | - </Flex> |
120 | | - ) |
121 | | - } |
122 | | - })} |
123 | | - </Flex> |
124 | | - </AutoColumn> |
| 80 | + <> |
| 81 | + <SectionBreak /> |
| 82 | + <AutoColumn style={{ padding: '0 24px' }}> |
| 83 | + <RowFixed> |
| 84 | + <TYPE.black fontSize={14} fontWeight={400} color={theme.text2}> |
| 85 | + Route |
| 86 | + </TYPE.black> |
| 87 | + <QuestionHelper text="Routing through these tokens resulted in the best price for your trade." /> |
| 88 | + </RowFixed> |
| 89 | + <SwapRoute trade={trade} /> |
| 90 | + </AutoColumn> |
| 91 | + </> |
125 | 92 | )} |
126 | 93 | </AutoColumn> |
127 | 94 | ) |
|
0 commit comments