Skip to content

Commit 391af35

Browse files
Merge branch 'master' into ahmed/DAPI-821/fix--sync-endpoint-configV3
2 parents a606747 + 0f07d77 commit 391af35

File tree

18 files changed

+272
-35
lines changed

18 files changed

+272
-35
lines changed

config/v3/kyc_auth_status/receive.json

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,24 @@
168168
}
169169
},
170170
"available_services": {
171-
"description": "Services that support this document type.",
171+
"description": "Services that support this document type and the specific name expected by the service.",
172172
"type": "array",
173173
"items": {
174-
"type": "string"
174+
"type": "object",
175+
"required": [
176+
"document_type",
177+
"service"
178+
],
179+
"properties": {
180+
"document_type": {
181+
"description": "The specific document type name expected by the service.",
182+
"type": "string"
183+
},
184+
"service": {
185+
"description": "The name of the service supporting this document type.",
186+
"type": "string"
187+
}
188+
}
175189
}
176190
},
177191
"display_name": {
@@ -378,10 +392,24 @@
378392
}
379393
},
380394
"available_services": {
381-
"description": "Services that support this document type.",
395+
"description": "Services that support this document type and the specific name expected by the service.",
382396
"type": "array",
383397
"items": {
384-
"type": "string"
398+
"type": "object",
399+
"required": [
400+
"document_type",
401+
"service"
402+
],
403+
"properties": {
404+
"document_type": {
405+
"description": "The specific document type name expected by the service.",
406+
"type": "string"
407+
},
408+
"service": {
409+
"description": "The name of the service supporting this document type.",
410+
"type": "string"
411+
}
412+
}
385413
}
386414
},
387415
"display_name": {

config/v3/p2p_order_create/receive.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,18 @@
124124
1
125125
]
126126
},
127+
"is_recommended": {
128+
"description": "Optional field, indicates if the advertiser is recommended.",
129+
"type": [
130+
"integer",
131+
"null"
132+
],
133+
"enum": [
134+
0,
135+
1,
136+
null
137+
]
138+
},
127139
"last_name": {
128140
"description": "The advertiser's last name.",
129141
"type": "string",

package-lock.json

Lines changed: 15 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/UserNavbarItem/item.desktop.tsx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import useDeviceType from '@site/src/hooks/useDeviceType';
1212

1313
import { IUserNavbarItemProps } from './item.types';
1414
import styles from './UserNavbarItem.module.scss';
15+
import Cookies from 'js-cookie';
16+
import { useHandleLogin } from '@site/src/hooks/useHandleLogin';
1517

1618
interface IActionProps {
1719
handleClick: () => void;
@@ -62,12 +64,16 @@ const DashboardActions: React.FC<IActionProps> = ({ handleClick, isDesktop }) =>
6264
const SignedInActions: React.FC<IActionProps> = ({ handleClick, isDesktop }) => {
6365
const signedInButtonClasses = clsx('navbar__item', styles.UserNavbarItem, styles.SignedInButton);
6466

67+
const { handleLogin } = useHandleLogin({
68+
onClickLogin: handleClick,
69+
});
70+
6571
return (
6672
<nav className='right-navigation'>
6773
<Button
6874
variant='secondary'
6975
color='black'
70-
onClick={handleClick}
76+
onClick={handleLogin}
7177
className={signedInButtonClasses}
7278
data-testid='sa_login'
7379
>
@@ -88,14 +94,41 @@ const SignedInActions: React.FC<IActionProps> = ({ handleClick, isDesktop }) =>
8894
};
8995

9096
const UserNavbarDesktopItem = ({ authUrl, is_logged_in }: IUserNavbarItemProps) => {
91-
const { logout } = useLogout();
9297
const { deviceType } = useDeviceType();
9398
const isDesktop = deviceType === 'desktop';
9499

95100
const handleClick = () => {
96101
location.assign(authUrl);
97102
};
98103

104+
const { handleLogin, isOAuth2Enabled } = useHandleLogin({
105+
onClickLogin: handleClick,
106+
});
107+
108+
const { logout } = useLogout();
109+
110+
const loggedState = Cookies.get('logged_state');
111+
112+
const loginAccountsSessionStorage = JSON.parse(sessionStorage.getItem('login-accounts'));
113+
114+
const isLoginAccountsPopulated =
115+
loginAccountsSessionStorage && loginAccountsSessionStorage.length > 0;
116+
117+
React.useEffect(() => {
118+
if (
119+
loggedState === 'true' &&
120+
isOAuth2Enabled &&
121+
!isLoginAccountsPopulated &&
122+
!window.location.pathname.includes('callback') &&
123+
!window.location.pathname.includes('endpoint')
124+
) {
125+
handleLogin();
126+
}
127+
if (loggedState === 'false' && isOAuth2Enabled && isLoginAccountsPopulated) {
128+
logout();
129+
}
130+
}, [isOAuth2Enabled, loggedState, logout, handleLogin, isLoginAccountsPopulated]);
131+
99132
return is_logged_in ? (
100133
<DashboardActions handleClick={logout} isDesktop={isDesktop} />
101134
) : (

src/features/Apiexplorer/LoginDialog/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import useLoginUrl from '@site/src/hooks/useLoginUrl';
44
import styles from './LoginDialog.module.scss';
55
import Translate, { translate } from '@docusaurus/Translate';
66
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
7+
import { useHandleLogin } from '@site/src/hooks/useHandleLogin';
78

89
type TLoginDialog = {
910
setToggleModal: React.Dispatch<React.SetStateAction<boolean>>;
@@ -25,6 +26,10 @@ export const LoginDialog = ({ setToggleModal }: TLoginDialog) => {
2526
location.assign(getUrl(currentLocale));
2627
};
2728

29+
const { handleLogin } = useHandleLogin({
30+
onClickLogin: handleClick,
31+
});
32+
2833
const handleSignUp = () => {
2934
location.assign('https://deriv.com/signup/');
3035
};
@@ -57,7 +62,7 @@ export const LoginDialog = ({ setToggleModal }: TLoginDialog) => {
5762
<Button color='tertiary' onClick={handleSignUp} className={styles.btn}>
5863
<Translate>Sign up</Translate>
5964
</Button>
60-
<Button color='primary' onClick={handleClick} className={styles.btn}>
65+
<Button color='primary' onClick={handleLogin} className={styles.btn}>
6166
<Translate>Log in</Translate>
6267
</Button>
6368
</div>

src/features/Apiexplorer/Schema/Schema.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@use 'src/styles/utility' as *;
2+
@use 'src/styles/mixins' as *;
23

34
.schemaHeader {
45
padding: rem(2.4);
@@ -227,6 +228,10 @@
227228
gap: rem(0.8);
228229
width: 100%;
229230

231+
@include mobile-sm {
232+
flex-wrap: wrap;
233+
}
234+
230235
strong {
231236
font-size: rem(1.6);
232237
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { Callback } from '@deriv-com/auth-client';
3+
import { transformAccountsFromResponseBody } from '@site/src/utils';
4+
import useAuthContext from '@site/src/hooks/useAuthContext';
5+
const CallbackPage = () => {
6+
const { updateLoginAccounts } = useAuthContext();
7+
return (
8+
<Callback
9+
onSignInSuccess={(tokens) => {
10+
const accounts = transformAccountsFromResponseBody(tokens);
11+
updateLoginAccounts(accounts);
12+
window.location.href = '/';
13+
}}
14+
/>
15+
);
16+
};
17+
export default CallbackPage;

src/features/Callback/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import CallbackPage from './CallbackPage';
2+
export default CallbackPage;

src/features/Login/Login.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import useLoginUrl from '@site/src/hooks/useLoginUrl';
55
import Footer from '@site/src/components/Footer';
66
import Translate from '@docusaurus/Translate';
77
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
8+
import { useHandleLogin } from '@site/src/hooks/useHandleLogin';
89

910
export const Login = () => {
1011
const { getUrl } = useLoginUrl();
@@ -15,6 +16,11 @@ export const Login = () => {
1516
const handleClick = () => {
1617
window.location.assign(getUrl(currentLocale));
1718
};
19+
20+
const { handleLogin } = useHandleLogin({
21+
onClickLogin: handleClick,
22+
});
23+
1824
return (
1925
<div>
2026
<div className={styles.login} data-testid='login'>
@@ -26,7 +32,7 @@ export const Login = () => {
2632
</Translate>
2733
</Text>
2834
<div className={styles.action}>
29-
<Button color='primary' onClick={handleClick}>
35+
<Button color='primary' onClick={handleLogin}>
3036
<Translate>Log In</Translate>
3137
</Button>
3238
</div>

src/features/dashboard/__tests__/dashboard.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ mockReactTable.mockImplementation(() => ({
4848
headerGroups: [],
4949
}));
5050

51+
jest.mock('@docusaurus/BrowserOnly', () => ({
52+
__esModule: true,
53+
default: ({ children }: { children: () => JSX.Element }) => children(),
54+
}));
55+
5156
describe('AppManager', () => {
5257
it('shows the login screen', () => {
5358
mockUseAuthContext.mockImplementation(() => ({

0 commit comments

Comments
 (0)