forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle all cases of risk management items display
- Loading branch information
1 parent
ca2941b
commit a4e709c
Showing
9 changed files
with
181 additions
and
111 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/trader/src/AppV2/Components/DealCancellation/deal-cancellation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Localize } from '@deriv/translations'; | ||
import React from 'react'; | ||
import { getContractDetailsConfig } from 'AppV2/Utils/contract-details-config'; | ||
import { observer } from '@deriv/stores'; | ||
import useContractDetails from 'AppV2/Hooks/useContractDetails'; | ||
import RiskManagementItem from '../RiskManagementItem'; | ||
import { isValidToCancel, isOpen } from '@deriv/shared'; | ||
import CardWrapper from '../CardWrapper'; | ||
|
||
const DealCancellation = observer(() => { | ||
const { contract_info } = useContractDetails(); | ||
const { is_deal_cancellation_visible } = getContractDetailsConfig(contract_info.contract_type ?? ''); | ||
|
||
const is_valid_to_cancel = isValidToCancel(contract_info); | ||
|
||
return is_valid_to_cancel && is_deal_cancellation_visible && isOpen(contract_info) ? ( | ||
<CardWrapper> | ||
<RiskManagementItem | ||
label={<Localize i18n_default_text='Deal cancellation' />} | ||
modal_body_content={ | ||
<Localize i18n_default_text='When this is active, you can cancel your trade within the chosen time frame. Your stake will be returned without loss.' /> | ||
} | ||
is_deal_cancellation | ||
/> | ||
</CardWrapper> | ||
) : null; | ||
}); | ||
|
||
export default DealCancellation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/trader/src/AppV2/Components/StopLoss/stop-loss.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Localize } from '@deriv/translations'; | ||
import React from 'react'; | ||
import { getContractDetailsConfig } from 'AppV2/Utils/contract-details-config'; | ||
import { observer } from '@deriv/stores'; | ||
import useContractDetails from 'AppV2/Hooks/useContractDetails'; | ||
import RiskManagementItem from '../RiskManagementItem'; | ||
|
||
const StopLoss = observer(() => { | ||
const { contract_info } = useContractDetails(); | ||
const { is_stop_loss_visible } = getContractDetailsConfig(contract_info.contract_type ?? ''); | ||
|
||
return is_stop_loss_visible ? ( | ||
<RiskManagementItem | ||
label={<Localize i18n_default_text='Stop Loss' />} | ||
modal_body_content={ | ||
<Localize i18n_default_text='When your loss reaches or exceeds the set amount, your trade will be closed automatically.' /> | ||
} | ||
validation_message='hello' | ||
/> | ||
) : null; | ||
}); | ||
|
||
export default StopLoss; |
25 changes: 25 additions & 0 deletions
25
packages/trader/src/AppV2/Components/TakeProfit/take-profit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Localize } from '@deriv/translations'; | ||
import React from 'react'; | ||
import { getContractDetailsConfig } from 'AppV2/Utils/contract-details-config'; | ||
import { observer } from '@deriv/stores'; | ||
import useContractDetails from 'AppV2/Hooks/useContractDetails'; | ||
import RiskManagementItem from '../RiskManagementItem'; | ||
|
||
const TakeProfit = observer(() => { | ||
const { contract_info } = useContractDetails(); | ||
const { is_take_profit_visible } = getContractDetailsConfig(contract_info.contract_type ?? ''); | ||
|
||
return ( | ||
is_take_profit_visible && ( | ||
<RiskManagementItem | ||
label={<Localize i18n_default_text='Take profit' />} | ||
modal_body_content={ | ||
<Localize i18n_default_text='When your profit reaches or exceeds the set amount, your trade will be closed automatically.' /> | ||
} | ||
validation_message='hello' | ||
/> | ||
) | ||
); | ||
}); | ||
|
||
export default TakeProfit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters