diff --git a/packages/components/src/components/contract-card/contract-card-items/__tests__/turbos-card-body.spec.tsx b/packages/components/src/components/contract-card/contract-card-items/__tests__/turbos-card-body.spec.tsx index 151b8c14bc43..3f4a2f4b0680 100644 --- a/packages/components/src/components/contract-card/contract-card-items/__tests__/turbos-card-body.spec.tsx +++ b/packages/components/src/components/contract-card/contract-card-items/__tests__/turbos-card-body.spec.tsx @@ -10,22 +10,17 @@ const contract_info: TContractInfo = { buy_price: 1044.0, profit: 50, barrier: '10904.80', - current_spot_display_value: '1046.80', - sell_spot: 1046.8, - entry_spot: 1054, - is_valid_to_sell: 1, + entry_spot_display_value: '1046.80', + sell_price: 1046.8, }; const mockCardLabels = () => ({ BARRIER: 'Barrier', - CURRENT_PRICE: 'Current price', - STAKE: 'Stake', - BUY_PRICE: 'Buy price', + CONTRACT_VALUE: 'Contract value', + ENTRY_SPOT: 'Entry spot', TAKE_PROFIT: 'Take profit', TOTAL_PROFIT_LOSS: 'Total profit/loss', - PAYOUT: 'Payout', - PROFIT_LOSS: 'Profit/Loss', - POTENTIAL_PROFIT_LOSS: 'Potential profit/loss', + PURCHASE_PRICE: 'Buy price', }); describe('TurbosCardBody', () => { @@ -58,18 +53,17 @@ describe('TurbosCardBody', () => { }); }); - // is_sold = false - it('renders stake amount correctly', () => { + it('renders header and values correctly', () => { render(); - const stake_header = screen.getByText(mockCardLabels().STAKE); - expect(stake_header).toBeInTheDocument(); - const stake_amount = screen.getByText('1,044.00'); - expect(stake_amount).toBeInTheDocument(); + 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 current_price_header = screen.getByText(mockCardLabels().CURRENT_PRICE); - expect(current_price_header).toBeInTheDocument(); - const current_price_amount = screen.getByText('1,046.80'); - expect(current_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(); @@ -86,32 +80,4 @@ describe('TurbosCardBody', () => { const total_profit_loss_amount = screen.getByText('50.00'); expect(total_profit_loss_amount).toBeInTheDocument(); }); - - // is_sold = true - it('renders headers when contract is sold', () => { - render(); - - const profit_loss_header = screen.getByText(mockCardLabels().PROFIT_LOSS); - expect(profit_loss_header).toBeInTheDocument(); - const profit_loss_amount = screen.getByText('50.00'); - expect(profit_loss_amount).toBeInTheDocument(); - - const payout_header = screen.getByText(mockCardLabels().PAYOUT); - expect(payout_header).toBeInTheDocument(); - const payout_amount = screen.getByText('1,046.80'); - expect(payout_amount).toBeInTheDocument(); - - const buy_price_header = screen.getByText(mockCardLabels().BUY_PRICE); - expect(buy_price_header).toBeInTheDocument(); - const buy_price_amount = screen.getByText('10,904.80'); - expect(buy_price_amount).toBeInTheDocument(); - - const take_profit_header = screen.queryByText(mockCardLabels().TAKE_PROFIT); - expect(take_profit_header).not.toBeInTheDocument(); - const take_profit_amount = screen.queryByText('-'); - expect(take_profit_amount).not.toBeInTheDocument(); - - expect(screen.getByText('Barrier')).toBeInTheDocument(); - expect(screen.queryByText('Current price')).not.toBeInTheDocument(); - }); }); diff --git a/packages/components/src/components/contract-card/contract-card-items/turbos-card-body.tsx b/packages/components/src/components/contract-card/contract-card-items/turbos-card-body.tsx index e265ded3a985..aca9f631462a 100644 --- a/packages/components/src/components/contract-card/contract-card-items/turbos-card-body.tsx +++ b/packages/components/src/components/contract-card/contract-card-items/turbos-card-body.tsx @@ -54,72 +54,64 @@ const TurbosCardBody = ({ status, }: TTurbosCardBody) => { const { + bid_price, buy_price, profit, barrier, - current_spot_display_value, + entry_spot_display_value, limit_order = {}, - sell_spot, - entry_spot, + sell_price, } = contract_info; const { take_profit } = getLimitOrderAmount(contract_update || limit_order); const is_valid_to_sell = isValidToSell(contract_info); - const { BARRIER, BUY_PRICE, CURRENT_PRICE, STAKE, TAKE_PROFIT, TOTAL_PROFIT_LOSS, PAYOUT, PROFIT_LOSS } = - getCardLabels(); + const contract_value = is_sold ? sell_price : bid_price; + const { BARRIER, CONTRACT_VALUE, ENTRY_SPOT, TAKE_PROFIT, TOTAL_PROFIT_LOSS, PURCHASE_PRICE } = getCardLabels(); return (
0 : false} + header={PURCHASE_PRICE} > - + - - + + - + - {is_sold ? ( - - + +
+ + {take_profit ? : -} + {is_valid_to_sell && ( + + )} - ) : ( -
- - {take_profit ? : -} - {is_valid_to_sell && ( - - )} - -
- )} +
+ + +
{is_sold ? ( @@ -130,7 +122,7 @@ const TurbosCardBody = ({
- {!is_sold && !!profit && ( + {!!profit && ( = 0; const cancellation_price = getCancellationPrice(contract_info); const { number_of_contracts } = extractInfoFromShortcode(shortcode); - const show_barrier = - !is_vanilla && - !isAccumulatorContract(contract_type) && - (!isTurbosContract(contract_type) || !isNaN(contract_end_time)); - const show_duration = - (!isAccumulatorContract(contract_type) && !isTurbosContract(contract_type)) || !isNaN(contract_end_time); - const show_payout_per_point = (isTurbosContract(contract_type) && !isNaN(contract_end_time)) || is_vanilla; + const show_barrier = !is_vanilla && !isAccumulatorContract(contract_type); + const show_duration = !isAccumulatorContract(contract_type) || !isNaN(contract_end_time); + const show_payout_per_point = isTurbosContract(contract_type) || is_vanilla; const ticks_duration_text = isAccumulatorContract(contract_type) ? `${tick_passed}/${tick_count} ${localize('ticks')}` : `${tick_count} ${tick_count < 2 ? localize('tick') : localize('ticks')}`;