|
1 | 1 | import { ReactNode } from 'react';
|
2 | 2 |
|
3 | 3 | import styled from 'styled-components';
|
4 |
| -import { AnimatePresence, motion } from 'framer-motion'; |
5 | 4 |
|
6 |
| -import { Icon, variables, Radio, motionAnimation } from '@trezor/components'; |
| 5 | +import { |
| 6 | + Icon, |
| 7 | + variables, |
| 8 | + Radio, |
| 9 | + Banner, |
| 10 | + Column, |
| 11 | + Card, |
| 12 | + Row, |
| 13 | + Divider, |
| 14 | + Text, |
| 15 | +} from '@trezor/components'; |
7 | 16 | import { formatNetworkAmount } from '@suite-common/wallet-utils';
|
8 | 17 | import { spacings } from '@trezor/theme';
|
9 | 18 |
|
10 | 19 | import { FormattedCryptoAmount, HiddenPlaceholder } from 'src/components/suite';
|
11 | 20 | import { Translation, TranslationKey } from 'src/components/suite/Translation';
|
12 | 21 | import { useRbfContext } from 'src/hooks/wallet/useRbfForm';
|
13 | 22 |
|
14 |
| -import { GreyCard } from './GreyCard'; |
15 |
| -import { WarnHeader } from './WarnHeader'; |
16 |
| - |
17 |
| -const OutputsWrapper = styled.div` |
18 |
| - display: flex; |
19 |
| - flex-direction: column; |
20 |
| - padding-top: 12px; |
21 |
| - margin-top: 24px; |
22 |
| - border-top: 1px solid ${({ theme }) => theme.legacy.STROKE_GREY}; |
23 |
| -`; |
24 |
| - |
25 |
| -const Output = styled.div` |
26 |
| - display: flex; |
27 |
| - align-items: center; |
28 |
| - padding: 8px 0; |
29 |
| -`; |
30 |
| - |
31 |
| -const OutputInner = styled.div` |
32 |
| - display: flex; |
33 |
| - flex-direction: column; |
34 |
| -`; |
35 |
| - |
36 | 23 | const OutputLabel = styled.div<{ $isChecked: boolean }>`
|
37 | 24 | display: flex;
|
38 | 25 | align-items: center;
|
@@ -109,63 +96,64 @@ export const DecreasedOutputs = () => {
|
109 | 96 | }
|
110 | 97 |
|
111 | 98 | return (
|
112 |
| - <AnimatePresence initial> |
113 |
| - <motion.div {...motionAnimation.expand}> |
114 |
| - <GreyCard> |
115 |
| - <WarnHeader data-testid="@send/decreased-outputs"> |
116 |
| - <Translation id={decreaseWarning} /> |
117 |
| - </WarnHeader> |
118 |
| - <OutputsWrapper> |
119 |
| - {formValues.outputs.flatMap((o, i) => { |
120 |
| - if (typeof o.address !== 'string') return null; |
121 |
| - const isChecked = setMaxOutputId === i; |
122 |
| - |
123 |
| - return ( |
124 |
| - // it's safe to use array index as key since outputs do not change |
125 |
| - |
126 |
| - <Output key={i}> |
127 |
| - {useRadio && ( |
128 |
| - <Radio |
129 |
| - onClick={() => { |
130 |
| - setValue('setMaxOutputId', i); |
131 |
| - composeRequest(); |
| 99 | + <Card fillType="flat" paddingType="none"> |
| 100 | + <Text typographyStyle="body" margin={spacings.md}> |
| 101 | + <Translation id="TR_AMOUNT_REDUCED_TXS" /> |
| 102 | + </Text> |
| 103 | + <Divider margin={spacings.zero} /> |
| 104 | + <Column margin={spacings.md}> |
| 105 | + <Banner variant="warning" data-testid="@send/decreased-outputs" icon="warning"> |
| 106 | + <Translation id={decreaseWarning} /> |
| 107 | + </Banner> |
| 108 | + <Column> |
| 109 | + {formValues.outputs.flatMap((o, i) => { |
| 110 | + if (typeof o.address !== 'string') return null; |
| 111 | + const isChecked = setMaxOutputId === i; |
| 112 | + |
| 113 | + return ( |
| 114 | + // it's safe to use array index as key since outputs do not change |
| 115 | + <Row key={i}> |
| 116 | + {useRadio && ( |
| 117 | + <Radio |
| 118 | + onClick={() => { |
| 119 | + setValue('setMaxOutputId', i); |
| 120 | + composeRequest(); |
| 121 | + }} |
| 122 | + isChecked={isChecked} |
| 123 | + margin={{ right: spacings.xs }} |
| 124 | + /> |
| 125 | + )} |
| 126 | + <Column> |
| 127 | + <OutputLabel $isChecked={isChecked}> |
| 128 | + <Translation |
| 129 | + id="TR_REDUCE_FROM" |
| 130 | + values={{ |
| 131 | + value: ( |
| 132 | + <FormattedCryptoAmount |
| 133 | + value={ |
| 134 | + shouldSendInSats |
| 135 | + ? formatNetworkAmount( |
| 136 | + o.amount, |
| 137 | + account.symbol, |
| 138 | + ) |
| 139 | + : o.amount |
| 140 | + } |
| 141 | + symbol={account.symbol} |
| 142 | + /> |
| 143 | + ), |
132 | 144 | }}
|
133 |
| - isChecked={isChecked} |
134 |
| - margin={{ right: spacings.xs }} |
135 | 145 | />
|
136 |
| - )} |
137 |
| - <OutputInner> |
138 |
| - <OutputLabel $isChecked={isChecked}> |
139 |
| - <Translation |
140 |
| - id="TR_REDUCE_FROM" |
141 |
| - values={{ |
142 |
| - value: ( |
143 |
| - <FormattedCryptoAmount |
144 |
| - value={ |
145 |
| - shouldSendInSats |
146 |
| - ? formatNetworkAmount( |
147 |
| - o.amount, |
148 |
| - account.symbol, |
149 |
| - ) |
150 |
| - : o.amount |
151 |
| - } |
152 |
| - symbol={account.symbol} |
153 |
| - /> |
154 |
| - ), |
155 |
| - }} |
156 |
| - /> |
157 |
| - {isChecked && reducedAmount} |
158 |
| - </OutputLabel> |
159 |
| - <OutputAddress $isChecked={isChecked}> |
160 |
| - <HiddenPlaceholder>{o.address}</HiddenPlaceholder> |
161 |
| - </OutputAddress> |
162 |
| - </OutputInner> |
163 |
| - </Output> |
164 |
| - ); |
165 |
| - })} |
166 |
| - </OutputsWrapper> |
167 |
| - </GreyCard> |
168 |
| - </motion.div> |
169 |
| - </AnimatePresence> |
| 146 | + {isChecked && reducedAmount} |
| 147 | + </OutputLabel> |
| 148 | + <OutputAddress $isChecked={isChecked}> |
| 149 | + <HiddenPlaceholder>{o.address}</HiddenPlaceholder> |
| 150 | + </OutputAddress> |
| 151 | + </Column> |
| 152 | + </Row> |
| 153 | + ); |
| 154 | + })} |
| 155 | + </Column> |
| 156 | + </Column> |
| 157 | + </Card> |
170 | 158 | );
|
171 | 159 | };
|
0 commit comments