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

+ Added support for legacy contracts #148

Merged
merged 2 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
51 changes: 51 additions & 0 deletions src/javascript/app/Constants/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,56 @@ const getContractConfig = is_high_low => ({
...getUnsupportedContracts(),
});

export const getSupportedContracts = is_high_low => ({
CALL: {
name : is_high_low ? localize('Higher') : localize('Rise'),
position: 'top',
},
PUT: {
name : is_high_low ? localize('Lower') : localize('Fall'),
position: 'bottom',
},
CALLE: {
name : localize('Rise'),
position: 'top',
},
PUTE: {
name : localize('Fall'),
position: 'bottom',
},
DIGITMATCH: {
name : localize('Matches'),
position: 'top',
},
DIGITDIFF: {
name : localize('Differs'),
position: 'bottom',
},
DIGITEVEN: {
name : localize('Even'),
position: 'top',
},
DIGITODD: {
name : localize('Odd'),
position: 'bottom',
},
DIGITOVER: {
name : localize('Over'),
position: 'top',
},
DIGITUNDER: {
name : localize('Under'),
position: 'bottom',
},
ONETOUCH: {
name : localize('Touch'),
position: 'top',
},
NOTOUCH: {
name : localize('No Touch'),
position: 'bottom',
},
});
negarn marked this conversation as resolved.
Show resolved Hide resolved

export const getContractTypeDisplay = (type, is_high_low = false) => (getContractConfig(is_high_low)[type] ? getContractConfig(is_high_low)[type].name : '');
export const getContractTypePosition = (type, is_high_low = false) => (getContractConfig(is_high_low)[type] ? getContractConfig(is_high_low)[type].position : 'top');
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { website_name } from 'App/Constants/app-config';
import DataTable from 'App/Components/Elements/DataTable';
import Localize from 'App/Components/Elements/localize.jsx';
import { getContractPath } from 'App/Components/Routes/helpers';
import { getUnsupportedContracts } from 'Constants';
import { getSupportedContracts } from 'Constants';
import { connect } from 'Stores/connect';
import EmptyTradeHistoryMessage from '../Components/empty-trade-history-message.jsx';
import PlaceholderComponent from '../Components/placeholder-component.jsx';
Expand All @@ -26,8 +26,9 @@ class ProfitTable extends React.Component {
}

getRowAction = (row_obj) => (
getUnsupportedContracts()[getMarketInformation(row_obj).category.toUpperCase()] ?
{
getSupportedContracts()[getMarketInformation(row_obj).category.toUpperCase()] ?
getContractPath(row_obj.contract_id)
: {
negarn marked this conversation as resolved.
Show resolved Hide resolved
component: (
<Localize
str='This trade type is currently not supported on [_1]. Please go to [_2]Binary.com[_3] for details.'
Expand All @@ -38,7 +39,6 @@ class ProfitTable extends React.Component {
/>
),
}
: getContractPath(row_obj.contract_id)
);

render () {
Expand Down
10 changes: 5 additions & 5 deletions src/javascript/app/Modules/Reports/Containers/statement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import DataTable from 'App/Components/Elements/DataTa
import Localize from 'App/Components/Elements/localize.jsx';
import { getContractPath } from 'App/Components/Routes/helpers';
import { website_name } from 'App/Constants/app-config';
import { getUnsupportedContracts } from 'Constants';
import { getSupportedContracts } from 'Constants';
import { connect } from 'Stores/connect';
import { getStatementTableColumnsTemplate } from '../Constants/data-table-constants';
import PlaceholderComponent from '../Components/placeholder-component.jsx';
Expand All @@ -29,8 +29,9 @@ class Statement extends React.Component {
let action;

if (row_obj.id && ['buy', 'sell'].includes(row_obj.action_type)) {
action = getUnsupportedContracts()[getMarketInformation(row_obj).category.toUpperCase()] ?
{
action = getSupportedContracts()[getMarketInformation(row_obj).category.toUpperCase()] ?
getContractPath(row_obj.id)
: {
negarn marked this conversation as resolved.
Show resolved Hide resolved
component: (
<Localize
str='This trade type is currently not supported on [_1]. Please go to [_2]Binary.com[_3] for details.'
Expand All @@ -40,8 +41,7 @@ class Statement extends React.Component {
}}
/>
),
}
: getContractPath(row_obj.id);
};
} else if (['deposit', 'withdrawal'].includes(row_obj.action_type)) {
action = {
message: row_obj.desc,
Expand Down
14 changes: 9 additions & 5 deletions src/javascript/app/Modules/Reports/Helpers/market-underyling.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
export const getMarketInformation = (payload) => {
const market_info = {
category : '',
underlying: '',
};

const pattern = new RegExp('^([A-Z]+)_((OTC_[A-Z0-9]+)|R_[\\d]{2,3}|[A-Z]+)_'); // Used to get market name from shortcode
const extracted = pattern.exec(payload.shortcode);
if (extracted !== null) {
return {
category : extracted[1].toLowerCase(),
underlying: extracted[2],
};
market_info.category = extracted[1].toLowerCase();
market_info.underlying = extracted[2];
}
return null;

return market_info;
};