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

Adding a notification for users to accept the updated T&Cs changes #16422

Merged
merged 48 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0a14a5f
chore: implement tnc update popup notification
utkarsha-deriv Aug 8, 2024
ac96676
test: added testcase for modal
utkarsha-deriv Aug 9, 2024
4e70611
fix: fix conflicts with master
utkarsha-deriv Aug 9, 2024
eac7502
fix: refactor testcase
utkarsha-deriv Aug 9, 2024
00184e7
fix: resolving comments
utkarsha-deriv Aug 9, 2024
3651635
fix: remove size
utkarsha-deriv Aug 9, 2024
acda862
fix: resolve comments for size and testcase
utkarsha-deriv Aug 9, 2024
8b2e49e
fix: resolving comments
utkarsha-deriv Aug 9, 2024
4b5c0c4
fix: move logic from client-store to hooks
utkarsha-deriv Aug 12, 2024
adbfcab
chore: merge master
utkarsha-deriv Aug 12, 2024
5034dcd
chore: fix type
utkarsha-deriv Aug 12, 2024
e765b66
test: add testcasepe
utkarsha-deriv Aug 12, 2024
e260b79
chore: add tnc_acceptance field to account creation(real/malta) api req
utkarsha-deriv Aug 15, 2024
9645c79
chore: empty commit
utkarsha-deriv Aug 16, 2024
546f01b
Merge branch 'master' into utkarsha/tnc_change
utkarsha-deriv Aug 16, 2024
db6ab60
Merge branch 'master' into utkarsha/TnC-for-new-account-creation
utkarsha-deriv Aug 16, 2024
1a524ec
fix: clone.tnc_acceptance condition fix
utkarsha-deriv Aug 16, 2024
8137b43
fix: fix === true in condition
utkarsha-deriv Aug 16, 2024
23f9c9c
Merge pull request #15 from utkarsha-deriv/utkarsha/TnC-for-new-accou…
utkarsha-deriv Aug 16, 2024
6c374fa
fix: resolve conflicts
yauheni-deriv Aug 26, 2024
b3fc20c
fix: resolve conflicts
yauheni-deriv Aug 28, 2024
d9e8656
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Aug 30, 2024
68c59f8
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 5, 2024
d7d6bd7
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 9, 2024
1678dd3
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 10, 2024
bb4af29
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 10, 2024
1e5abe2
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 10, 2024
0be41f3
refactor: remove old tnc logic
yauheni-deriv Sep 10, 2024
5fbc0d3
refactor: replace old tnc logic in wallets
yauheni-deriv Sep 11, 2024
e9e3bfa
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 11, 2024
66653e5
fix: usedepositlocked test
yauheni-deriv Sep 11, 2024
3aed293
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 11, 2024
67ad840
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 11, 2024
0d944b8
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 12, 2024
4c38382
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 13, 2024
ecd077d
fix: continue button does not close modal
yauheni-deriv Sep 13, 2024
9ccfe13
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 17, 2024
02e38dd
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 18, 2024
3bb87ad
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 18, 2024
d006f1d
fix: resolve conflicts
yauheni-deriv Sep 20, 2024
f65d873
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 23, 2024
ad24108
fix: logout after signup
yauheni-deriv Sep 23, 2024
c8be135
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 24, 2024
815015c
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 24, 2024
5b5e53f
Merge branch 'master' into utkarsha/tnc_change
yauheni-deriv Sep 27, 2024
e228e9b
refactor: update condition for useIsTNCNeeded, added documentation
yauheni-deriv Sep 27, 2024
2c640a2
Merge pull request #16 from yauheni-deriv/update_is_tns_neede_hook
yauheni-deriv Sep 27, 2024
9c79520
Merge branch 'master' into utkarsha/tnc_change
amina-deriv Oct 4, 2024
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
9 changes: 9 additions & 0 deletions packages/core/src/App/Containers/Modals/app-modals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const InformationSubmittedModal = React.lazy(() =>
import(/* webpackChunkName: "information-submitted-modal" */ './information-submitted-modal')
);

const TncStatusUpdateModal = React.lazy(() =>
import(/* webpackChunkName: "information-submitted-modal" */ './tnc-status-update-modal')
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
);

