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

Farzin/76563/Replace DepositStore with hooks #7180

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
911fbc8
refactor(cashier): :fire: remove `is_deposit_locked` from `DepositStore`
Dec 16, 2022
8ae39aa
refactor(cashier): :fire: remove `submitFundsProtection` from `Deposi…
Dec 16, 2022
3deccd7
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 16, 2022
f27d1aa
fix(cashier): :green_heart: fix CI build
Dec 16, 2022
2addfb6
fix(cashier): :green_heart: fix CI build
Dec 16, 2022
c5212fd
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 20, 2022
7b6ef86
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 22, 2022
047a42c
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 23, 2022
39820c4
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 27, 2022
158df1b
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 28, 2022
a8b726d
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 29, 2022
d16693a
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 30, 2022
0558906
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 30, 2022
0a4d34f
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Dec 30, 2022
b9a31b0
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 3, 2023
0705f63
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 6, 2023
0de99e7
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 9, 2023
5ede719
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 10, 2023
ffdd89d
test(hooks): :white_check_mark: add more test cases for `useDepositLo…
Jan 10, 2023
fb90b3f
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 10, 2023
5819466
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 12, 2023
8558804
Merge branch 'develop' into farzin/76563/replace_deposit_store_with_h…
Jan 17, 2023
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
1 change: 1 addition & 0 deletions packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"url": "https://github.com/binary-com/deriv-app/issues"
},
"dependencies": {
"@deriv/api": "^1.0.0",
"@deriv/api-types": "^1.0.54",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { render, screen } from '@testing-library/react';
import CashierLocked from '../cashier-locked';
import { StoreProvider } from '@deriv/stores';
import { TRootStore } from '../../../types';
import type { DeepPartial } from '@deriv/stores/types';

describe('<CashierLocked />', () => {
it('should show the proper message if there is a cryptocashier maintenance', () => {
Expand All @@ -18,6 +17,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: true } } },
};
Expand Down Expand Up @@ -45,6 +50,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: true,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: true } } },
};
Expand Down Expand Up @@ -72,6 +83,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: true,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: true } } },
};
Expand Down Expand Up @@ -99,6 +116,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: true } } },
};
Expand Down Expand Up @@ -126,6 +149,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -153,6 +182,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -180,6 +215,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -207,6 +248,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -234,6 +281,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -259,6 +312,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -282,6 +341,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -308,6 +373,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -335,6 +406,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -358,6 +435,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -381,6 +464,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -408,6 +497,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -439,6 +534,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: true,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -466,6 +567,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: true,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand All @@ -489,6 +596,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: true,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -516,6 +629,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: true,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -543,6 +662,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: true,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand All @@ -568,6 +693,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand All @@ -591,6 +722,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: false,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: true, is_system_maintenance: false } } },
};
Expand Down Expand Up @@ -618,6 +755,12 @@ describe('<CashierLocked />', () => {
is_deposit_lock: false,
is_withdrawal_lock: true,
is_identity_verification_needed: false,
mt5_login_list: [
{
account_type: 'demo',
sub_account_type: 'financial_stp',
},
],
},
modules: { cashier: { general_store: { is_cashier_locked: false, is_system_maintenance: false } } },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import React from 'react';
import { observer } from 'mobx-react-lite';
import EmptyState from 'Components/empty-state';
import getMessage from './cashier-locked-provider';
import { useDepositLocked } from '@deriv/hooks';
import { useStore } from '@deriv/stores';

const CashierLocked = () => {
const is_deposit_locked = useDepositLocked();
const { client, modules } = useStore();
const {
account_status,
accounts,
current_currency_type,
is_deposit_lock: is_deposit_locked,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_deposit_lock from ClientStore doesn’t have any extra logic but useDepositLocked have, I'm not sure if the behaviour is the same or not but since we should have a single source of truth I've changed it to use useDepositLocked instead.

Please let me know if this is wrong and should be reverted 🙏🏻

Copy link
Contributor

@heorhi-deriv heorhi-deriv Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farzin-deriv I believe that it's ok if we will use useDepositLocked instead of is_deposit_lock from ClientStore because we show CashierLocked component first based on is_cashier_locked status and if we have is_deposit_locked=true, we show the user what was wrong with his account (in terms of is_deposit_lock status (without checking other extra logic)), and if he fixed his is_cashier_locked and is_deposit_locked to false and then again tries to reach cashier we again checking his deposit status, but now with extra logic as you mentioned and show him an appropriate message. Mmm maybe my explanation was not very clear, but my conclusion is we can replace is_deposit_lock from ClientStore with useDepositLocked hook here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@george-usynin-binary Thank you for your explanation buddy 🌹 🙇🏻

is_withdrawal_lock: is_withdrawal_locked,
loginid,
is_identity_verification_needed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ import React from 'react';
import { fireEvent, render, screen } from '@testing-library/react';
import CashierOnboardingDetails from '../cashier-onboarding-details';

jest.mock('Stores/connect.js', () => ({
__esModule: true,
default: 'mockedDefaultExport',
connect: () => Component => Component,
}));
farzin-deriv marked this conversation as resolved.
Show resolved Hide resolved

describe('<CashierOnboardingDetails />', () => {
let props;
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import { fireEvent, render, screen } from '@testing-library/react';
import CashierOnboardingSideNote from '../cashier-onboarding-side-note';
import { StoreProvider } from '@deriv/stores';

jest.mock('Stores/connect.js', () => ({
__esModule: true,
default: 'mockedDefaultExport',
connect: () => Component => Component,
}));

describe('<CashierOnboardingSideNote />', () => {
let mockRootStore;
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ import { Router } from 'react-router';
import { routes } from '@deriv/shared';
import { StoreProvider } from '@deriv/stores';

jest.mock('Stores/connect.js', () => ({
__esModule: true,
default: 'mockedDefaultExport',
connect: () => Component => Component,
}));

describe('<CashierOnboarding />', () => {
let mockRootStore;
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { StoreProvider } from '@deriv/stores';
import { Formik } from 'formik';
import * as formik from 'formik';

jest.mock('Stores/connect.js', () => ({
__esModule: true,
default: 'mockedDefaultExport',
connect: () => Component => Component,
}));

describe('<CryptoFiatConverter />', () => {
let mockRootStore, mockProps;

Expand Down
Loading