Skip to content

Commit

Permalink
Merge branch 'master' into feature/wallets_with_traders_hub
Browse files Browse the repository at this point in the history
  • Loading branch information
nijil-deriv committed Jul 18, 2023
2 parents 9815fe4 + dfa6dbf commit 991f643
Show file tree
Hide file tree
Showing 74 changed files with 832 additions and 348 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
build_and_test:
docker:
- image: cimg/node:18.16.0
resource_class: large
resource_class: xlarge
steps:
- git_checkout_from_cache
- npm_install_from_cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/automationrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"skip_pending_checks": false,
"skip_slack_integration": false,
"skip_updating_branch": true,
"merge_delay": 120000,
"skip_updating_branch": false,
"merge_delay": 1200000,
"first_merge_delay": 1200000,
"max_task_count": 15,
"pull_request": {
Expand Down
3 changes: 1 addition & 2 deletions packages/account/build/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ const {
js_loaders,
svg_file_loaders,
svg_loaders,
IS_RELEASE,
} = require('./loaders-config');

const IS_RELEASE = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging';

const ALIASES = {
Assets: path.resolve(__dirname, '../src/Assets'),
Components: path.resolve(__dirname, '../src/Components'),
Expand Down
4 changes: 3 additions & 1 deletion packages/account/build/loaders-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { IS_RELEASE } = require('./constants');

const IS_RELEASE = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'staging';

const js_loaders = [
{
Expand Down Expand Up @@ -107,4 +108,5 @@ module.exports = {
svg_loaders,
svg_file_loaders,
css_loaders,
IS_RELEASE,
};
5 changes: 2 additions & 3 deletions packages/account/src/Components/forms/form-fields.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ export const DateOfBirthField = ({ name, portal_id, ...rest }) => (
</Field>
);

export const FormInputField = ({ name, optional = false, warn, ...props }) => (
export const FormInputField = ({ name, optional = false, warn, ...rest }) => (
<Field name={name}>
{({ field, form: { errors, touched } }) => (
<Input
type='text'
required={!optional}
autoComplete='off'
maxLength={props.maxLength || 30}
error={touched[field.name] && errors[field.name]}
warn={warn}
{...field}
{...props}
{...rest}
/>
)}
</Field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import PoiButton from 'Components/poi/poi-button';
import React from 'react';
import { TPoaStatusProps } from 'Types';
import { localize } from '@deriv/translations';
import { isNavigationFromP2P, isNavigationFromDerivGO } from '@deriv/shared';

export const NeedsReview = ({ needs_poi, redirect_button }: TPoaStatusProps) => {
const message = localize('Your proof of address was submitted successfully');
const is_redirected_from_platform = isNavigationFromP2P() || isNavigationFromDerivGO();
if (!needs_poi) {
return (
<IconMessageContent
message={message}
text={localize('Your document is being reviewed, please check back in 1-3 days.')}
icon={<Icon icon='IcPoaVerified' size={128} />}
>
{redirect_button || <ContinueTradingButton />}
{redirect_button || (!is_redirected_from_platform && <ContinueTradingButton />)}
</IconMessageContent>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import classNames from 'classnames';
import { Icon, Text } from '@deriv/components';
import { localize } from '@deriv/translations';
import { PlatformContext } from '@deriv/shared';
import { PlatformContext, isNavigationFromP2P, isNavigationFromDerivGO } from '@deriv/shared';
import { TPoaStatusProps } from 'Types';
import { ContinueTradingButton } from 'Components/poa/continue-trading-button/continue-trading-button';
import PoiButton from 'Components/poi/poi-button';
Expand All @@ -11,6 +11,7 @@ import IconMessageContent from 'Components/icon-message-content';
export const Submitted = ({ needs_poi, redirect_button }: TPoaStatusProps) => {
const { is_appstore } = React.useContext(PlatformContext);
const message = localize('Your documents were submitted successfully');
const is_redirected_from_platform = isNavigationFromP2P() || isNavigationFromDerivGO();
if (needs_poi) {
return (
<div
Expand Down Expand Up @@ -48,7 +49,7 @@ export const Submitted = ({ needs_poi, redirect_button }: TPoaStatusProps) => {
icon={<Icon icon='IcPoaVerified' size={128} />}
full_width={is_appstore}
>
{redirect_button || <ContinueTradingButton />}
{redirect_button || (!is_redirected_from_platform && <ContinueTradingButton />)}
</IconMessageContent>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TPoaStatusProps } from 'Types';
import { ContinueTradingButton } from 'Components/poa/continue-trading-button/continue-trading-button';
import { Icon } from '@deriv/components';
import IconMessageContent from 'Components/icon-message-content';
import { PlatformContext } from '@deriv/shared';
import { PlatformContext, isNavigationFromP2P, isNavigationFromDerivGO } from '@deriv/shared';
import { PoiButton } from 'Components/poi/poi-button/poi-button';
import React from 'react';
import classNames from 'classnames';
Expand All @@ -13,6 +13,7 @@ export const Verified = ({ needs_poi, redirect_button }: TPoaStatusProps) => {
const { is_appstore } = React.useContext(PlatformContext);

const message = localize('Your proof of address is verified');
const is_redirected_from_platform = isNavigationFromP2P() || isNavigationFromDerivGO();
if (needs_poi) {
return (
<div
Expand Down Expand Up @@ -42,7 +43,7 @@ export const Verified = ({ needs_poi, redirect_button }: TPoaStatusProps) => {
icon={<Icon icon='IcPoaVerified' size={128} />}
className={classNames({ 'account-management-dashboard': is_appstore })}
>
{redirect_button || <ContinueTradingButton />}
{redirect_button || (!is_redirected_from_platform && <ContinueTradingButton />)}
</IconMessageContent>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import { Field, FormikProps, FormikValues } from 'formik';
import { Field, FieldProps, FormikProps, FormikValues } from 'formik';
import { localize } from '@deriv/translations';
import { isMobile, supported_filetypes, max_document_size } from '@deriv/shared';
import { Button, Icon, Text, FileDropzone } from '@deriv/components';
Expand All @@ -21,7 +21,7 @@ type TUploader = {
has_frame: boolean;
onChange: (e: unknown) => void;
setFieldValue: FormikProps<FormikValues>['setFieldValue'];
handleChange: (file: object | null, setFieldValue?: FormikProps<FormikValues>['setFieldValue']) => void;
handleChange: (file: object | null, setFieldValue: FormikProps<FormikValues>['setFieldValue']) => void;
};

type TMessage = {
Expand Down Expand Up @@ -101,17 +101,17 @@ const Uploader = ({ data, value, is_full, onChange, has_frame }: Partial<TUpload
setImage(value);
}, [value]);

const handleChange = (file?: object, setFieldValue?: FormikProps<FormikValues>['setFieldValue']) => {
const handleChange = (file: object | null, setFieldValue: FormikProps<FormikValues>['setFieldValue']) => {
onChange?.(file);
setFieldValue?.(data?.name, file);
};

const handleAccept = (files: object[], setFieldValue: () => void) => {
const handleAccept = (files: object[], setFieldValue: FormikProps<FormikValues>['setFieldValue']) => {
const file = { file: files[0], errors: [], ...data };
handleChange(file, setFieldValue);
};

const handleReject = (files: THandleRejectFiles, setFieldValue: () => void) => {
const handleReject = (files: THandleRejectFiles, setFieldValue: FormikProps<FormikValues>['setFieldValue']) => {
const errors = files[0].errors?.map((error: { code: string }) =>
DROPZONE_ERRORS[error.code as keyof TDROPZONE_ERRORS]
? DROPZONE_ERRORS[error.code as keyof TDROPZONE_ERRORS]
Expand Down Expand Up @@ -139,7 +139,7 @@ const Uploader = ({ data, value, is_full, onChange, has_frame }: Partial<TUpload

return (
<Field name={data?.name}>
{({ form: { setFieldValue } }: FormikValues) => (
{({ form: { setFieldValue } }: FieldProps) => (
<div
className={classNames(`${ROOT_CLASS}__uploader`, {
[`${ROOT_CLASS}__uploader--full`]: is_full,
Expand All @@ -159,7 +159,7 @@ const Uploader = ({ data, value, is_full, onChange, has_frame }: Partial<TUpload
value={image}
has_frame={has_frame}
setFieldValue={setFieldValue}
handleChange={() => handleChange()}
handleChange={handleChange}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Icon, Text } from '@deriv/components';
import { PlatformContext } from '@deriv/shared';
import { PlatformContext, isNavigationFromP2P, isNavigationFromDerivGO } from '@deriv/shared';
import { localize } from '@deriv/translations';
import PoaButton from 'Components/poa/poa-button';
import { ContinueTradingButton } from 'Components/poa/continue-trading-button/continue-trading-button';
Expand All @@ -20,6 +20,8 @@ export const UploadComplete = ({
? localize('We’ll review your documents and notify you of its status within 1 - 3 working days.')
: localize('We’ll review your documents and notify you of its status within 5 minutes.');

const is_redirected_from_platform = isNavigationFromP2P() || isNavigationFromDerivGO();

if (!needs_poa) {
return (
<IconMessageContent
Expand All @@ -34,7 +36,7 @@ export const UploadComplete = ({
}
className={classNames({ 'account-management-dashboard': is_appstore })}
>
{!is_from_external && (redirect_button || <ContinueTradingButton />)}
{!is_from_external && (redirect_button || (!is_redirected_from_platform && <ContinueTradingButton />))}
</IconMessageContent>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { localize } from '@deriv/translations';
export const Verified = ({ needs_poa, redirect_button, is_from_external }: TPOIStatus) => {
const { is_appstore } = React.useContext<TPlatformContext>(PlatformContext);
const message = localize('Your proof of identity is verified');

if (!needs_poa) {
return (
<IconMessageContent
Expand Down
36 changes: 17 additions & 19 deletions packages/account/src/Containers/account.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import 'Styles/account.scss';
import { PlatformContext, getSelectedRoute, isMobile, matchRoute, routes as shared_routes } from '@deriv/shared';
import {
PlatformContext,
getSelectedRoute,
getStaticUrl,
isMobile,
matchRoute,
routes as shared_routes,
} from '@deriv/shared';
import PropTypes from 'prop-types';
import React from 'react';
import { withRouter } from 'react-router-dom';
import { VerticalTab, FadeWrapper, PageOverlay, Loading, Text, Icon } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { flatten } from '../Helpers/flatten';
import { localize } from '@deriv/translations';
import { useHistory } from 'react-router';

const onClickLogout = (logout, history) => {
history.push(shared_routes.index);
logout().then(() => (window.location.href = getStaticUrl('/')));
};

const AccountLogout = ({ logout, history }) => {
return (
<div
className='dc-vertical-tab__header account__logout '
onClick={() => {
history.push(shared_routes.index);
logout();
}}
>
<div className='dc-vertical-tab__header account__logout ' onClick={() => onClickLogout(logout, history)}>
<div className='dc-vertical-tab__header-group account__logout-tab'>
<Text size='xxs' weight='normal'>
{localize('Log out')}
Expand All @@ -27,16 +32,9 @@ const AccountLogout = ({ logout, history }) => {
);
};

const TradingHubLogout = ({ logout }) => {
const history = useHistory();
const TradingHubLogout = ({ logout, history }) => {
return (
<div
className='dc-vertical-tab__header-account__logout-tab'
onClick={() => {
logout();
history.push(shared_routes.index);
}}
>
<div className='dc-vertical-tab__header-account__logout-tab' onClick={() => onClickLogout(logout, history)}>
<div className='dc-vertical-tab__header-account__logout'>
<Icon icon='IcLogout' className='dc-vertical-tab__header-account__logout--icon' />
<Text size='xs' weight='bold'>
Expand Down Expand Up @@ -97,7 +95,7 @@ const PageOverlayWrapper = ({
is_full_width
list={subroutes}
list_groups={list_groups}
extra_content={<TradingHubLogout logout={logout} />}
extra_content={<TradingHubLogout logout={logout} history={history} />}
/>
</PageOverlay>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ProofOfAddressContainer = ({

const from_platform = getPlatformRedirect(app_routing_history);

const should_show_redirect_btn = Object.keys(platforms).includes(from_platform.ref);
const should_show_redirect_btn = Object.keys(platforms).includes(from_platform?.ref);

const redirect_button = should_show_redirect_btn ? (
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ProofOfIdentityContainer = ({

const from_platform = getPlatformRedirect(app_routing_history);

const should_show_redirect_btn = Object.keys(platforms).includes(from_platform.ref);
const should_show_redirect_btn = Object.keys(platforms).includes(from_platform?.ref);

const routeBackTo = redirect_route => routeBackInApp(history, [redirect_route]);
const handleRequireSubmission = () => setHasRequireSubmission(true);
Expand Down
29 changes: 27 additions & 2 deletions packages/appstore/src/components/containers/trading-app-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ import classNames from 'classnames';
import { getStatusBadgeConfig } from '@deriv/account';
import { Text, StatusBadge } from '@deriv/components';
import TradigPlatformIconProps from 'Assets/svgs/trading-platform';
import { getAppstorePlatforms, getMFAppstorePlatforms, BrandConfig } from 'Constants/platform-config';
import {
getAppstorePlatforms,
getMFAppstorePlatforms,
BrandConfig,
DERIV_PLATFORM_NAMES,
} from 'Constants/platform-config';
import TradingAppCardActions, { Actions } from './trading-app-card-actions';
import { AvailableAccount, TDetailsOfEachMT5Loginid } from 'Types';
import { useStores } from 'Stores/index';
import { observer } from 'mobx-react-lite';
import { localize } from '@deriv/translations';
import { CFD_PLATFORMS, ContentFlag, getStaticUrl } from '@deriv/shared';
import { CFD_PLATFORMS, ContentFlag, getStaticUrl, getUrlSmartTrader, getUrlBinaryBot } from '@deriv/shared';
import './trading-app-card.scss';

type TWalletsProps = {
Expand Down Expand Up @@ -62,6 +67,26 @@ const TradingAppCard = ({
);

const openStaticPage = () => {
if (is_deriv_platform) {
switch (name) {
case DERIV_PLATFORM_NAMES.TRADER:
window.open(getStaticUrl(`/dtrader`));
break;
case DERIV_PLATFORM_NAMES.DBOT:
window.open(getStaticUrl(`/dbot`));
break;
case DERIV_PLATFORM_NAMES.SMARTTRADER:
window.open(getUrlSmartTrader());
break;
case DERIV_PLATFORM_NAMES.BBOT:
window.open(getUrlBinaryBot());
break;
case DERIV_PLATFORM_NAMES.GO:
window.open(getStaticUrl('/deriv-go'));
break;
default:
}
}
if (platform === CFD_PLATFORMS.MT5 && availability === 'EU')
window.open(getStaticUrl(`/dmt5`, {}, false, true));
else if (platform === CFD_PLATFORMS.MT5 && availability !== 'EU') window.open(getStaticUrl(`/dmt5`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const OptionsAndMultipliersListing = () => {
<TradingAppCard
key={`trading_app_card_${available_platform.name}`}
{...available_platform}
clickable_icon
action_type={
is_demo || (!no_CR_account && !is_eu_user) || (has_maltainvest_account && is_eu_user)
? 'trade'
Expand Down
9 changes: 9 additions & 0 deletions packages/appstore/src/constants/platform-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ export const getMFAppstorePlatforms = (): MfPlatformConfig[] => [
link_to: routes.trade,
},
];

// The platform names were taken from packages/shared/brand.config.json
export const DERIV_PLATFORM_NAMES = {
TRADER: 'Deriv Trader',
DBOT: 'Deriv Bot',
SMARTTRADER: 'SmartTrader',
BBOT: 'Binary Bot',
GO: 'Deriv GO',
} as const;
Loading

0 comments on commit 991f643

Please sign in to comment.