Skip to content
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

Maryia/Kate/DTRA-19/task-add-turbos #7514

Merged
Merged
Show file tree
Hide file tree
Changes from 158 commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
ef24949
feat: connect turbos contracts_for & take barrier_choices
maryia-deriv Feb 3, 2023
5e5dbfe
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 3, 2023
fe7a0e4
chore: add barrier count to turbos config
maryia-deriv Feb 3, 2023
bf3d299
chore: connected proposal API + added Stake header + updated purchase…
maryia-deriv Feb 5, 2023
332dbd2
Kate/87485/add Turbos to the Trade types list (#74)
kate-deriv Feb 6, 2023
28104c1
Kate/87510/add existing Take Profit component to Turbos Trade params …
kate-deriv Feb 6, 2023
55995ce
fix: maryia/hide info from purchase button correctly
maryia-deriv Feb 6, 2023
4d5402c
hamza/ feat: Barrier Line Colors depend upon the contract type (#80)
hamza-deriv Feb 8, 2023
247177a
hamza/dynamic Turbos purchase button with icons (#79)
hamza-deriv Feb 8, 2023
8e7b984
Kate/87536/add existing Duration & Amount(Stake) components to Turbos…
kate-deriv Feb 8, 2023
e8fa9b5
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Feb 14, 2023
935c243
hamza/88083/To Adjust the purchase button styles including animation …
hamza-deriv Feb 14, 2023
e51a57b
Kate/87506/To implement Turbos Contract card in Recent Positions draw…
kate-deriv Feb 14, 2023
aa0aeba
Hamza / 87508/feat:To add Turbos to Open Positions page [Desktop & Re…
hamza-deriv Feb 21, 2023
481fde6
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 23, 2023
b04fffe
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 23, 2023
b3e3327
Kate/87395/add turbos barriers component (#87)
kate-deriv Feb 23, 2023
5f5fb50
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 23, 2023
4a0adc4
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 24, 2023
640432e
Kate/87397/[Responsive]: To add Collapsed Turbos barriers in Trade pa…
kate-deriv Feb 27, 2023
0e69942
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 27, 2023
e8bdbd4
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Feb 27, 2023
64927e5
Hamza/ 88943 /feat: add Long & Short Tabs to trade params for desktop…
hamza-deriv Mar 1, 2023
fcd4d01
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Mar 2, 2023
3d17195
Kate/87400/add Expanded view for Turbos Barriers opening in a MobileD…
kate-deriv Mar 2, 2023
1e7e3a9
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Mar 3, 2023
7866859
Hamza/89706/test cases of new features (#96)
hamza-deriv Mar 9, 2023
bd39f9d
Hamza/87396/feat: responsive trade type tabs (#98)
hamza-deriv Mar 9, 2023
ab0b1b6
Merge branch 'master' of github.com:binary-com/deriv-app; branch 'mar…
maryia-deriv Mar 9, 2023
741e075
Kate/89669/tests for turbos (#97)
kate-deriv Mar 10, 2023
189a052
fix: change style for turbos contract card (#100)
kate-deriv Mar 10, 2023
fd2b3ff
refactor: maryia/refactored TurbosInfo, tests & OpenPositions
maryia-deriv Mar 10, 2023
c024b95
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Mar 10, 2023
f0aaafc
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 14, 2023
59d98fb
Kate/90808/90829/ To migrate turbos-card-body, turbos-trade-descripti…
kate-deriv Mar 16, 2023
3914479
Kate/90812/To migrate turbos-info and payout-per-point to TS together…
kate-deriv Mar 17, 2023
a2f5e63
refactor: update function for turbos cards filtration (#105)
kate-deriv Mar 17, 2023
1144f16
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Mar 20, 2023
0aad8c9
chore: vanilla+turbos adjustment
maryia-deriv Mar 20, 2023
4f72010
chore: integrate turbos into options in open positions
maryia-deriv Mar 20, 2023
e1e7a70
chore: maryia/design adjustments
maryia-deriv Mar 20, 2023
4db8c56
Kate/87523/Make barriers and payout per point collapsible in responsi…
kate-deriv Mar 21, 2023
1010ac0
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 22, 2023
9c73f66
Kate/91508/To finalize Payout per point component and its tooltip (#110)
kate-deriv Mar 22, 2023
6fe8c97
refactor: replace base tags with text tag and add duration text funct…
kate-deriv Mar 23, 2023
01e3b56
Kate/91602/Display Long and Short open contracts in DTrader chart sim…
kate-deriv Mar 23, 2023
8abeaa7
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 23, 2023
c71ccc9
refactor: maryia/rounding payout per point + refactoring
maryia-deriv Mar 23, 2023
5415ea0
Kate/91815/Final checks and adjustments (#113)
kate-deriv Mar 24, 2023
8897afd
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 24, 2023
58f6257
refactor: reused MinMaxStakeInfo & PayoutPerPointMobile for vanillas …
maryia-deriv Mar 27, 2023
4cc7a67
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Mar 27, 2023
c1a9679
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Mar 28, 2023
4645550
Kate/91999/Technical debt: To reuse Vanillas & Turbos common UI eleme…
kate-deriv Mar 28, 2023
8b457af
refactor: barriers-list and its body & trade-type-tabs
maryia-deriv Mar 29, 2023
62c8172
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 29, 2023
fc98fbf
refactor: address review comments
maryia-deriv Mar 29, 2023
ade4b42
refactor: address review comments
maryia-deriv Mar 29, 2023
03ae381
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Mar 29, 2023
97c3450
refactor: remove getTurbosDurationText
maryia-deriv Mar 29, 2023
67faa25
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 29, 2023
a882aeb
refactor: old getDurationUnitText to reduce cognitive complexity
maryia-deriv Mar 29, 2023
c1bcedb
fix: address review comments
maryia-deriv Mar 29, 2023
96ff6b9
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Mar 31, 2023
22a8b7e
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Mar 31, 2023
8a44b0d
fix: conditional rendering of total profit/loss
maryia-deriv Mar 31, 2023
25c1029
fix: replace time and add comment (#116)
kate-deriv Mar 31, 2023
06e4dad
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Apr 3, 2023
b7f1172
Kate/refactor after last review (#117)
kate-deriv Apr 3, 2023
d7788f3
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Apr 4, 2023
f5fa193
fix: filter turbos cards in responsive & reports popover text
maryia-deriv Apr 4, 2023
8991c53
refactor: address review comments
maryia-deriv Apr 4, 2023
4f576ab
refactor: TurbosTradeDescription content
maryia-deriv Apr 4, 2023
eaf66e2
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Apr 7, 2023
1b35a4b
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Apr 7, 2023
5fdccc3
chore: caching barrier choices and selected barrier for turbos
maryia-deriv Apr 7, 2023
24cba3f
fix: add response check (#118)
kate-deriv Apr 11, 2023
3585e69
Kate/92888/turbos content update (#119)
kate-deriv Apr 11, 2023
4dada65
Kate/93137/Profit value is not displayed right in the contract detail…
kate-deriv Apr 12, 2023
fa38af5
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Apr 12, 2023
6bcb6ff
fix: bug with barriers in contract details (#121)
kate-deriv Apr 13, 2023
30388b0
fix: maryia/93143/chart markers count in contract details + refactoring
maryia-deriv Apr 13, 2023
5e52d6b
revert: unnecessary change to chart markers count for turbos
maryia-deriv Apr 14, 2023
762a4d5
Kate/93403/Payout per point is not displayed in contract detail page …
kate-deriv Apr 14, 2023
bcd3036
refactor: minor refactoring
maryia-deriv Apr 14, 2023
1b4ca87
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Apr 14, 2023
f04b3b7
revert: no longer needed changes in useStore.tsx
maryia-deriv Apr 14, 2023
1c780cd
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Apr 17, 2023
2e15a2d
Kate/93332/CD: [Change Request] replace contract card fields by new o…
kate-deriv Apr 17, 2023
5d3a87a
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Apr 18, 2023
9c6522d
fix: change style for turbos mobile (#124)
kate-deriv Apr 19, 2023
c0dd6cb
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Apr 19, 2023
d197cb7
Kate/Barrier text in the section is not aligned properly (#125)
kate-deriv Apr 26, 2023
d54641a
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv May 19, 2023
d690e90
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv May 19, 2023
b4a910f
build: fix types
maryia-deriv May 19, 2023
eb0d476
fix: imports for new tsx files
maryia-deriv May 19, 2023
a82462b
refactor: replace old turbo icons (#126)
kate-deriv May 19, 2023
d74da0e
fix: types + localization + reverted Vanillas tooltip text changes
maryia-deriv May 19, 2023
f39db28
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv May 23, 2023
b00f3d1
fix: add icon for turbos long
kate-deriv May 23, 2023
6fa46b0
chore: update icon bundle
kate-deriv May 23, 2023
ae31dad
Merge pull request #127 from kate-deriv/kate/turbos_chore_icons
matin-deriv May 29, 2023
9a4adc4
refactor: use number of contracts instead of shortcode
kate-deriv Jun 9, 2023
e8b7873
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jun 9, 2023
f1c4e00
refactor: sonarcloud + tests
maryia-deriv Jun 9, 2023
796b09e
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jun 12, 2023
e7c4129
fix: conflicts + address review
maryia-deriv Jun 12, 2023
7e20483
refactor: as per reviews
maryia-deriv Jun 12, 2023
2d0ba8a
fix: apply gradient style to all contracts (#132)
kate-deriv Jun 15, 2023
39438ec
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jun 16, 2023
0445f49
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jun 19, 2023
1e7d231
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Jun 20, 2023
fa8fdce
chore: improve types as per reviews
maryia-deriv Jun 20, 2023
bae11f7
chore: address reviews
maryia-deriv Jun 21, 2023
41da8fb
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jun 21, 2023
acf1b21
refactor: sonarcloud warnings
maryia-deriv Jun 21, 2023
9ba9b25
build: trigger build
maryia-deriv Jun 21, 2023
d319a55
refactor: rename number of contracts (#134)
kate-deriv Jun 28, 2023
f3bde6f
Kate / Apply suggestions from last code review (#135)
kate-deriv Jun 29, 2023
6e1609f
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jul 4, 2023
1752909
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 4, 2023
21236f2
fix: address review comments
maryia-deriv Jul 5, 2023
387c1ec
test: fix tests
maryia-deriv Jul 5, 2023
0118657
fix: types
maryia-deriv Jul 5, 2023
3e3ccd5
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Jul 5, 2023
7530f74
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jul 5, 2023
37b4fba
fix: sonarcloud warnings
maryia-deriv Jul 5, 2023
e06f977
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 6, 2023
b5056f6
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Jul 7, 2023
64e432d
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 10, 2023
ecb339f
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jul 11, 2023
eb8b412
build: trigger checks
maryia-deriv Jul 11, 2023
0d584af
fix: remove barrier shade
maryia-deriv Jul 11, 2023
7296e51
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 11, 2023
560db11
fix: contract card values alignment
maryia-deriv Jul 11, 2023
63a2feb
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 13, 2023
3791bb1
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 13, 2023
523716a
fix: missing colon after Barrier
maryia-deriv Jul 13, 2023
aa5e11f
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 14, 2023
496a199
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 17, 2023
1d25508
chore: add vanilla header with timer to turbos contract card in mobil…
maryia-deriv Jul 18, 2023
6e1c536
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 18, 2023
29bade5
fix: sonarcloud warning
maryia-deriv Jul 18, 2023
723b8d4
chore: show full title only in open positions
maryia-deriv Jul 19, 2023
3e6103a
build: trigger build
maryia-deriv Jul 19, 2023
25d505b
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 20, 2023
cad3ca4
fix: types in open-positions
maryia-deriv Jul 20, 2023
57635f0
fix: address review comments about types
maryia-deriv Jul 21, 2023
beb1eef
Merge branch 'master' of github.com:binary-com/deriv-app into maryia/…
maryia-deriv Jul 21, 2023
7e6a39f
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Jul 21, 2023
c1a26e5
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 21, 2023
35fa976
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 24, 2023
3190fed
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 24, 2023
acfa962
Merge branch 'master' into maryia/87354/task-add-turbos
maryia-deriv Jul 25, 2023
0e7727b
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Aug 1, 2023
baaf7c3
refactor: type
maryia-deriv Aug 1, 2023
7e58616
build: empty commit
maryia-deriv Aug 1, 2023
4d5b6f3
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Aug 7, 2023
26ca75e
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Aug 7, 2023
356f891
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Aug 7, 2023
9185ac7
Merge branch master of github.com:binary-com/deriv-app into maryia/87…
maryia-deriv Aug 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
.trade-container {
&__fieldset {
flex: 1;
margin-left: 0.4rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was breaking purchase button for all contracts in responsive


.dc-button-menu__wrapper {
height: 4rem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { render, screen } from '@testing-library/react';
import { TContractInfo } from '@deriv/shared/src/utils/contract/contract-types';
import TurbosCardBody from '../turbos-card-body';

const contract_info: TContractInfo = {
contract_id: 1,
bid_price: 1044.02,
buy_price: 1044.0,
profit: 50,
barrier: '10904.80',
entry_spot_display_value: '1046.80',
sell_price: 1046.8,
};

const mockCardLabels = () => ({
BARRIER: 'Barrier',
CONTRACT_VALUE: 'Contract value',
ENTRY_SPOT: 'Entry spot',
TAKE_PROFIT: 'Take profit',
TOTAL_PROFIT_LOSS: 'Total profit/loss',
PURCHASE_PRICE: 'Buy price',
});

describe('TurbosCardBody', () => {
const mock_props = {
addToast: jest.fn(),
connectWithContractUpdate: jest.fn(),
contract_info,
contract_update: {
take_profit: {
display_name: 'Take profit',
order_amount: 0,
order_date: 1678948046,
},
},
currency: 'USD',
current_focus: null,
error_message_alignment: 'left',
getCardLabels: mockCardLabels,
getContractById: jest.fn(),
is_sold: false,
onMouseLeave: jest.fn(),
removeToast: jest.fn(),
setCurrentFocus: jest.fn(),
status: 'profit',
progress_slider_mobile_el: false,
};
beforeAll(() => {
(ReactDOM.createPortal as jest.Mock) = jest.fn(component => {
return component;
});
});

it('renders header and values correctly', () => {
render(<TurbosCardBody {...mock_props} />);
const buy_price_header = screen.getByText(mockCardLabels().PURCHASE_PRICE);
expect(buy_price_header).toBeInTheDocument();
const buy_price_amount = screen.getByText('1,044.00');
expect(buy_price_amount).toBeInTheDocument();

const entry_spot_header = screen.getByText(mockCardLabels().ENTRY_SPOT);
expect(entry_spot_header).toBeInTheDocument();
const entry_spot_amount = screen.getByText('1,046.80');
expect(entry_spot_amount).toBeInTheDocument();

const barrier_header = screen.getByText(mockCardLabels().BARRIER);
expect(barrier_header).toBeInTheDocument();
const barrier_level = screen.getByText('10,904.80');
expect(barrier_level).toBeInTheDocument();

const take_profit_header = screen.getByText(mockCardLabels().TAKE_PROFIT);
expect(take_profit_header).toBeInTheDocument();
const take_profit_amount = screen.getByText('-');
expect(take_profit_amount).toBeInTheDocument();

const total_profit_loss_header = screen.getByText(mockCardLabels().TOTAL_PROFIT_LOSS);
expect(total_profit_loss_header).toBeInTheDocument();
const total_profit_loss_amount = screen.getByText('50.00');
expect(total_profit_loss_amount).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import { ResultStatusIcon } from '../result-overlay/result-overlay';
import ProgressSliderMobile from '../../progress-slider-mobile';
import AccumulatorCardBody from './accumulator-card-body';
import MultiplierCardBody from './multiplier-card-body';
import TurbosCardBody from './turbos-card-body';
import VanillaOptionsCardBody from './vanilla-options-card-body';
import { TContractInfo, TContractStore } from '@deriv/shared/src/utils/contract/contract-types';
import { ContractUpdate } from '@deriv/api-types';
import { TToastConfig } from '../../types/contract.types';
import { TGetCardLables } from '../../types/common.types';

export type TGeneralContractCardBodyProps = {
addToast: (toast_config: TToastConfig) => void;
contract_info: TContractInfo;
contract_update: ContractUpdate;
contract_update: TContractInfo['contract_update'];
connectWithContractUpdate?: (contract_update_form: React.ElementType) => React.ElementType;
currency: string;
current_focus?: string;
Expand All @@ -34,16 +34,17 @@ export type TGeneralContractCardBodyProps = {
onMouseLeave: () => void;
removeToast: (toast_id: string) => void;
setCurrentFocus: (name: string) => void;
status: string;
status?: string;
toggleCancellationWarning: () => void;
progress_slider?: React.ReactNode;
is_accumulator?: boolean;
is_positions?: boolean;
};

export type TContractCardBodyProps = {
is_accumulator?: boolean;
is_multiplier: boolean;
server_time: moment.Moment;
is_turbos?: boolean;
is_vanilla?: boolean;
} & TGeneralContractCardBodyProps;

Expand All @@ -63,6 +64,7 @@ const ContractCardBody = ({
is_multiplier,
is_positions,
is_sold,
is_turbos,
is_vanilla,
onMouseLeave,
removeToast,
Expand Down Expand Up @@ -90,51 +92,61 @@ const ContractCardBody = ({
/>
);

const toggle_card_dialog_props = {
addToast,
connectWithContractUpdate,
current_focus,
error_message_alignment,
getContractById,
onMouseLeave,
removeToast,
setCurrentFocus,
};

let card_body;

if (is_multiplier) {
card_body = (
<MultiplierCardBody
addToast={addToast}
connectWithContractUpdate={connectWithContractUpdate}
contract_info={contract_info}
contract_update={contract_update}
currency={currency}
current_focus={current_focus}
error_message_alignment={error_message_alignment}
getCardLabels={getCardLabels}
getContractById={getContractById}
has_progress_slider={has_progress_slider}
progress_slider={progress_slider_mobile_el}
is_mobile={is_mobile}
is_sold={is_sold}
onMouseLeave={onMouseLeave}
status={status}
removeToast={removeToast}
setCurrentFocus={setCurrentFocus}
should_show_cancellation_warning={should_show_cancellation_warning}
toggleCancellationWarning={toggleCancellationWarning}
{...toggle_card_dialog_props}
/>
);
} else if (is_accumulator) {
card_body = (
<AccumulatorCardBody
addToast={addToast}
connectWithContractUpdate={connectWithContractUpdate}
contract_info={contract_info}
contract_update={contract_update}
currency={currency}
current_focus={current_focus}
error_message_alignment={error_message_alignment}
getCardLabels={getCardLabels}
getContractById={getContractById}
indicative={indicative}
is_sold={is_sold}
onMouseLeave={onMouseLeave}
status={status}
removeToast={removeToast}
setCurrentFocus={setCurrentFocus}
is_positions={is_positions}
{...toggle_card_dialog_props}
/>
);
} else if (is_turbos) {
card_body = (
<TurbosCardBody
contract_info={contract_info}
contract_update={contract_update}
currency={currency}
getCardLabels={getCardLabels}
is_sold={is_sold}
status={status}
progress_slider_mobile_el={progress_slider_mobile_el}
{...toggle_card_dialog_props}
/>
);
} else if (is_vanilla) {
Expand Down Expand Up @@ -209,7 +221,7 @@ const ContractCardBody = ({
<MobileWrapper>
<div
className={classNames('dc-contract-card__separatorclass', {
'dc-contract-card__body-wrapper': !is_multiplier,
'dc-contract-card__body-wrapper': !is_multiplier && !is_turbos,
})}
>
{card_body}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type TCardFooterPropTypes = {
is_sell_requested: boolean;
onClickCancel: (contract_id?: number) => void;
onClickSell: (contract_id?: number) => void;
onFooterEntered: () => void;
onFooterEntered?: () => void;
server_time: moment.Moment;
should_show_transition: boolean;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import React from 'react';
import classNames from 'classnames';
import { CSSTransition } from 'react-transition-group';
import { localize } from '@deriv/translations';
import {
isHighLow,
getCurrentTick,
getGrowthRatePercentage,
isBot,
getContractSubtype,
isAccumulatorContract,
isBot,
isOnlyUpsDownsContract,
isMobile,
isTurbosContract,
} from '@deriv/shared';
import ContractTypeCell from './contract-type-cell';
import Button from '../../button';
Expand Down Expand Up @@ -66,28 +69,42 @@ const ContractCardHeader = ({
const is_accumulator = isAccumulatorContract(contract_type);
const is_only_ups_downs = isOnlyUpsDownsContract(contract_type);
const is_mobile = isMobile();
const contract_type_list_info = [
{
is_param_displayed: multiplier,
displayed_param: `x${multiplier}`,
},
{
is_param_displayed: is_accumulator,
displayed_param: `${getGrowthRatePercentage(growth_rate || 0)}%`,
},
];
const is_turbos = isTurbosContract(contract_type);

const contract_type_list_info = React.useMemo(
() => [
{
is_param_displayed: multiplier,
displayed_param: `x${multiplier}`,
},
{
is_param_displayed: is_accumulator,
displayed_param: `${getGrowthRatePercentage(growth_rate || 0)}%`,
},
{
is_param_displayed: is_turbos,
displayed_param:
getContractSubtype(contract_type || '') === 'Long' ? localize('Long') : localize('Short'),
},
],
[multiplier, growth_rate, is_accumulator, is_turbos, contract_type]
);

const displayed_trade_param =
contract_type_list_info.find(contract_type_item_info => contract_type_item_info.is_param_displayed)
?.displayed_param || '';

return (
<>
<React.Fragment>
<div
className={classNames('dc-contract-card__grid', 'dc-contract-card__grid-underlying-trade', {
'dc-contract-card__grid-underlying-trade--mobile': is_mobile && !multiplier && !is_accumulator,
'dc-contract-card__grid-underlying-trade--mobile':
is_mobile && !multiplier && !is_accumulator && !is_turbos,
'dc-contract-card__grid-underlying-trade--trader': !is_pathname_bot,
'dc-contract-card__grid-underlying-trade--trader--accumulator': !is_mobile && is_accumulator,
'dc-contract-card__grid-underlying-trade--trader--accumulator-sold': is_accumulator && is_sold,
[`dc-contract-card__grid-underlying-trade--trader--${
is_accumulator ? 'accumulator' : 'turbos'
}-sold`]: (is_accumulator || is_turbos) && is_sold,
})}
>
<div
Expand Down Expand Up @@ -176,7 +193,7 @@ const ContractCardHeader = ({
/>
)}
</DesktopWrapper>
</>
</React.Fragment>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export type TContractCardSellProps = {
contract_info: TContractInfo;
getCardLabels: TGetCardLables;
is_sell_requested: boolean;
onClickSell: (contract_id?: number) => void;
onClickSell?: (contract_id?: number) => void;
};

const ContractCardSell = ({ contract_info, getCardLabels, is_sell_requested, onClickSell }: TContractCardSellProps) => {
const is_valid_to_sell = isValidToSell(contract_info);
const should_show_sell = hasContractEntered(contract_info) && isOpen(contract_info);

const onClick = (ev: React.MouseEvent<HTMLButtonElement>) => {
onClickSell(contract_info.contract_id);
onClickSell?.(contract_info.contract_id);
ev.stopPropagation();
ev.preventDefault();
};
Expand Down
Loading