Skip to content

Commit

Permalink
Merge branch 'master' into Agrim/user-id-missing
Browse files Browse the repository at this point in the history
  • Loading branch information
agrim-deriv committed Nov 25, 2024
2 parents 28dbe39 + 594997b commit 356e856
Show file tree
Hide file tree
Showing 392 changed files with 3,197 additions and 10,685 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,39 @@ on:
- master
pull_request:
types: [opened, synchronize, edited]
name: Coveralls
name: Reporter
jobs:
build:
name: Reporter
test:
name: Run tests in parallel
runs-on: Runner_16cores_Deriv-app
strategy:
matrix:
shard: [1,2,3,4,5,6,7,8,9,10]
fail-fast: true
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Setup Node
uses: './.github/actions/setup_node'
- name: Install dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Build
uses: "./.github/actions/build"
- name: Build components package
working-directory: packages/components
run: npm run build
- name: Test
run: JEST_MAX_WORKERS=95% npm run test:jest -- --collectCoverage
- name: Coveralls
run: JEST_MAX_WORKERS=95% SHARD_INDEX=${{ matrix.shard }} SHARD_COUNT=10 npm run test:shard -- --collectCoverage
- name: Coveralls Parallel
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
flag-name: ${{ matrix.shard}}
parallel: true

finish:
name: Coveralls Finished
needs: [test]
runs-on: Runner_16cores_Deriv-app
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@3dfc5567390f6fa9267c0ee9c251e4c8c3f18949
with:
parallel-finished: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository contains the various platforms of the Deriv application.
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
![Sonar Tech Debt](https://img.shields.io/sonar/tech_debt/binary-com_deriv-app?server=https%3A%2F%2Fsonarcloud.io)
![Sonar Violations (short format)](https://img.shields.io/sonar/violations/binary-com_deriv-app?server=https%3A%2F%2Fsonarcloud.io)
[![Coverage Status](https://coveralls.io/repos/github/binary-com/deriv-app/badge.svg?branch=master)](https://coveralls.io/github/binary-com/deriv-app?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/deriv-com/deriv-app/badge.svg?branch=master)](https://coveralls.io/github/deriv-com/deriv-app?branch=master)

**In this document**:

Expand Down
13 changes: 7 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"test": "f () { npm run test:stylelint && npm run test:eslint-all && npm run test:jest ;}; f",
"test:stylelint": "stylelint \"./packages/*/src/**/*.s(a|c)ss\"",
"test:ci": "f () { npm run test:stylelint && npm run test:eslint-all ;}; f",
"test:shard": "jest --all --shard=${SHARD_INDEX}/${SHARD_COUNT} --maxWorkers=${JEST_MAX_WORKERS:-'50%'}",
"test:jest": "jest --all --maxWorkers=${JEST_MAX_WORKERS:-'50%'}",
"test:performance": "cd e2e-tests && jest -c ./jest.config.js --detectOpenHandles performance",
"stylelint:fix": "stylelint \"./packages/*/src/**/*.s(a|c)ss\" --fix",
Expand Down
13 changes: 9 additions & 4 deletions packages/account/src/Configs/user-profile-validation-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { localize } from '@deriv-com/translations';
import dayjs from 'dayjs';
import * as Yup from 'yup';

import { localize } from '@deriv-com/translations';
import { ValidationConstants } from '@deriv-com/utils';
import dayjs from 'dayjs';

import { TEmployeeDetailsTinValidationConfig } from '../Types';

const {
Expand All @@ -25,6 +27,7 @@ type TINDepdendents = {
*/
is_tin_auto_set?: boolean;
is_employment_status_tin_mandatory?: boolean;
is_required_for_tax_residence?: boolean;
};

Yup.addMethod(Yup.string, 'validatePhoneNumberLength', function (message) {
Expand All @@ -44,14 +47,15 @@ const makeTinOptional = ({
tin_skipped,
is_tin_auto_set,
is_employment_status_tin_mandatory,
is_required_for_tax_residence,
}: TINDepdendents) => {
const check_if_tin_skipped = tin_skipped && !is_tin_auto_set;
if (is_real) {
// Students and unemployed are not required to provide TIN to have a regulated MT5 jurisdiction
if (is_tin_auto_set && is_employment_status_tin_mandatory) {
if (is_tin_auto_set && !(is_employment_status_tin_mandatory && is_required_for_tax_residence)) {
return true;
}
return check_if_tin_skipped || !is_employment_status_tin_mandatory;
return check_if_tin_skipped || !(is_employment_status_tin_mandatory && is_required_for_tax_residence);
}
// Check For Virtual account
if (is_mf) {
Expand Down Expand Up @@ -95,6 +99,7 @@ export const getEmploymentAndTaxValidationSchema = ({
tin_skipped,
is_tin_auto_set,
is_employment_status_tin_mandatory,
is_required_for_tax_residence: Boolean(tin_config?.is_tin_mandatory),
}),
then: Yup.string().notRequired(),
otherwise: Yup.string().required(localize('Tax identification number is required.')),
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/Constants/file-uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getFileUploaderDescriptions = (page: string, is_eu?: boolean): TFil
const proof_of_address_descriptions = {
title: (
<Localize
i18n_default_text='We accept only the following documents as proof of address. The document must be issued within the last {{expiry_in_months}} months and include your full name and address:'
i18n_default_text='Upload an original (unaltered) document that clearly shows your name and address, issued within the past {{expiry_in_months}} months. We accept:'
values={{ expiry_in_months: is_eu ? 6 : 12 }}
/>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ type PageOverlayWrapperProps = {
*/
const PageOverlayWrapper = observer(({ routes, subroutes }: PageOverlayWrapperProps) => {
const history = useHistory();
const { client, common } = useStore();
const { client, common, ui } = useStore();
const { logout } = client;
const { is_from_derivgo } = common;
const { setIsForcedToExitPnv } = ui;
const { isDesktop } = useDevice();

const passkeysMenuCloseActionEventTrack = React.useCallback(() => {
Expand Down Expand Up @@ -54,6 +55,11 @@ const PageOverlayWrapper = observer(({ routes, subroutes }: PageOverlayWrapperPr
const selected_route = getSelectedRoute({ routes: subroutes, pathname: location.pathname });

const onClickLogout = async () => {
if (window.location.pathname.startsWith(shared_routes.phone_verification)) {
setIsForcedToExitPnv(true);
// Add a small delay to ensure state is updated before navigation because adding await doesn't work here
await new Promise(resolve => setTimeout(resolve, 0));
}
history.push(shared_routes.traders_hub);
await logout();
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { FormikValues, useFormikContext } from 'formik';

import { TinValidations } from '@deriv/api/types';
import { Checkbox, useOnClickOutside } from '@deriv/components';
import { useResidenceList } from '@deriv/hooks';
import { getLegalEntityName } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { Localize } from '@deriv-com/translations';
import { useDevice } from '@deriv-com/ui';

import {
EmploymentStatusField,
TaxIdentificationNumberField,
TaxResidenceField,
} from '../../Components/forms/form-fields';
import { isFieldImmutable } from '../../Helpers/utils';
import { Checkbox, useOnClickOutside } from '@deriv/components';
import { Localize } from '@deriv-com/translations';
import { getLegalEntityName } from '@deriv/shared';
import { useDevice } from '@deriv-com/ui';
import { useResidenceList } from '@deriv/hooks';

import './employment-tax-details-container.scss';
import { TinValidations } from '@deriv/api/types';
import { observer, useStore } from '@deriv/stores';

type TEmploymentTaxDetailsContainerProps = {
editable_fields: string[];
Expand Down Expand Up @@ -41,7 +44,7 @@ const EmploymentTaxDetailsContainer = observer(

const { is_virtual, account_settings, account_status } = client;

const { tin_employment_status_bypass } = tin_validation_config;
const { tin_employment_status_bypass, is_tin_mandatory } = tin_validation_config;

const is_employment_status_mandatory = is_virtual
? true
Expand Down Expand Up @@ -196,7 +199,10 @@ const EmploymentTaxDetailsContainer = observer(
is_tin_popover_open={is_tin_popover_open}
setIsTinPopoverOpen={setIsTinPopoverOpen}
setIsTaxResidencePopoverOpen={setIsTaxResidencePopoverOpen}
required={(should_display_long_message && !values.tin_skipped) || is_tin_required}
required={
(should_display_long_message && !values.tin_skipped) ||
(is_tin_required && is_tin_mandatory)
}
fieldFocused={
should_focus_fields &&
values.employment_status &&
Expand Down
6 changes: 5 additions & 1 deletion packages/api-v2/src/APIProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ const APIProvider = ({ children }: PropsWithChildren<TAPIProviderProps>) => {
if (reconnect) {
connectionRef.current = initializeConnection(
() => {
reconnectTimerId = setTimeout(() => setReconnect(true), 500);
reconnectTimerId = setTimeout(() => {
if (isMounted.current) {
setReconnect(true);
}
}, 500);
},
() => {
if (!connectionRef.current) {
Expand Down
20 changes: 13 additions & 7 deletions packages/api-v2/src/hooks/useTradingPlatformStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CFD_PLATFORMS } from '@deriv/shared';
import { useCallback } from 'react';
import useAuthorizedQuery from '../useAuthorizedQuery';
import useQuery from '../useQuery';

Expand All @@ -24,14 +25,19 @@ const useTradingPlatformStatus = () => {
* @param platform The platform identifier (e.g., 'ctrader', 'dxtrade', 'mt5').
* @returns The status of the identified platform ('active', 'maintenance', 'unavailable').
*/
const getPlatformStatus = (platform: string) => {
const platformStatus =
platform === CFD_PLATFORMS.MT5 || platform === CFD_PLATFORMS.DXTRADE || platform === CFD_PLATFORMS.CTRADER
? tradingPlatformStatusData?.find((status: TPlatformStatus) => status.platform === platform)?.status
: undefined; // cashier may pass non-cfd platform (i.e. doughflow, p2p, paymentagent, etc) which doesn't have status property
const getPlatformStatus = useCallback(
(platform: string) => {
const platformStatus =
platform === CFD_PLATFORMS.MT5 ||
platform === CFD_PLATFORMS.DXTRADE ||
platform === CFD_PLATFORMS.CTRADER
? tradingPlatformStatusData?.find((status: TPlatformStatus) => status.platform === platform)?.status
: undefined; // cashier may pass non-cfd platform (i.e. doughflow, p2p, paymentagent, etc) which doesn't have status property

return platformStatus;
};
return platformStatus;
},
[tradingPlatformStatusData]
);

return {
...rest,
Expand Down
18 changes: 14 additions & 4 deletions packages/api/src/hooks/useRemoteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { ObjectUtils } from '@deriv-com/utils';
import initData from '../remote_config.json';

Expand All @@ -17,22 +17,32 @@ const remoteConfigQuery = async function () {

function useRemoteConfig(enabled = false) {
const [data, setData] = useState(initData);
const isMounted = useRef(false);

useEffect(() => {
enabled &&
isMounted.current = true;

return () => {
isMounted.current = false;
};
}, []);

useEffect(() => {
if (enabled) {
remoteConfigQuery()
.then(async res => {
const resHash = await ObjectUtils.hashObject(res);
const dataHash = await ObjectUtils.hashObject(data);
if (resHash !== dataHash) {
if (resHash !== dataHash && isMounted.current) {
setData(res);
}
})
.catch(error => {
// eslint-disable-next-line no-console
console.log('Remote Config error: ', error);
});
}, [enabled]);
}
}, [enabled, data]);

return { data };
}
Expand Down
1 change: 1 addition & 0 deletions packages/appstore/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'\\.s(c|a)ss$': '<rootDir>/../../__mocks__/styleMock.js',
'^.+\\.svg$': '<rootDir>/../../__mocks__/fileMock.js',
'@deriv-com/translations': '<rootDir>/../../__mocks__/translation.mock.js',
'^@deriv/account$': '<rootDir>/../account/src',
'@deriv-com/ui': '<rootDir>/../../__mocks__/deriv-com.ui.mock.js',
'^Assets/(.*)$': '<rootDir>/src/assets/$1',
'^Components/(.*)$': '<rootDir>/src/components/$1',
Expand Down
Loading

0 comments on commit 356e856

Please sign in to comment.