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

[WALL] aum / WALL-[4916 / 4925] / wallets-implement-default-jurisdiction-flows #16867

Open
wants to merge 55 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
80791d8
feat: added created modal and added DocumentTile component
aum-deriv Sep 17, 2024
d19ae44
feat: added DocumentsList component
aum-deriv Sep 17, 2024
5711c04
refactor: useSortedMT5Accounts to get default jurisdiction accounts
aum-deriv Sep 19, 2024
ba9a266
feat: created MT5LicenceNumber component
aum-deriv Sep 23, 2024
7c995a6
refactor: MT5 password related components to include info for the MT5…
aum-deriv Sep 24, 2024
f791d85
feat: added getClientVerification util
aum-deriv Sep 24, 2024
05672f4
fix: some UI issues
aum-deriv Sep 25, 2024
b14a41f
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 25, 2024
eeadf6f
chore: bump deriv-com/ui from 1.35.0 to 1.35.2
aum-deriv Sep 26, 2024
28cc9cb
feat: added ClientVerificationStatusBadge component
aum-deriv Sep 26, 2024
4150c15
feat: updated usage of badge in DocumentList component
aum-deriv Sep 26, 2024
b5ee6fb
fix: temporary hardcoding of compnay number for non-regulated in MT5L…
aum-deriv Sep 26, 2024
9764b39
refactor: converted getTileProps function to tileProps map in Documen…
aum-deriv Sep 26, 2024
64877a4
fix: refer to correct key for poa and translation for DocumentTile in…
aum-deriv Sep 26, 2024
f17c21c
fix: logic for getClientVerification util
aum-deriv Sep 27, 2024
19f6847
refactor: DocumentList to use getClientVerification
aum-deriv Sep 27, 2024
af5e65a
chore: added unit tests for MT5LicenceMessage and DocumentList component
aum-deriv Sep 27, 2024
d1c1780
refactor: renamed and moved CFDPasswordModalTnc to screens/components…
aum-deriv Sep 27, 2024
b3a54fe
fix: unit tests for MT5PasswordModalTnc
aum-deriv Sep 27, 2024
6f3bd5f
fix: added temporary types for default service
aum-deriv Sep 27, 2024
73b3a29
fix: unit tests for AvailableMT5AccountsList
aum-deriv Sep 28, 2024
c8496a0
chore: added unit tests for EnterPassword component
aum-deriv Sep 28, 2024
0495076
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 28, 2024
3addfe5
fix: sonarcloud issue
aum-deriv Sep 28, 2024
54f5700
fix: the build CI
aum-deriv Sep 28, 2024
1cbbc95
fix: unit test for DocumentsList
aum-deriv Sep 28, 2024
faf80eb
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 30, 2024
70739a3
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Sep 30, 2024
882890c
fix: added missing localize for getMarketTypeDetails
aum-deriv Sep 30, 2024
721e868
refactor: MT5 account filtering and sorting for displaying on traders…
aum-deriv Oct 1, 2024
4731362
chore: applied suggestions
aum-deriv Oct 2, 2024
b1b2bc9
fix: warning for dependency array in MT5AccountAdded
aum-deriv Oct 2, 2024
087c59e
fix: applied comments
aum-deriv Oct 2, 2024
cb88f05
feat: created AddedMT5AccountStatusBadge
aum-deriv Oct 2, 2024
e1dbd58
refactor: AddedMt5AccountsList for default jurisdiction changes
aum-deriv Oct 3, 2024
362c0f7
fix: remove unwanted status checks for added MT5 accounts
aum-deriv Oct 4, 2024
f116417
fix: description width in desktop for ClientVerificationModal
aum-deriv Oct 4, 2024
c50da18
fix: correct check for showing the ClientVerificationModal for pre-ac…
aum-deriv Oct 4, 2024
9d72727
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 4, 2024
59309d2
fix: MT5 account added success screen not showing for first time acco…
aum-deriv Oct 4, 2024
99c9f13
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 4, 2024
29c06eb
fix: add end margin to status badge for AddedMT5AccountsList
aum-deriv Oct 4, 2024
51775fe
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 7, 2024
dd2e8c2
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 7, 2024
ad009f9
perf: added unit test for useSortedMT5Accounts hook
aum-deriv Oct 7, 2024
d325697
refactor: unit tests for AddedMT5AccountsList
aum-deriv Oct 8, 2024
7d9c040
perf: added unit tests for useAddedMT5Accounts
aum-deriv Oct 8, 2024
ffab734
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 9, 2024
d020314
Merge branch 'aum/WALL-4904/wallets-implement-default-jurisdiction-fl…
aum-deriv Oct 9, 2024
0b1f396
Merge pull request #13 from aum-deriv/aum/WALL-4925/default-jurisdict…
aum-deriv Oct 9, 2024
df7ce18
fix: ci error for ordering constants
aum-deriv Oct 9, 2024
3dcb470
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 14, 2024
73837e1
Merge branch 'master' of github.com:binary-com/deriv-app into aum/WAL…
aum-deriv Oct 15, 2024
1951f61
feat: show the ClientVerificationModal only on the click of the badge…
aum-deriv Oct 15, 2024
d517bd1
fix: updated mt5 accounts sorting order with stp to show multiple acc…
aum-deriv Oct 17, 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
378 changes: 340 additions & 38 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@deriv-com/analytics": "1.14.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/utils": "^0.0.34",
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/api": "^1.0.0",
"@deriv-com/quill-ui": "1.16.18",
"@deriv/components": "^1.0.0",
Expand Down
83 changes: 37 additions & 46 deletions packages/api-v2/src/hooks/useSortedMT5Accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,79 +28,70 @@ const useSortedMT5Accounts = (regulation?: string) => {
: account.landing_company_short !== 'maltainvest')
);

