forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Cancel Close Contracts and TP,SL actions #53
Merged
akmal-deriv
merged 11 commits into
akmal-deriv:contract-details-v2
from
ahmadtaimoor-deriv:f_contract_details
Jun 5, 2024
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
33087b5
chore: changing name from shared contract type
ahmadtaimoor-deriv cce989b
chore: updated quill
ahmadtaimoor-deriv 53c3aa0
chore: merge base
ahmadtaimoor-deriv beb9078
chore: test
ahmadtaimoor-deriv 43b0d5a
chore: button
ahmadtaimoor-deriv 0744a84
chore: remove comments
ahmadtaimoor-deriv 0f1e4ec
chore: test
ahmadtaimoor-deriv b1a7efb
chore: add notification
ahmadtaimoor-deriv b7afcb1
chore: add notification
ahmadtaimoor-deriv 2aacdf0
chore: TP and SL toggle
ahmadtaimoor-deriv 0b3eb80
chore: localize order detail
ahmadtaimoor-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
74 changes: 71 additions & 3 deletions
74
packages/trader/src/AppV2/Components/ContractDetailsFooter/contract-details-footer.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 |
---|---|---|
@@ -1,12 +1,80 @@ | ||
import { Button } from '@deriv-com/quill-ui'; | ||
import { TContractInfo, getCardLabels, isMultiplierContract, isValidToCancel, isValidToSell } from '@deriv/shared'; | ||
import { useStore } from '@deriv/stores'; | ||
import { getRemainingTime } from 'AppV2/Utils/helper'; | ||
import { observer } from 'mobx-react'; | ||
import React from 'react'; | ||
|
||
const ContractDetailsFooter = () => { | ||
type ContractInfoProps = { | ||
contract_info: TContractInfo; | ||
}; | ||
|
||
const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) => { | ||
const { | ||
bid_price, | ||
currency, | ||
contract_id, | ||
cancellation: { date_expiry: cancellation_date_expiry } = {}, | ||
profit, | ||
contract_type, | ||
} = contract_info; | ||
|
||
const { contract_replay, common } = useStore(); | ||
const { server_time } = common; | ||
const { onClickCancel, onClickSell, is_sell_requested } = contract_replay; | ||
const is_valid_to_sell = isValidToSell(contract_info); | ||
const is_valid_to_cancel = isValidToCancel(contract_info); | ||
const is_multiplier = isMultiplierContract(contract_type); | ||
|
||
return ( | ||
<div className='contract-details-footer--container'> | ||
<Button variant='secondary' label='Close @ 9.00 USD' color='black' size='lg' fullWidth /> | ||
{is_multiplier ? ( | ||
<> | ||
<Button | ||
variant='secondary' | ||
label={`${getCardLabels().CLOSE} ${!is_valid_to_cancel ? `@${bid_price} ${currency}` : ''}`} | ||
color='black' | ||
size='lg' | ||
isLoading={is_sell_requested} | ||
disabled={is_sell_requested || (Number(profit) < 0 && is_valid_to_cancel)} | ||
onClick={() => onClickSell(contract_id)} | ||
fullWidth | ||
/> | ||
{is_valid_to_cancel && ( | ||
<Button | ||
onClick={() => onClickCancel(contract_id)} | ||
variant='secondary' | ||
label={`${getCardLabels().CANCEL} ${getRemainingTime({ | ||
end_time: cancellation_date_expiry, | ||
format: 'mm:ss', | ||
getCardLabels, | ||
start_time: server_time, | ||
})}`} | ||
color='black' | ||
disabled={Number(profit) >= 0} | ||
size='lg' | ||
fullWidth | ||
/> | ||
)} | ||
</> | ||
) : ( | ||
<Button | ||
variant='secondary' | ||
label={ | ||
is_valid_to_sell | ||
? `${getCardLabels().CLOSE} @ ${bid_price} ${currency}` | ||
: getCardLabels().RESALE_NOT_OFFERED | ||
} | ||
color='black' | ||
size='lg' | ||
isLoading={is_sell_requested && is_valid_to_sell} | ||
onClick={is_valid_to_sell ? () => onClickSell(contract_id) : undefined} | ||
fullWidth | ||
disabled={!is_valid_to_sell} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; | ||
}); | ||
|
||
export default ContractDetailsFooter; |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way will not work. You need to localize the labels directly and pass localized text here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akmal-deriv Its changed now . localize added to the useOrderDetail Hook