1
1
<template >
2
2
<div class =" dual-currency-input" >
3
-
4
- {{ exchangeRate }}
5
3
<section :class =" { orange: !!invalidReason }" >
6
4
<div class =" flex-row primary-amount" >
7
5
<AmountInput v-model =" _cryptoAmount" :decimals =" cryptoCurrencyDecimals" >
36
34
</AmountInput >
37
35
</span >
38
36
</section >
39
-
40
- <MessageTransition class =" message-section" >
41
- <template v-if =" invalidReason === ' insufficient-limit' " >
42
- <!-- TEMP: wording TBD -->
43
- <i18n path =" Max swappable amount is {amount}" >
44
- <Amount slot =" amount" :amount =" maxCrypto"
45
- :currency =" fiatCurrency" hideDecimals />
46
- </i18n ><br />
47
- <a @click =" $emit('set-max')" >{{ $t('Sell max') }}</a >
48
- </template >
49
- <template v-else-if =" invalidReason === ' insufficient-balance' " >
50
- {{ $t('Insufficient balance.') }} <a @click =" $emit('set-max')" >{{ $t('Sell max') }}</a >
51
- </template >
52
- </MessageTransition >
53
37
</div >
54
38
</template >
55
39
56
40
<script lang="ts">
57
41
import { computed , defineComponent , ref , watch } from ' @vue/composition-api' ;
58
42
import { CryptoCurrency , FiatCurrency } from ' @/lib/Constants' ;
59
- import { Amount } from ' @nimiq/vue-components' ;
60
43
import AmountInput from ' ./AmountInput.vue' ;
61
- import MessageTransition from ' ./MessageTransition.vue' ;
62
44
63
45
export default defineComponent ({
64
46
props: {
@@ -84,7 +66,7 @@ export default defineComponent({
84
66
},
85
67
cryptoCurrencyDecimals: {
86
68
type: Number ,
87
- default: 2 ,
69
+ default: 5 ,
88
70
},
89
71
maxCrypto: Number ,
90
72
maxFiat: Number ,
@@ -111,15 +93,17 @@ export default defineComponent({
111
93
watch (_fiatAmount , (newVal ) => {
112
94
if (syncing .value ) return ;
113
95
syncing .value = true ;
114
- const newCryptoValue = newVal * props .exchangeRate ;
96
+ const newCryptoValue = Number (((newVal / props .exchangeRate ) * 10 ** props .cryptoCurrencyDecimals )
97
+ .toFixed (props .cryptoCurrencyDecimals ));
115
98
context .emit (' update:cryptoAmount' , newCryptoValue );
116
99
setTimeout (() => syncing .value = false , 100 );
117
100
}, { lazy: true });
118
101
119
102
watch (_cryptoAmount , (newVal ) => {
120
103
if (syncing .value ) return ;
121
104
syncing .value = true ;
122
- const newFiatValue = newVal / props .exchangeRate ;
105
+ const newFiatValue = Number (((newVal / 10 ** props .cryptoCurrencyDecimals ) * props .exchangeRate )
106
+ .toFixed (props .fiatCurrencyDecimals ));
123
107
context .emit (' update:fiatAmount' , newFiatValue );
124
108
setTimeout (() => syncing .value = false , 100 );
125
109
}, { lazy: true });
@@ -133,8 +117,6 @@ export default defineComponent({
133
117
},
134
118
components: {
135
119
AmountInput ,
136
- MessageTransition ,
137
- Amount ,
138
120
},
139
121
});
140
122
</script >
@@ -143,7 +125,6 @@ export default defineComponent({
143
125
.dual-currency-input {
144
126
text-align : center ;
145
127
margin-top : 3rem ;
146
- margin-bottom : 2rem ;
147
128
148
129
& .orange {
149
130
color : var (--nimiq-orange );
@@ -284,26 +265,5 @@ export default defineComponent({
284
265
}
285
266
}
286
267
}
287
- .message-section.message-transition {
288
- width : 100% ;
289
- font-weight : 600 ;
290
- font-size : 14px ;
291
- line-height : 21px ;
292
- text-align : center ;
293
- color : var (--nimiq-orange );
294
-
295
- transition-delay : 0ms ;
296
- --message-transition-duration : 200ms ;
297
-
298
- a {
299
- text-decoration : underline ;
300
- cursor : pointer ;
301
- }
302
-
303
- & ::v- deep .fadeY- enter,
304
- & ::v- deep .fadeY- leave- to {
305
- transform : translateY (-25% ) !important ;
306
- }
307
- }
308
268
}
309
269
</style >
0 commit comments