return filtered_available_accounts?.map(available_account => {
const combined_accounts = filtered_available_accounts?.map(available_account => {
const created_account = filtered_mt5_accounts?.find(account => {
return (
available_account.market_type === account.market_type &&
available_account.product === account.product &&
available_account.shortcode === account.landing_company_short
);
});

if (created_account)
return {
...created_account,
/** Determine if the account is added or not */
is_added: true,
} as const;

return {
...available_account,
...created_account,
/** Determine if the account is added or not */
is_added: false,
} as const;
is_added: Boolean(created_account),
};
});
}, [activeAccount?.is_virtual, all_available_mt5_accounts, isEU, mt5_accounts]);

// // Reduce out the added and non added accounts to make sure only one of each market_type is shown for not added
const filtered_data = useMemo(() => {
if (!modified_data) return;

const added_accounts = modified_data.filter(account => account.is_added);
const non_added_accounts = modified_data.filter(account => !account.is_added);

const filtered_non_added_accounts = non_added_accounts.reduce((acc, account) => {
const { market_type, product } = account;
const key = product === 'zero_spread' ? `${market_type}_${product}` : market_type;

const existing_account = acc.find(acc_account =>
acc_account.product === 'zero_spread'
? `${acc_account.market_type}_${acc_account.product}` === key
: acc_account.market_type === key
);
const added_account = added_accounts.find(acc_account =>
acc_account.product === 'zero_spread'
? `${acc_account.market_type}_${acc_account.product}` === key
: acc_account.market_type === key
);
if (existing_account || added_account) return acc;

return [...acc, account];
}, [] as typeof non_added_accounts);

return [...added_accounts, ...filtered_non_added_accounts];
}, [modified_data]);
return Array.from(
aum-deriv marked this conversation as resolved.
Show resolved Hide resolved
// filter out only one account per product type
combined_accounts
.reduce(
(
acc: Map<typeof combined_accounts[number]['product'], typeof combined_accounts[number]>,
cur: typeof combined_accounts[number]
) => {
const existingItem = acc.get(cur.product);

// Note: 'stp' product type account is not available for creation but we still support existing 'stp' accounts
// @ts-expect-error type for is_default_jurisdiction is unavailable in mt5_login_list and trading_platform_available_accounts
if (!existingItem && cur.is_default_jurisdiction === 'true' && cur.product !== 'stp') {
// No existing item for this product, add it directly
acc.set(cur.product, cur);
} else if (cur.is_added) {
// If `is_added` is true, replace the older entry (prioritization)
acc.set(cur.product, cur);
}

return acc;
},
new Map<typeof combined_accounts[number]['product'], typeof combined_accounts[number]>()
)
.values()
);
}, [activeAccount?.is_virtual, all_available_mt5_accounts, isEU, mt5_accounts]);

