Skip to content

Commit

Permalink
update feature_branch with master (#9220)
Browse files Browse the repository at this point in the history
* fix: close account message doesn't show up (#9210)

Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>

* Jim/WEBREL-667/fix-bug-revealed-during-ts-migration (#9216)

* revert: revert code changes

* fix: fix bug revealed during ts migration

* chore: add test cases for line changed

---------

Co-authored-by: Niloofar Sadeghi <93518187+niloofar-deriv@users.noreply.github.com>
Co-authored-by: niloofar sadeghi <niloofar.sadeghi@re-work.dev>
Co-authored-by: Jim Daniels Wasswa <104334373+jim-deriv@users.noreply.github.com>
  • Loading branch information
4 people committed Jul 4, 2023
1 parent cb17414 commit 7205738
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { TSchema, regex_checks } from '@deriv/shared';
import { transformConfig } from 'Configs/address-details-config';

describe('address-details-config', () => {
let address_details_config: TSchema;
beforeEach(() => {
const account_settings = {
address_state: 'test',
};
address_details_config = {
address_state: {
supported_in: ['svg', 'iom', 'malta', 'maltainvest'],
default_value: account_settings.address_state,
rules: [
['req', 'State is required'],
[
'regular',
'State is not in a proper format',
{
regex: regex_checks.address_details.address_state,
},
],
],
},
};
});
it('should remove the required rule for non-eu clients', () => {
const transformed_config = transformConfig(address_details_config, 'svg');
expect(transformed_config.address_state.rules).not.toContainEqual(['req', 'State is required']);
});
it('should remove the required rule for eu clients', () => {
const transformed_config = transformConfig(address_details_config, 'maltainvest');
expect(transformed_config.address_state.rules).not.toContainEqual(['req', 'State is required']);
});
});
10 changes: 7 additions & 3 deletions packages/account/src/Configs/address-details-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,13 @@ const transformForResidence = (rules: TSchema, residence: string) => {
return rules;
};

const transformConfig = (config: TSchema, real_account_signup_target: string) => {
// Remove required rule for svg clients
if (!real_account_signup_target || real_account_signup_target === 'svg') {
export const transformConfig = (config: TSchema, real_account_signup_target: string) => {
// Remove required rule for svg clients and maltainvest clients
if (
!real_account_signup_target ||
real_account_signup_target === 'svg' ||
real_account_signup_target === 'maltainvest'
) {
config.address_state.rules?.shift();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Modal, Text } from '@deriv/components';
import { routes, getStaticUrl, PlatformContext } from '@deriv/shared';
import { Localize } from '@deriv/translations';
import { getStaticUrl, PlatformContext } from '@deriv/shared';
import { connect } from 'Stores/connect';
import { TCoreStore } from 'Stores/index';

const AccountClosed = ({ logout }) => {
type TAccountClosed = {
logout: () => void;
};

const AccountClosed = ({ logout }: TAccountClosed) => {
const [is_modal_open, setModalState] = React.useState(true);
const [timer, setTimer] = React.useState(10);
const { is_appstore } = React.useContext(PlatformContext);
const history = useHistory();

const counter = React.useCallback(() => {
if (timer > 0) {
Expand All @@ -20,7 +23,7 @@ const AccountClosed = ({ logout }) => {
}, [is_appstore, timer]);

React.useEffect(() => {
history.push(routes.root);
window.history.pushState(null, '', '/');
logout();
const handleInterval = setInterval(() => counter(), 1000);
return () => {
Expand All @@ -42,6 +45,6 @@ const AccountClosed = ({ logout }) => {
);
};

export default connect(({ client }) => ({
export default connect(({ client }: TCoreStore) => ({
logout: client.logout,
}))(AccountClosed);

0 comments on commit 7205738

Please sign in to comment.