File tree Expand file tree Collapse file tree 6 files changed +69
-4
lines changed
suite-common/message-system/src Expand file tree Collapse file tree 6 files changed +69
-4
lines changed Original file line number Diff line number Diff line change
1
+ import { Feature , selectIsFeatureDisabled } from '@suite-common/message-system' ;
2
+
3
+ import { useSelector } from './useSelector' ;
4
+
5
+ export const useMessageSystemTrading = ( ) => {
6
+ const isBuyDisabled = useSelector ( state => selectIsFeatureDisabled ( state , Feature . trading . buy ) ) ;
7
+
8
+ const isSellDisabled = useSelector ( state =>
9
+ selectIsFeatureDisabled ( state , Feature . trading . sell ) ,
10
+ ) ;
11
+
12
+ const isExchangeDisabled = useSelector ( state =>
13
+ selectIsFeatureDisabled ( state , Feature . trading . swap ) ,
14
+ ) ;
15
+
16
+ return {
17
+ isBuyDisabled,
18
+ isSellDisabled,
19
+ isExchangeDisabled,
20
+ } ;
21
+ } ;
Original file line number Diff line number Diff line change
1
+ import { Context } from '@suite-common/message-system' ;
2
+
3
+ import { ContextMessage } from 'src/components/wallet/WalletLayout/AccountBanners/ContextMessage' ;
4
+ import { useMessageSystemTrading } from 'src/hooks/suite/useMessageSystemTrading' ;
1
5
import { useTradingBuyForm } from 'src/hooks/wallet/trading/form/useTradingBuyForm' ;
2
6
import { TradingFormContext } from 'src/hooks/wallet/trading/form/useTradingCommonForm' ;
3
7
import { UseTradingProps } from 'src/types/trading/trading' ;
4
8
import { TradingContainer } from 'src/views/wallet/trading/common/TradingContainer' ;
5
9
import { TradingFormLayout } from 'src/views/wallet/trading/common/TradingForm/TradingFormLayout' ;
6
10
import { TradingLayout } from 'src/views/wallet/trading/common/TradingLayout/TradingLayout' ;
7
11
12
+ import { TradingDisabled } from '../common/TradingDisabled' ;
13
+
8
14
const TradingBuyComponent = ( { selectedAccount } : UseTradingProps ) => {
15
+ const { isBuyDisabled } = useMessageSystemTrading ( ) ;
16
+
9
17
const tradingBuyContextValues = useTradingBuyForm ( { selectedAccount } ) ;
10
18
11
19
return (
12
20
< TradingLayout >
13
21
< TradingFormContext . Provider value = { tradingBuyContextValues } >
14
- < TradingFormLayout />
22
+ < ContextMessage context = { Context . tradingBuy } />
23
+ { isBuyDisabled ? < TradingDisabled type = "buy" /> : < TradingFormLayout /> }
15
24
</ TradingFormContext . Provider >
16
25
</ TradingLayout >
17
26
) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ import { Banner } from '@trezor/components' ;
4
+
5
+ type TradingDisabledProps = {
6
+ type : 'buy' | 'sell' | 'swap' ;
7
+ } ;
8
+
9
+ const capitalize = ( value : string ) => value . at ( 0 ) ?. toUpperCase ( ) + value . slice ( 1 ) ;
10
+
11
+ export const TradingDisabled = ( { type } : TradingDisabledProps ) => (
12
+ < Banner icon = "warning" variant = "warning" >
13
+ { capitalize ( type ) } is currently disabled.
14
+ </ Banner >
15
+ ) ;
Original file line number Diff line number Diff line change
1
+ import { Context } from '@suite-common/message-system' ;
2
+
3
+ import { ContextMessage } from 'src/components/wallet/WalletLayout/AccountBanners/ContextMessage' ;
4
+ import { useMessageSystemTrading } from 'src/hooks/suite/useMessageSystemTrading' ;
1
5
import { TradingFormContext } from 'src/hooks/wallet/trading/form/useTradingCommonForm' ;
2
6
import { useTradingExchangeForm } from 'src/hooks/wallet/trading/form/useTradingExchangeForm' ;
3
7
import { UseTradingProps } from 'src/types/trading/trading' ;
4
8
import { TradingContainer } from 'src/views/wallet/trading/common/TradingContainer' ;
5
9
import { TradingFormLayout } from 'src/views/wallet/trading/common/TradingForm/TradingFormLayout' ;
6
10
import { TradingLayout } from 'src/views/wallet/trading/common/TradingLayout/TradingLayout' ;
7
11
12
+ import { TradingDisabled } from '../common/TradingDisabled' ;
13
+
8
14
const TradingExchangeFormComponent = ( { selectedAccount } : UseTradingProps ) => {
15
+ const { isExchangeDisabled } = useMessageSystemTrading ( ) ;
16
+
9
17
const tradingExchangeContextValue = useTradingExchangeForm ( { selectedAccount } ) ;
10
18
11
19
return (
12
20
< TradingLayout >
13
21
< TradingFormContext . Provider value = { tradingExchangeContextValue } >
14
- < TradingFormLayout />
22
+ < ContextMessage context = { Context . tradingSwap } />
23
+ { isExchangeDisabled ? < TradingDisabled type = "swap" /> : < TradingFormLayout /> }
15
24
</ TradingFormContext . Provider >
16
25
</ TradingLayout >
17
26
) ;
Original file line number Diff line number Diff line change
1
+ import { Context } from '@suite-common/message-system' ;
2
+
3
+ import { ContextMessage } from 'src/components/wallet/WalletLayout/AccountBanners/ContextMessage' ;
4
+ import { useMessageSystemTrading } from 'src/hooks/suite/useMessageSystemTrading' ;
1
5
import { TradingFormContext } from 'src/hooks/wallet/trading/form/useTradingCommonForm' ;
2
6
import { useTradingSellForm } from 'src/hooks/wallet/trading/form/useTradingSellForm' ;
3
7
import { UseTradingProps } from 'src/types/trading/trading' ;
4
8
import { TradingContainer } from 'src/views/wallet/trading/common/TradingContainer' ;
5
9
import { TradingFormLayout } from 'src/views/wallet/trading/common/TradingForm/TradingFormLayout' ;
6
10
import { TradingLayout } from 'src/views/wallet/trading/common/TradingLayout/TradingLayout' ;
7
11
12
+ import { TradingDisabled } from '../common/TradingDisabled' ;
13
+
8
14
const TradingSellFormComponent = ( { selectedAccount } : UseTradingProps ) => {
15
+ const { isSellDisabled } = useMessageSystemTrading ( ) ;
16
+
9
17
const tradingSellContextValues = useTradingSellForm ( { selectedAccount } ) ;
10
18
19
+ if ( isSellDisabled ) {
20
+ return < TradingDisabled type = "sell" /> ;
21
+ }
22
+
11
23
return (
12
24
< TradingLayout >
13
25
< TradingFormContext . Provider value = { tradingSellContextValues } >
26
+ < ContextMessage context = { Context . tradingSell } />
14
27
< TradingFormLayout />
15
28
</ TradingFormContext . Provider >
16
29
</ TradingLayout >
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ export const Feature = {
42
42
entropyCheckMobile : 'security.entropyCheck.mobile' ,
43
43
// FW update feature flag implemented only for mobile app
44
44
firmwareUpdate : 'device.firmware.update' ,
45
- // trading feature flags implemented for mobile app
46
45
trading : {
47
46
buy : 'trading.buy' ,
48
47
sell : 'trading.sell' ,
@@ -67,7 +66,6 @@ export const Context = {
67
66
coinjoin : 'accounts.coinjoin' ,
68
67
ethStaking : 'accounts.eth.staking' ,
69
68
solStaking : 'accounts.sol.staking' ,
70
- // trading contexts are implemented for mobile app
71
69
tradingBuy : 'trading.buy' ,
72
70
tradingSell : 'trading.sell' ,
73
71
tradingSwap : 'trading.swap' ,
You can’t perform that action at this time.
0 commit comments