Skip to content

Commit

Permalink
chore: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadtaimoor-deriv committed Jun 14, 2024
1 parent 85bca4f commit 99f941f
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ type TRemainingTimeProps = {
start_time: moment.Moment;
format?: string;
getCardLabels: TGetCardLables;
className?: string;
};

const RemainingTime = ({ as = 'div', end_time, format, getCardLabels, start_time }: TRemainingTimeProps) => {
const RemainingTime = ({
as = 'div',
end_time,
format,
getCardLabels,
start_time,
className = 'dc-remaining-time',
}: TRemainingTimeProps) => {
const Tag = as;
if (!end_time || start_time.unix() > +end_time) {
return <React.Fragment>{''}</React.Fragment>;
Expand All @@ -26,7 +34,7 @@ const RemainingTime = ({ as = 'div', end_time, format, getCardLabels, start_time
}
const is_zeroes = /^00:00$/.test(remaining_time);

return <React.Fragment>{!is_zeroes && <Tag className='dc-remaining-time'>{remaining_time}</Tag>}</React.Fragment>;
return <React.Fragment>{!is_zeroes && <Tag className={className}>{remaining_time}</Tag>}</React.Fragment>;
};

export default RemainingTime;
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Button } from '@deriv-com/quill-ui';
import { TContractInfo, getCardLabels, isMultiplierContract, isValidToCancel, isValidToSell } from '@deriv/shared';
import { Button, Text } from '@deriv-com/quill-ui';
import { RemainingTime } from '@deriv/components';
import {
TContractInfo,
formatMoney,
getCardLabels,
isMultiplierContract,
isValidToCancel,
isValidToSell,
} from '@deriv/shared';
import { useStore } from '@deriv/stores';
import { getRemainingTime } from 'AppV2/Utils/helper';
import { observer } from 'mobx-react';
Expand Down Expand Up @@ -44,12 +52,20 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
<Button
onClick={() => onClickCancel(contract_id)}
variant='secondary'
label={`${getCardLabels().CANCEL} ${getRemainingTime({
end_time: cancellation_date_expiry,
format: 'mm:ss',
getCardLabels,
start_time: server_time,
})}`}
label={
<>
{getCardLabels().CANCEL}
{' '}
<RemainingTime
as='span'
end_time={cancellation_date_expiry}
format='mm:ss'
className='color'
getCardLabels={getCardLabels}
start_time={server_time}
/>
</>
}
color='black'
disabled={Number(profit) >= 0}
size='lg'
Expand All @@ -62,7 +78,7 @@ const ContractDetailsFooter = observer(({ contract_info }: ContractInfoProps) =>
variant='secondary'
label={
is_valid_to_sell
? `${getCardLabels().CLOSE} @ ${bid_price} ${currency}`
? `${getCardLabels().CLOSE} @ ${bid_price} ${formatMoney(currency)}`
: getCardLabels().RESALE_NOT_OFFERED
}
color='black'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
overflow: auto;
gap: var(--semantic-spacing-general-sm);
height: 100vh;
padding-bottom: var(--core-spacing-400);
padding-bottom: var(--semantic-spacing-general-4xl);
&--two-buttons {
padding-bottom: 230px;
padding-bottom: 186px;
}

&--one-button {
padding-bottom: 140px;
padding-bottom: 130px;
}
.contract-card-wrapper {
margin-top: var(--core-spacing-200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,37 @@ const ContractDetails = observer(() => {
showTpSl = isOpen(contract_info) && Boolean(limit_order);
}
return (
<div
className={classNames('contract-details', {
'contract-details--two-buttons': should_show_sell && show_cancel_button,
'contract-details--one-button': should_show_sell && !show_cancel_button,
})}
>
<div className='contract-card-wrapper'>
<ContractCard contractInfo={contract_info} serverTime={server_time} />
</div>
<div className='placeholder'>
<ChartPlaceholder />
</div>
<DealCancellation />
{showTpSl && (
<CardWrapper>
<TakeProfit />
<StopLoss />
</CardWrapper>
)}
<>
{' '}
<div
className={classNames('contract-details', {
'contract-details--two-buttons': should_show_sell && show_cancel_button,
'contract-details--one-button': should_show_sell && !show_cancel_button,
})}
>
<div className='contract-card-wrapper'>
<ContractCard contractInfo={contract_info} serverTime={server_time} />
</div>
<div className='placeholder'>
<ChartPlaceholder />
</div>
<DealCancellation />
{showTpSl && (
<CardWrapper>
<TakeProfit />
<StopLoss />
</CardWrapper>
)}

<OrderDetails contract_info={contract_info} />
<PayoutInfo contract_info={contract_info} />
<EntryExitDetails contract_info={contract_info} />
{is_tp_history_visible && update_history.length > 0 && (
<TakeProfitHistory history={update_history} currency={currency} />
)}
<OrderDetails contract_info={contract_info} />
<PayoutInfo contract_info={contract_info} />
<EntryExitDetails contract_info={contract_info} />
{is_tp_history_visible && update_history.length > 0 && (
<TakeProfitHistory history={update_history} currency={currency} />
)}
</div>
{should_show_sell && <ContractDetailsFooter contract_info={contract_info} />}
</div>
</>
);
});

Expand Down

0 comments on commit 99f941f

Please sign in to comment.