Skip to content

Commit

Permalink
Kate/92181/Content change for unavailable contract details error mess…
Browse files Browse the repository at this point in the history
…age from Deriv SmartTrader on Deriv's Report. (#8065)

* chore: change phrase for unsupported contracts

* fix: change key for profit table and statment

* refactor: reuse const

* refactor: change constants name

---------

Co-authored-by: Matin shafiei <matin@deriv.com>
Co-authored-by: Jim Daniels Wasswa <104334373+jim-deriv@users.noreply.github.com>
  • Loading branch information
3 people committed Mar 31, 2023
1 parent a13b4d6 commit f489cf7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 64 deletions.
18 changes: 3 additions & 15 deletions packages/reports/src/Containers/open-positions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import {
SelectNative,
} from '@deriv/components';
import {
urlFor,
isAccumulatorContract,
isMobile,
isMultiplierContract,
isVanillaContract,
getTimePercentage,
website_name,
getUnsupportedContracts,
getTotalProfit,
getContractPath,
getCurrentTick,
Expand Down Expand Up @@ -224,26 +223,15 @@ export const OpenPositionsTable = ({
</React.Fragment>
);

const portfoliows_href = urlFor('user/portfoliows', { legacy: true });

const getRowAction = row_obj =>
row_obj.is_unsupported
? {
component: (
<Localize
i18n_default_text='This trade type is currently not supported on {{website_name}}. Please go to <0>Binary.com</0> for details.'
i18n_default_text="The {{trade_type_name}} contract details aren't currently available. We're working on making them available soon."
values={{
website_name,
trade_type_name: getUnsupportedContracts()[row_obj.type]?.name,
}}
components={[
<a
key={0}
className='link link--orange'
rel='noopener noreferrer'
target='_blank'
href={portfoliows_href}
/>,
]}
/>
),
}
Expand Down
24 changes: 7 additions & 17 deletions packages/reports/src/Containers/profit-table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PropTypes as MobxPropTypes } from 'mobx-react';
import React from 'react';
import { withRouter } from 'react-router';
import { DesktopWrapper, MobileWrapper, DataList, DataTable } from '@deriv/components';
import { extractInfoFromShortcode, isForwardStarting, urlFor, website_name, getContractPath } from '@deriv/shared';
import { extractInfoFromShortcode, isForwardStarting, getUnsupportedContracts, getContractPath } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
import { ReportsTableRowLoader } from '../Components/Elements/ContentLoader';
import CompositeCalendar from '../Components/Form/CompositeCalendar';
Expand All @@ -16,31 +16,21 @@ import PlaceholderComponent from '../Components/placeholder-component.jsx';
import { ReportsMeta } from '../Components/reports-meta.jsx';
import { getProfitTableColumnsTemplate } from 'Constants/data-table-constants';

const profit_tablews_href = urlFor('user/profit_tablews', { legacy: true });

const getRowAction = row_obj =>
getSupportedContracts()[extractInfoFromShortcode(row_obj.shortcode).category.toUpperCase()] &&
!isForwardStarting(row_obj.shortcode, row_obj.purchase_time_unix)
const getRowAction = row_obj => {
const contract_type = extractInfoFromShortcode(row_obj.shortcode).category.toUpperCase();
return getSupportedContracts()[contract_type] && !isForwardStarting(row_obj.shortcode, row_obj.purchase_time_unix)
? getContractPath(row_obj.contract_id)
: {
component: (
<Localize
i18n_default_text='This trade type is currently not supported on {{website_name}}. Please go to <0>Binary.com</0> for details.'
i18n_default_text="The {{trade_type_name}} contract details aren't currently available. We're working on making them available soon."
values={{
website_name,
trade_type_name: getUnsupportedContracts()[contract_type]?.name,
}}
components={[
<a
key={0}
className='link link--orange'
rel='noopener noreferrer'
target='_blank'
href={profit_tablews_href}
/>,
]}
/>
),
};
};

const ProfitTable = ({
component_icon,
Expand Down
20 changes: 5 additions & 15 deletions packages/reports/src/Containers/statement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router-dom';
import { DesktopWrapper, MobileWrapper, DataList, DataTable, Text, Clipboard } from '@deriv/components';
import { extractInfoFromShortcode, isForwardStarting, urlFor, website_name, getContractPath } from '@deriv/shared';
import { extractInfoFromShortcode, isForwardStarting, getUnsupportedContracts, getContractPath } from '@deriv/shared';
import { localize, Localize } from '@deriv/translations';
import { ReportsTableRowLoader } from '../Components/Elements/ContentLoader';
import { getSupportedContracts } from '_common/contract';
Expand Down Expand Up @@ -52,31 +52,21 @@ const DetailsComponent = ({ message = '', action_type = '' }) => {
);
};

const statementws_href = urlFor('user/statementws', { legacy: true });

const getRowAction = row_obj => {
let action;
if (row_obj.id && ['buy', 'sell'].includes(row_obj.action_type)) {
const contract_type = extractInfoFromShortcode(row_obj.shortcode).category.toUpperCase();
action =
getSupportedContracts()[extractInfoFromShortcode(row_obj.shortcode).category.toUpperCase()] &&
getSupportedContracts()[contract_type] &&
!isForwardStarting(row_obj.shortcode, row_obj.purchase_time || row_obj.transaction_time)
? getContractPath(row_obj.id)
: {
component: (
<Localize
i18n_default_text='This trade type is currently not supported on {{website_name}}. Please go to <0>Binary.com</0> for details.'
i18n_default_text="The {{trade_type_name}} contract details aren't currently available. We're working on making them available soon."
values={{
website_name,
trade_type_name: getUnsupportedContracts()[contract_type]?.name,
}}
components={[
<a
key={0}
className='link link--orange'
rel='noopener noreferrer'
target='_blank'
href={statementws_href}
/>,
]}
/>
),
};
Expand Down
34 changes: 17 additions & 17 deletions packages/shared/src/utils/constants/contract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,71 +319,71 @@ export const getMarketNamesMap = () => ({

export const getUnsupportedContracts = () => ({
EXPIRYMISS: {
name: <Localize i18n_default_text='Ends Outside' />,
name: localize('Ends Outside'),
position: 'top',
},
EXPIRYRANGE: {
name: <Localize i18n_default_text='Ends Between' />,
name: localize('Ends Between'),
position: 'bottom',
},
RANGE: {
name: <Localize i18n_default_text='Stays Between' />,
name: localize('Stays Between'),
position: 'top',
},
UPORDOWN: {
name: <Localize i18n_default_text='Goes Outside' />,
name: localize('Goes Outside'),
position: 'bottom',
},
RESETCALL: {
name: <Localize i18n_default_text='Reset Call' />,
name: localize('Reset Call'),
position: 'top',
},
RESETPUT: {
name: <Localize i18n_default_text='Reset Put' />,
name: localize('Reset Put'),
position: 'bottom',
},
TICKHIGH: {
name: <Localize i18n_default_text='High Tick' />,
name: localize('High Tick'),
position: 'top',
},
TICKLOW: {
name: <Localize i18n_default_text='Low Tick' />,
name: localize('Low Tick'),
position: 'bottom',
},
ASIANU: {
name: <Localize i18n_default_text='Asian Up' />,
name: localize('Asian Up'),
position: 'top',
},
ASIAND: {
name: <Localize i18n_default_text='Asian Down' />,
name: localize('Asian Down'),
position: 'bottom',
},
LBFLOATCALL: {
name: <Localize i18n_default_text='Close-to-Low' />,
name: localize('Close-to-Low'),
position: 'top',
},
LBFLOATPUT: {
name: <Localize i18n_default_text='High-to-Close' />,
name: localize('High-to-Close'),
position: 'top',
},
LBHIGHLOW: {
name: <Localize i18n_default_text='High-to-Low' />,
name: localize('High-to-Low'),
position: 'top',
},
CALLSPREAD: {
name: <Localize i18n_default_text='Spread Up' />,
name: localize('Spread Up'),
position: 'top',
},
PUTSPREAD: {
name: <Localize i18n_default_text='Spread Down' />,
name: localize('Spread Down'),
position: 'bottom',
},
RUNHIGH: {
name: <Localize i18n_default_text='Only Ups' />,
name: localize('Only Ups'),
position: 'top',
},
RUNLOW: {
name: <Localize i18n_default_text='Only Downs' />,
name: localize('Only Downs'),
position: 'bottom',
},
});
Expand Down

1 comment on commit f489cf7

@vercel
Copy link

@vercel vercel bot commented on f489cf7 Mar 31, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

deriv-app – ./

binary.sx
deriv-app.binary.sx
deriv-app-git-master.binary.sx
deriv-app.vercel.app

Please sign in to comment.