Skip to content

Commit ef77e15

Browse files
committed
feat: accounts manual verification document selection
1 parent 74a74cc commit ef77e15

File tree

19 files changed

+273
-0
lines changed

19 files changed

+273
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './screens';
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React, { useState } from 'react';
2+
import { DocumentSelection } from './components/DocumentSelection';
3+
import { PassportDocumentUpload } from './components/PassportDocumentUpload';
4+
5+
const ManualDocumentUpload = () => {
6+
// will use formik here in the future!
7+
const [selectedDocument, setSelectedDocument] = useState('');
8+
9+
if (selectedDocument === 'passport') {
10+
return <PassportDocumentUpload setSelectedDocument={setSelectedDocument} />;
11+
} //... other document types
12+
13+
return <DocumentSelection setSelectedDocument={setSelectedDocument} />;
14+
};
15+
16+
export default ManualDocumentUpload;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { APIProvider } from '@deriv/api';
3+
import { render, screen } from '@testing-library/react';
4+
import ManualDocumentUpload from '../ManualDocumentUpload';
5+
6+
describe('<ManualDocumentUpload />', () => {
7+
it('should set selected document', () => {
8+
render(
9+
<APIProvider>
10+
<ManualDocumentUpload />
11+
</APIProvider>
12+
);
13+
14+
expect(screen.getByText('Please upload one of the following documents:')).toBeInTheDocument();
15+
const passportCard = screen.getByTestId('dt_passport');
16+
expect(passportCard).toBeInTheDocument();
17+
passportCard.click();
18+
expect(screen.getByTestId('dt_passport-document-upload')).toBeInTheDocument();
19+
});
20+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.wallets-document-selection {
2+
display: flex;
3+
padding-top: 32px;
4+
flex-direction: column;
5+
align-items: self-start;
6+
justify-content: center;
7+
gap: 19px;
8+
width: 675px;
9+
10+
@include mobile {
11+
width: 328px;
12+
}
13+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import { useSettings } from '@deriv/api';
3+
import { WalletText } from '../../../../../../components/Base';
4+
import { documentTypes } from '../../constants';
5+
import { DocumentSelectionCard } from '../DocumentSelectionCard';
6+
import './DocumentSelection.scss';
7+
8+
type TProps = {
9+
setSelectedDocument: (document: string) => void;
10+
};
11+
12+
const DocumentSelection: React.FC<TProps> = ({ setSelectedDocument }) => {
13+
const { data } = useSettings();
14+
15+
return (
16+
<div className='wallets-document-selection'>
17+
<WalletText>Please upload one of the following documents:</WalletText>
18+
{documentTypes.map(({ countries, description, icon, title, value }) => {
19+
if (countries && !countries.includes(data?.country_code ?? '')) {
20+
return null;
21+
}
22+
return (
23+
<DocumentSelectionCard
24+
description={description}
25+
icon={icon}
26+
key={`document-card-${value}`}
27+
onClick={setSelectedDocument}
28+
title={title}
29+
value={value}
30+
/>
31+
);
32+
})}
33+
</div>
34+
);
35+
};
36+
37+
export default DocumentSelection;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as DocumentSelection } from './DocumentSelection';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.wallets-document-selection-card {
2+
all: unset;
3+
display: flex;
4+
padding: 1.6rem;
5+
justify-content: space-between;
6+
align-items: center;
7+
align-self: stretch;
8+
border-radius: 0.4rem;
9+
border: 0.1rem solid var(--system-light-3-less-prominent-text, #999);
10+
cursor: pointer;
11+
12+
&:hover {
13+
border: 0.1rem solid var(--system-light-3-prominent-text, #666);
14+
}
15+
16+
&__content {
17+
display: flex;
18+
align-items: center;
19+
gap: 16px;
20+
}
21+
22+
&__text-content {
23+
display: flex;
24+
flex-direction: column;
25+
align-items: flex-start;
26+
gap: 8px;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from 'react';
2+
import { WalletText } from '../../../../../../components/Base';
3+
import useDevice from '../../../../../../hooks/useDevice';
4+
import RightArrow from '../../../../../../public/images/navigation-chevron-right.svg';
5+
import { TDocumentType } from '../../constants';
6+
import './DocumentSelectionCard.scss';
7+
8+
type TProps = TDocumentType & {
9+
onClick: (document: string) => void;
10+
};
11+
12+
const DocumentSelectionCard: React.FC<TProps> = ({ description, icon: Icon, onClick, title, value }) => {
13+
const { isMobile } = useDevice();
14+
return (
15+
<button className='wallets-document-selection-card' data-testid={`dt_${value}`} onClick={() => onClick(value)}>
16+
<div className='wallets-document-selection-card__content'>
17+
<Icon />
18+
<div className='wallets-document-selection-card__text-content'>
19+
<WalletText size={isMobile ? 'xs' : 'sm'} weight='bold'>
20+
{title}
21+
</WalletText>
22+
<WalletText size={isMobile ? '2xs' : 'xs'}>{description}</WalletText>
23+
</div>
24+
</div>
25+
<RightArrow />
26+
</button>
27+
);
28+
};
29+
30+
export default DocumentSelectionCard;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as DocumentSelectionCard } from './DocumentSelectionCard';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { WalletButton, WalletButtonGroup } from '../../../../../../components/Base';
3+
4+
type TProps = {
5+
setSelectedDocument: (document: string) => void;
6+
};
7+
8+
const PassportDocumentUpload: React.FC<TProps> = ({ setSelectedDocument }) => {
9+
return (
10+
<div data-testid='dt_passport-document-upload'>
11+
<div>
12+
<WalletButtonGroup>
13+
<WalletButton onClick={() => setSelectedDocument('')} text='Back' variant='outlined' />
14+
<WalletButton onClick={() => setSelectedDocument('')} text='Next' />
15+
</WalletButtonGroup>
16+
</div>
17+
</div>
18+
);
19+
};
20+
21+
export default PassportDocumentUpload;

0 commit comments

Comments
 (0)