// Sort the data by market_type and product to make sure the order is 'synthetic', 'financial', 'swap_free' and 'zero_spread'
const sorted_data = useMemo(() => {
const sorting_order = ['synthetic', 'financial', 'swap_free', 'zero_spread'];

if (!filtered_data) return;
if (!modified_data) return;

const sorted_data = sorting_order.reduce((acc, sort_order) => {
const accounts = filtered_data.filter(account => {
const accounts = modified_data.filter(account => {
if (account.market_type === 'all') {
return account.product === sort_order;
}
return account.market_type === sort_order;
});
if (!accounts.length) return acc;
return [...acc, ...accounts];
}, [] as typeof filtered_data);
}, [] as typeof modified_data);

return sorted_data;
}, [filtered_data]);
}, [modified_data]);

const areAllAccountsCreated = sorted_data?.length === all_available_mt5_accounts?.length;
const areAllAccountsCreated = modified_data?.length === all_available_mt5_accounts?.length;

return {
data: sorted_data,
Expand Down
2 changes: 1 addition & 1 deletion packages/appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dependencies": {
"@deriv-com/analytics": "1.14.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/account": "^1.0.0",
"@deriv/cashier": "^1.0.0",
"@deriv/cfd": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bot-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"webpack-cli": "^4.7.2"
},
"dependencies": {
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/api": "^1.0.0",
"@deriv/api-types": "1.0.172",
"@deriv/bot-skeleton": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"url": "https://github.com/binary-com/deriv-app/issues"
},
"dependencies": {
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv-com/analytics": "1.14.0",
"@deriv/api": "^1.0.0",
"@deriv/api-types": "1.0.172",
Expand Down
2 changes: 1 addition & 1 deletion packages/cfd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"webpack-node-externals": "^2.5.2"
},
"dependencies": {
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv-com/analytics": "1.14.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/utils": "^0.0.34",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"dependencies": {
"@cloudflare/stream-react": "^1.9.1",
"@contentpass/zxcvbn": "^4.4.3",
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/hooks": "^1.0.0",
"@deriv/shared": "^1.0.0",
"@deriv/stores": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"@deriv-com/quill-tokens": "^2.0.4",
"@deriv-com/quill-ui": "1.16.18",
"@deriv-com/translations": "1.3.9",
"@deriv-com/ui": "1.35.0",
"@deriv-com/utils": "^0.0.34",
"@deriv-com/ui": "1.35.2",
"@deriv/account": "^1.0.0",
"@deriv/api": "^1.0.0",
"@deriv/appstore": "^0.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/p2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv-com/analytics": "1.14.0",
"@deriv-com/utils": "^0.0.34",
"@deriv/api": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/reports/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"webpack-node-externals": "^2.5.2"
},
"dependencies": {
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv-com/analytics": "1.14.0",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/trader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"@deriv-com/quill-tokens": "^2.0.4",
"@deriv-com/quill-ui": "1.16.18",
"@deriv-com/utils": "^0.0.34",
"@deriv-com/ui": "1.35.0",
"@deriv-com/ui": "1.35.2",
"@deriv/api-types": "1.0.172",
"@deriv/components": "^1.0.0",
"@deriv/deriv-api": "^1.0.15",
Expand Down
2 changes: 1 addition & 1 deletion packages/wallets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"dependencies": {
"@deriv-com/analytics": "1.14.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/ui": "1.35.0",
"@deriv-com/utils": "^0.0.34",
"@deriv-com/ui": "1.35.2",
"@deriv/api-v2": "^1.0.0",
"@deriv/quill-icons": "1.23.3",
"@deriv/utils": "^1.0.0",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.wallets-client-verification-badge {
&__content {
&--underlined {
text-decoration: underline;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';
import classNames from 'classnames';
import {
LabelPairedCircleCheckCaptionBoldIcon,
LabelPairedCircleExclamationCaptionBoldIcon,
LabelPairedClockThreeCaptionBoldIcon,
LabelPairedTriangleExclamationCaptionBoldIcon,
} from '@deriv/quill-icons';
import { useTranslations } from '@deriv-com/translations';
import { Badge, Text, useDevice } from '@deriv-com/ui';
import { TTranslations } from '../../../../types';
import './ClientVerificationStatusBadge.scss';

type TBadgeColor = React.ComponentProps<typeof Badge>['color'];

const getBadgeVariations = (localize: TTranslations['localize']) => {
return {
failed: {
color: 'danger-secondary',
content: localize('Failed'),
icon: <LabelPairedTriangleExclamationCaptionBoldIcon fill='#C40000' />,
},
in_review: {
color: 'warning-secondary',
content: localize('In review'),
icon: <LabelPairedClockThreeCaptionBoldIcon fill='#C47D00' />,
},
needs_verification: {
color: 'blue-secondary',
content: localize('Needs verification'),
icon: <LabelPairedCircleExclamationCaptionBoldIcon fill='#0777C4' />,
},
verified: {
color: 'success-secondary',
content: localize('Verified'),
icon: <LabelPairedCircleCheckCaptionBoldIcon fill='#007A22' />,
},
};
};

type TClientVerificationBadgeProps = {
onClick?: VoidFunction;
variant: keyof ReturnType<typeof getBadgeVariations>;
};

const ClientVerificationStatusBadge: React.FC<TClientVerificationBadgeProps> = ({ onClick, variant }) => {
const { localize } = useTranslations();
const { isDesktop } = useDevice();
const { color, content, icon } = getBadgeVariations(localize)[variant];
return (
<Badge
badgeSize='sm'
className='wallets-client-verification-badge'
color={color as TBadgeColor}
leftIcon={icon}
onClick={onClick}
>
<Text
className={classNames('wallets-client-verification-badge__content', {
'wallets-client-verification-badge__content--underlined': !!onClick,
})}
size={isDesktop ? 'xs' : 'sm'}
weight='bold'
>
{content}
</Text>
</Badge>
);
};

export default ClientVerificationStatusBadge;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as ClientVerificationStatusBadge } from './ClientVerificationStatusBadge';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type TProps = {
badgeSize: ComponentProps<typeof Badge>['badgeSize'];
cashierAccount?: TAccount;
className?: ComponentProps<typeof Badge>['className'];
mt5Account?: THooks.MT5AccountsList;
mt5Account?: THooks.SortedMT5Accounts;
};

const PlatformStatusBadge: React.FC<TProps> = ({ badgeSize, cashierAccount, className, mt5Account }) => {
Expand Down
1 change: 1 addition & 0 deletions packages/wallets/src/features/cfd/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './CFDPlatformsListAccounts';
export * from './ClientVerificationBadge';
export * from './CompareAccountsCarousel';
export * from './ModalTradeWrapper';
export * from './PlatformStatusBadge';
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { MT5TradeModal, TradingPlatformStatusModal, VerificationFailedModal } fr
import './AddedMT5AccountsList.scss';

type TProps = {
account: THooks.MT5AccountsList;
account: THooks.SortedMT5Accounts;
};

const AddedMT5AccountsList: React.FC<TProps> = ({ account }) => {
Expand Down
Loading
Loading