@@ -61,12 +75,13 @@ const ContractDetails = observer(() => {
)}
-
+
-
+
{is_tp_history_visible &&
}
+ {should_show_sell &&
}
);
});
diff --git a/packages/trader/src/AppV2/Hooks/useContractDetails.ts b/packages/trader/src/AppV2/Hooks/useContractDetails.ts
index 135e33308dfb..8e31d3cbea8e 100644
--- a/packages/trader/src/AppV2/Hooks/useContractDetails.ts
+++ b/packages/trader/src/AppV2/Hooks/useContractDetails.ts
@@ -4,10 +4,13 @@ import { useStore } from '@deriv/stores';
const useContractDetails = () => {
const store = useStore();
- const { contract_replay } = store;
+ const { contract_replay, contract_trade } = store;
+ const { getContractById } = contract_trade;
const { contract_store, onMount } = contract_replay;
- const location = useLocation();
const { contract_info } = contract_store;
+ const contract = getContractById(contract_info.contract_id);
+
+ const location = useLocation();
useEffect(() => {
if (!contract_info.contract_id) {
@@ -21,6 +24,7 @@ const useContractDetails = () => {
return {
contract_info,
+ contract,
is_loading: !contract_info.contract_id,
};
};
diff --git a/packages/trader/src/AppV2/Hooks/useOrderDetails.ts b/packages/trader/src/AppV2/Hooks/useOrderDetails.ts
index 24950c810605..e5486eacdc5f 100644
--- a/packages/trader/src/AppV2/Hooks/useOrderDetails.ts
+++ b/packages/trader/src/AppV2/Hooks/useOrderDetails.ts
@@ -1,4 +1,5 @@
import {
+ CONTRACT_TYPES,
TContractInfo,
addComma,
getDurationPeriod,
@@ -8,7 +9,7 @@ import {
isAccumulatorContract,
isResetContract,
} from '@deriv/shared';
-import { localize } from '@deriv/translations';
+import { Localize, localize } from '@deriv/translations';
import { getBarrierValue } from 'App/Components/Elements/PositionsDrawer/helpers';
// Contains all key values that are used more than once in different transform objects
@@ -20,16 +21,16 @@ const getCommonFields = (data: TContractInfo) => {
: `${tick_count} ${ticks_label}`;
return {
- 'Reference ID': [
+ [localize('Reference ID')]: [
data.transaction_ids?.buy ? `${data.transaction_ids.buy} (Buy)` : '',
data.transaction_ids?.sell ? `${data.transaction_ids.sell} (Sell)` : '',
],
- Stake: data.buy_price ? `${data.buy_price.toFixed(2)} ${data.currency}` : '',
- Duration:
+ [localize('Stake')]: data.buy_price ? `${data.buy_price.toFixed(2)} ${data.currency}` : '',
+ [localize('Duration')]:
Number(tick_count) > 0
? ticks_duration_text
: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
- 'Payout per point': data.display_number_of_contracts ? `${data.display_number_of_contracts}` : '',
+ [localize('Payout per point')]: data.display_number_of_contracts ? `${data.display_number_of_contracts}` : '',
};
};
@@ -37,17 +38,17 @@ const getCommonFields = (data: TContractInfo) => {
const transformMultiplierData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- Multiplier: data.multiplier ? `x${data.multiplier}` : '',
- Stake: commonFields.Stake,
- Commission: data.commission ? `${data.commission} ${data.currency}` : '',
- 'Take Profit': data.limit_order?.take_profit?.order_amount
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Multiplier')]: data.multiplier ? `x${data.multiplier}` : '',
+ [localize('Stake')]: commonFields[localize('Stake')],
+ [localize('Commission')]: data.commission ? `${data.commission} ${data.currency}` : '',
+ [localize('Take Profit')]: data.limit_order?.take_profit?.order_amount
? `${data.limit_order.take_profit.order_amount.toFixed(2)} ${data.currency}`
- : 'Not set',
- 'Stop loss': data.limit_order?.stop_loss?.order_amount
+ : localize('Not set'),
+ [localize('Stop loss')]: data.limit_order?.stop_loss?.order_amount
? `${data.limit_order.stop_loss.order_amount.toFixed(2)} ${data.currency}`
- : 'Not set',
- 'Stop out level': data.limit_order?.stop_out?.order_amount
+ : localize('Not set'),
+ [localize('Stop out level')]: data.limit_order?.stop_out?.order_amount
? `${data.limit_order.stop_out.order_amount.toFixed(2)} ${data.currency}`
: '',
};
@@ -57,10 +58,10 @@ const transformMultiplierData = (data: TContractInfo) => {
const transformRiseData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- Duration: commonFields.Duration,
- Barrier: data.barrier ? data.barrier : '',
- Stake: commonFields.Stake,
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Duration')]: commonFields[localize('Duration')],
+ [localize('Barrier')]: data.barrier ? data.barrier : '',
+ [localize('Stake')]: commonFields[localize('Stake')],
};
};
@@ -68,14 +69,14 @@ const transformRiseData = (data: TContractInfo) => {
const transformTurbosData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- Duration: commonFields.Duration,
- Barrier: data.barrier ? data.barrier : '',
- 'Payout per point': commonFields['Payout per point'],
- Stake: commonFields.Stake,
- 'Take Profit': data.limit_order?.take_profit?.order_amount
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Duration')]: commonFields[localize('Duration')],
+ [localize('Barrier')]: data.barrier ? data.barrier : '',
+ [localize('Payout per point')]: commonFields[localize('Payout per point')],
+ [localize('Stake')]: commonFields[localize('Stake')],
+ [localize('Take Profit')]: data.limit_order?.take_profit?.order_amount
? `${data.limit_order.take_profit.order_amount.toFixed(2)} ${data.currency}`
- : 'Not set',
+ : localize('Not set'),
};
};
@@ -83,25 +84,25 @@ const transformTurbosData = (data: TContractInfo) => {
const transformMatcherData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- Duration: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
- Target: getBarrierValue(data),
- Stake: commonFields.Stake,
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Duration')]: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
+ [localize('Target')]: getBarrierValue(data),
+ [localize('Stake')]: commonFields[localize('Stake')],
};
};
-
// For Accumulators
const transformAccumulatorData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- 'Growth rate': data.growth_rate ? `${getGrowthRatePercentage(data.growth_rate)}%` : '',
- Stake: commonFields.Stake,
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Growth rate')]: data.growth_rate ? `${getGrowthRatePercentage(data.growth_rate)}%` : '',
+ [localize('Duration')]: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
+ [localize('Stake')]: commonFields[localize('Stake')],
...{
...(data.limit_order?.take_profit && {
- 'Take Profit': data.limit_order?.take_profit?.order_amount
+ [localize('Take Profit')]: data.limit_order?.take_profit?.order_amount
? `${data.limit_order.take_profit.order_amount} ${data.currency}`
- : 'Not set',
+ : localize('Not set'),
}),
},
};
@@ -111,42 +112,42 @@ const transformAccumulatorData = (data: TContractInfo) => {
const transformVanillaData = (data: TContractInfo) => {
const commonFields = getCommonFields(data);
return {
- 'Reference ID': commonFields['Reference ID'],
- 'Strike Price':
+ [localize('Reference ID')]: commonFields[localize('Reference ID')],
+ [localize('Strike Price')]:
(isResetContract(data.contract_type) ? addComma(data.entry_spot_display_value) : getBarrierValue(data)) ||
' - ',
- Duration: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
- 'Payout per point': commonFields['Payout per point'],
- Stake: commonFields.Stake,
+ [localize('Duration')]: `${getDurationTime(data) ?? ''} ${getDurationUnitText(getDurationPeriod(data)) ?? ''}`,
+ [localize('Payout per point')]: commonFields[localize('Payout per point')],
+ [localize('Stake')]: commonFields[localize('Stake')],
};
};
// Map of contract types to their respective transform functions
const transformFunctionMap: Record
Record> = {
- TURBOSLONG: transformTurbosData,
- TURBOSSHORT: transformTurbosData,
- MULTDOWN: transformMultiplierData,
- MULTUP: transformMultiplierData,
- DIGITMATCH: transformMatcherData,
- DIGITDIFF: transformMatcherData,
- DIGITEVEN: transformMatcherData,
- DIGITODD: transformMatcherData,
- DIGITOVER: transformMatcherData,
- DIGITUNDER: transformMatcherData,
- CALL: transformRiseData,
- PUT: transformRiseData,
- ONETOUCH: transformRiseData,
- NOTOUCH: transformRiseData,
- ACCU: transformAccumulatorData,
- VANILLALONGCALL: transformVanillaData,
- VANILLALONGPUT: transformVanillaData,
+ [CONTRACT_TYPES.TURBOS.LONG]: transformTurbosData,
+ [CONTRACT_TYPES.TURBOS.SHORT]: transformTurbosData,
+ [CONTRACT_TYPES.MULTIPLIER.DOWN]: transformMultiplierData,
+ [CONTRACT_TYPES.MULTIPLIER.UP]: transformMultiplierData,
+ [CONTRACT_TYPES.MATCH_DIFF.MATCH]: transformMatcherData,
+ [CONTRACT_TYPES.MATCH_DIFF.DIFF]: transformMatcherData,
+ [CONTRACT_TYPES.EVEN_ODD.EVEN]: transformMatcherData,
+ [CONTRACT_TYPES.EVEN_ODD.ODD]: transformMatcherData,
+ [CONTRACT_TYPES.OVER_UNDER.OVER]: transformMatcherData,
+ [CONTRACT_TYPES.OVER_UNDER.UNDER]: transformMatcherData,
+ [CONTRACT_TYPES.RESET.CALL]: transformRiseData,
+ [CONTRACT_TYPES.PUT]: transformRiseData,
+ [CONTRACT_TYPES.CALL]: transformRiseData,
+ [CONTRACT_TYPES.TOUCH.ONE_TOUCH]: transformRiseData,
+ [CONTRACT_TYPES.TOUCH.NO_TOUCH]: transformRiseData,
+ [CONTRACT_TYPES.ACCUMULATOR]: transformAccumulatorData,
+ [CONTRACT_TYPES.VANILLA.CALL]: transformVanillaData,
+ [CONTRACT_TYPES.VANILLA.PUT]: transformVanillaData,
};
const useOrderDetails = (contract_info: TContractInfo) => {
const contractInfo = contract_info;
if (!contractInfo.contract_type) return;
-
const transformFunction = transformFunctionMap[contractInfo.contract_type];
const details = transformFunction ? transformFunction(contractInfo) : {};
diff --git a/packages/trader/src/AppV2/Utils/contract-details-config.ts b/packages/trader/src/AppV2/Utils/contract-details-config.ts
index c10fb80a1eec..8fce879d0048 100644
--- a/packages/trader/src/AppV2/Utils/contract-details-config.ts
+++ b/packages/trader/src/AppV2/Utils/contract-details-config.ts
@@ -15,13 +15,25 @@ export const getContractDetailsConfig = (contract_type: string) => {
is_stop_loss_visible: false,
is_tp_history_visible: true,
},
- [CONTRACT_TYPES.MULTIPLIER.UP || CONTRACT_TYPES.MULTIPLIER.DOWN]: {
+ [CONTRACT_TYPES.MULTIPLIER.UP]: {
is_take_profit_visible: true,
is_deal_cancellation_visible: true,
is_stop_loss_visible: true,
is_tp_history_visible: true,
},
- [CONTRACT_TYPES.TURBOS.LONG || CONTRACT_TYPES.TURBOS.SHORT]: {
+ [CONTRACT_TYPES.MULTIPLIER.DOWN]: {
+ is_take_profit_visible: true,
+ is_deal_cancellation_visible: true,
+ is_stop_loss_visible: true,
+ is_tp_history_visible: true,
+ },
+ [CONTRACT_TYPES.TURBOS.LONG]: {
+ is_take_profit_visible: true,
+ is_deal_cancellation_visible: false,
+ is_stop_loss_visible: false,
+ is_tp_history_visible: true,
+ },
+ [CONTRACT_TYPES.TURBOS.SHORT]: {
is_take_profit_visible: true,
is_deal_cancellation_visible: false,
is_stop_loss_visible: false,
diff --git a/packages/trader/src/AppV2/Utils/helper.ts b/packages/trader/src/AppV2/Utils/helper.ts
new file mode 100644
index 000000000000..eae745b55c06
--- /dev/null
+++ b/packages/trader/src/AppV2/Utils/helper.ts
@@ -0,0 +1,22 @@
+import { TGetCardLables } from '@deriv/components';
+import { formatDuration, getDiffDuration } from '@deriv/shared';
+
+type TRemainingTimeProps = {
+ end_time?: number;
+ start_time: moment.Moment;
+ format?: string;
+ getCardLabels: TGetCardLables;
+};
+
+export const getRemainingTime = ({ end_time, format, getCardLabels, start_time }: TRemainingTimeProps) => {
+ if (!end_time || start_time.unix() > +end_time) {
+ return;
+ }
+
+ const { days, timestamp } = formatDuration(getDiffDuration(start_time.unix(), end_time), format);
+ let remaining_time = timestamp;
+ if (days > 0) {
+ remaining_time = `${days} ${days > 1 ? getCardLabels().DAYS : getCardLabels().DAY} ${timestamp}`;
+ }
+ return remaining_time;
+};
diff --git a/packages/trader/src/AppV2/app.tsx b/packages/trader/src/AppV2/app.tsx
index e83b82de0ea6..c88dc83488c3 100644
--- a/packages/trader/src/AppV2/app.tsx
+++ b/packages/trader/src/AppV2/app.tsx
@@ -12,6 +12,7 @@ import { NotificationsProvider } from '@deriv-com/quill-ui';
import 'Sass/app.scss';
import ContractDetails from './Containers/ContractDetails';
import '@deriv-com/quill-tokens/dist/quill.css';
+import { useLocation } from 'react-router';
import Notifications from './Containers/Notifications';
type Apptypes = {
@@ -26,17 +27,21 @@ const App = ({ passthrough }: Apptypes) => {
React.useEffect(() => {
return () => root_store.ui.setPromptHandler(false);
}, [root_store]);
-
+ const location = useLocation();
return (
-
-
-
-
-
-
+ {location.pathname.includes('/contract/') ? (
+
+ ) : (
+
+
+
+
+
+
+ )}
);