const AppModals = observer(() => {
const { client, ui, traders_hub } = useStore();
const {
Expand Down Expand Up @@ -109,6 +113,7 @@ const AppModals = observer(() => {
should_show_one_time_deposit_modal,
should_show_account_success_modal,
should_show_crypto_transaction_processing_modal,
is_tnc_update_modal_open,
} = ui;
const temp_session_signup_params = SessionStore.get('signup_query_param');
const url_params = new URLSearchParams(useLocation().search || temp_session_signup_params);
Expand Down Expand Up @@ -232,6 +237,10 @@ const AppModals = observer(() => {
if (is_kyc_information_submitted_modal_open) {
ComponentToLoad = <InformationSubmittedModal />;
}

if (is_tnc_update_modal_open) {
ComponentToLoad = <TncStatusUpdateModal />;
}
}

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { StoreProvider, mockStore } from '@deriv/stores';
import TncStatusUpdateModal from '../tnc-status-update-modal';
import userEvent from '@testing-library/user-event';
import { WS } from '@deriv/shared';

jest.mock('@deriv/shared', () => ({
...jest.requireActual('@deriv/shared'),
WS: {
tncApproval: jest.fn(() =>
Promise.resolve({
tnc_approval: {},
})
),
getSettings: jest.fn(() =>
Promise.resolve({
get_limits: {},
})
),
},
}));

describe('<TncStatusUpdateModal />', () => {
let modal_root_el: HTMLDivElement;

beforeAll(() => {
modal_root_el = document.createElement('div');
modal_root_el.setAttribute('id', 'modal_root');
document.body.appendChild(modal_root_el);
});

afterAll(() => {
document.body.removeChild(modal_root_el);
});

const mock_store = mockStore({
ui: {
is_tnc_update_modal_open: true,
toggleTncUpdateModal: jest.fn(),
},
});

const renderComponent = ({ store_config = mock_store }) => {
return render(
<StoreProvider store={store_config}>
<TncStatusUpdateModal />
</StoreProvider>
);
};

it('should not render the TncStatusUpdateModal component', async () => {
const mock = mockStore({
ui: {
is_tnc_update_modal_open: false,
},
});

renderComponent({ store_config: mock });
expect(screen.queryByText('Please review our updated terms and conditions')).not.toBeInTheDocument();
});

it('should render the TncStatusUpdateModal component', async () => {
renderComponent({});
expect(screen.getByText("Updated T&C's")).toBeInTheDocument();
});

it('should render TncStatusUpdateModal component with Messages and Button', async () => {
renderComponent({});
expect(screen.getByText("Updated T&C's")).toBeInTheDocument();
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
expect(screen.getByText('By continuing you understand and accept the changes.')).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Continue' })).toBeInTheDocument();
});

it('should render TncStatusUpdateModal click on Button to called toggle modal function', async () => {
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
renderComponent({});
const continue_button = screen.getByRole('button', { name: 'Continue' });
await userEvent.click(continue_button);
expect(WS.tncApproval).toBeCalled();
expect(WS.getSettings).toBeCalled();
expect(mock_store.ui.toggleTncUpdateModal).toHaveBeenCalledWith(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import TncStatusUpdateModal from './tnc-status-update-modal';

export default TncStatusUpdateModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.dc-modal__container_tnc-status-update-modal-wrapper {
padding: 24px;
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
@include mobile-screen {
padding: 16px;
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
}

.tnc-status-update-modal {
display: flex;
flex-direction: column;
gap: 24px;

&__header {
font-size: 1.6rem;
@include mobile-screen {
font-size: 1.4rem;
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
}

&__text-container {
display: flex;
flex-direction: column;
align-items: flex-start;
align-self: stretch;
.dc-text {
font-size: 1.4rem;
@include mobile-screen {
font-size: 1.2rem;
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

&__button {
align-self: flex-end;
}

@include mobile-screen {
gap: 16px;
}
}

.link {
text-decoration: underline;
font-weight: normal;
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { Modal, Button, StaticUrl, Text } from '@deriv/components';
import { Localize } from '@deriv/translations';
import { observer, useStore } from '@deriv/stores';
import { WS } from '@deriv/shared';
import './tnc-status-update-modal.scss';

const TncStatusUpdateModal = observer(() => {
const { client, ui } = useStore();
const { is_cr_account } = client;
const { is_tnc_update_modal_open, toggleTncUpdateModal } = ui;

const onClick = async () => {
await WS.tncApproval();
WS.getSettings();
toggleTncUpdateModal(false);
};

return (
<Modal
className='tnc-status-update-modal-wrapper'
is_open={is_tnc_update_modal_open}
has_close_icon={false}
width='440px'
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
>
<div className='tnc-status-update-modal'>
<Text size='s' weight='bold' className='tnc-status-update-modal__header'>
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Localize i18n_default_text="Updated T&C's" />
</Text>
<div className='tnc-status-update-modal__text-container'>
<Text as='xs'>
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Localize
i18n_default_text='Please review our updated <0>terms and conditions</0>.'
components={[
<StaticUrl
key={0}
className='link'
href='terms-and-conditions'
is_eu_url={!is_cr_account}
/>,
]}
/>
</Text>
<Text as='xs'>
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
<Localize i18n_default_text='By continuing you understand and accept the changes.' />
</Text>
</div>
<div className='tnc-status-update-modal__button'>
<Button className='dc-dialog__button' has_effect onClick={onClick} primary large>
<Localize i18n_default_text='Continue' />
</Button>
</div>
</div>
</Modal>
);
});

export default TncStatusUpdateModal;
9 changes: 9 additions & 0 deletions packages/core/src/Stores/client-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ export default class ClientStore extends BaseStore {
is_poa_expired: computed,
real_account_creation_unlock_date: computed,
is_tnc_needed: computed,
is_tnc_status_updated: computed,
is_social_signup: computed,
isEligibleForMoreDemoMt5Svg: action.bound,
isEligibleForMoreRealMt5: action.bound,
Expand Down Expand Up @@ -725,6 +726,11 @@ export default class ClientStore extends BaseStore {
return typeof client_tnc_status !== 'undefined' && client_tnc_status !== terms_conditions_version;
}

get is_tnc_status_updated() {
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
const { tnc_status } = this.account_settings || {};
return tnc_status;
}

get is_social_signup() {
return this.account_status?.status?.includes('social_signup');
}
Expand Down Expand Up @@ -1633,6 +1639,9 @@ export default class ClientStore extends BaseStore {
this.resetMt5AccountListPopulation();
}
this.responseWebsiteStatus(await WS.wait('website_status'));
if (this.is_tnc_status_updated?.landing_company_short === 0) {
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
utkarsha-deriv marked this conversation as resolved.
Show resolved Hide resolved
this.root_store.ui.toggleTncUpdateModal(true);
}

this.registerReactions();
this.setIsLoggingIn(false);
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/Stores/ui-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export default class UIStore extends BaseStore {
is_additional_kyc_info_modal_open = false;
is_kyc_information_submitted_modal_open = false;

// tnc update
is_tnc_update_modal_open = false;

getDurationFromUnit = unit => this[`duration_${unit}`];

constructor(root_store) {
Expand Down Expand Up @@ -287,6 +290,7 @@ export default class UIStore extends BaseStore {
is_verification_submitted: observable,
is_mt5_migration_modal_open: observable,
is_mt5_migration_modal_enabled: observable,
is_tnc_update_modal_open: observable,
isUrlUnavailableModalVisible: observable,
manage_real_account_tab_index: observable,
modal_index: observable,
Expand Down Expand Up @@ -424,6 +428,7 @@ export default class UIStore extends BaseStore {
toggleUrlUnavailableModal: action.bound,
setShouldShowDepositNowOrLaterModal: action.bound,
setShouldShowCryptoTransactionProcessingModal: action.bound,
toggleTncUpdateModal: action.bound,
});

window.addEventListener('resize', this.handleResize);
Expand Down Expand Up @@ -983,4 +988,8 @@ export default class UIStore extends BaseStore {
setShouldShowCryptoTransactionProcessingModal(value) {
this.should_show_crypto_transaction_processing_modal = value;
}

toggleTncUpdateModal(value) {
this.is_tnc_update_modal_open = value;
}
}
3 changes: 3 additions & 0 deletions packages/stores/src/mockStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ const mock = (): TStores & { is_mock: boolean } => {
is_mf_account: false,
is_tradershub_tracking: false,
setTradersHubTracking: jest.fn(),
is_tnc_status_updated: {},
},
common: {
error: common_store_error,
Expand Down Expand Up @@ -481,6 +482,8 @@ const mock = (): TStores & { is_mock: boolean } => {
setShouldShowDepositNowOrLaterModal: jest.fn(),
should_show_crypto_transaction_processing_modal: false,
setShouldShowCryptoTransactionProcessingModal: jest.fn(),
is_tnc_update_modal_open: false,
toggleTncUpdateModal: jest.fn(),
},
traders_hub: {
getAccount: jest.fn(),
Expand Down
3 changes: 3 additions & 0 deletions packages/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ type TClientStore = {
is_cr_account: boolean;
is_mf_account: boolean;
setTradersHubTracking: (value: boolean) => void;
is_tnc_status_updated: Record<string, boolean>;
};

type TCommonStoreError = {
Expand Down Expand Up @@ -826,6 +827,8 @@ type TUiStore = {
setShouldShowDepositNowOrLaterModal: (value: boolean) => void;
should_show_crypto_transaction_processing_modal: boolean;
setShouldShowCryptoTransactionProcessingModal: (value: boolean) => void;
is_tnc_update_modal_open: boolean;
toggleTncUpdateModal: (value: boolean) => void;
};

type TPortfolioStore = {
Expand Down
Loading