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

Likhith/shaheer/coj 506/integrate manual upload flow #124

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5da32ea
[Cashier-V2] george / FEQ-1207 / Implement Cashier Onboarding module …
heorhi-deriv Feb 19, 2024
9870a0c
fix: duration dropdown height when switching between different trade …
akmal-deriv Feb 19, 2024
9dc8090
DTRA / Kate / DTRA-905 / Binary.com reference is still showing in for…
kate-deriv Feb 19, 2024
b899fa7
Ako/ add permissions to the workflow (#13658)
ali-hosseini-deriv Feb 19, 2024
20950f8
🤖 Remote Config file update 🤖 (#13661)
github-actions[bot] Feb 19, 2024
57cc084
fix: fixed the hover effect of forgot password part (#13439)
hirad-deriv Feb 19, 2024
04bac26
fix: prevent error on local development (#13668)
ali-hosseini-deriv Feb 19, 2024
c13ce90
[P2PS] / Ameerul / P2PS-2356 Improvisation of Content for Nickname Po…
ameerul-deriv Feb 19, 2024
d4005dc
[FEQ] P2P-V2 Block unblock user modal test (#13666)
adrienne-deriv Feb 19, 2024
3b8521f
[FEQ] P2P-V2 daily limit modal test (#13669)
adrienne-deriv Feb 19, 2024
9568f3c
[FEQ] P2P-V2 usePoiPoaStatus hook (#13671)
adrienne-deriv Feb 19, 2024
23e3b2e
chore: Bump-deriv-com/ui-version-from-v1.5.3-to-v1.8.1 (#13672)
heorhi-deriv Feb 19, 2024
5947bf2
[FEQ] P2P-V2 useAdvertiserStats hook test case (#13647)
adrienne-deriv Feb 19, 2024
d9c38cd
chore: add test case for payment method error modal (#13574)
jim-deriv Feb 19, 2024
67d819b
[FEQ]Jim/FEQ-1645/add unit test for payment method modal (#13575)
jim-deriv Feb 19, 2024
d3d6d98
fix: fix console errors for 2 cases (#13667) (#13673)
vinu-deriv Feb 19, 2024
862d851
fix: added testcases for manual
likhith-deriv Feb 19, 2024
6822b24
fix: code smells
likhith-deriv Feb 19, 2024
f20f60c
Merge branch 'binary-com:master' into likhith/shaheer/COJ-506/integra…
shaheer-deriv Feb 19, 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
6 changes: 0 additions & 6 deletions .github/actions/download_remote_config_backup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ description: Download remote config backup
inputs:
REMOTE_CONFIG_URL:
description: "Remote config backup URL"
GPG_PRIVATE_KEY:
description: "GPG private key"
GPG_PASSPHRASE:
description: "GPG passphrase"
GITHUB_TOKEN:
description: "GitHub token"
runs:
using: composite
steps:
Expand Down
7 changes: 0 additions & 7 deletions .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ jobs:
uses: "./.github/actions/setup_node"
- name: Install Dependencies
uses: "./.github/actions/npm_install_from_cache"
- name: Download Remote Config Backup File
uses: ./.github/actions/download_remote_config_backup
with:
GITHUB_TOKEN: ${{ github.token }}
REMOTE_CONFIG_URL: ${{ vars.REMOTE_CONFIG_URL }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Build
uses: "./.github/actions/build"
with:
Expand Down
26 changes: 17 additions & 9 deletions .github/workflows/remote_config_pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
name: Deriv App Remote Config backup file

permissions:
actions: write
checks: write
contents: write
deployments: write
pull-requests: write
statuses: write
on:
push:
branches:
Expand All @@ -13,24 +21,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Import GPG key
id: import-gpg
uses: deriv-com/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Checkout to remote_config_update_branch
run: |
git fetch origin
git checkout "${{ env.REMOTE_CONFIG_BRANCH }}" || git checkout -b "${{ env.REMOTE_CONFIG_BRANCH }}" origin/"${{ env.REMOTE_CONFIG_BRANCH }}"

shell: bash
- name: Download Remote Config Backup File
uses: ./.github/actions/download_remote_config_backup
with:
REMOTE_CONFIG_URL: ${{ vars.REMOTE_CONFIG_URL }}

- name: Import GPG key
id: import-gpg
uses: deriv-com/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit the file and Create PR
env:
GIT_AUTHOR_NAME: ${{ steps.import-gpg.outputs.name }}
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/account-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "rimraf dist && npm run test && npm run serve"
},
"dependencies": {
"@deriv-com/ui": "1.5.3",
"@deriv-com/ui": "1.8.1",
"@deriv/api": "^1.0.0",
"@deriv/library": "^1.0.0",
"@deriv/quill-design": "^1.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ describe('ManualForm', () => {
selectedDocument?: React.ComponentProps<typeof ManualForm>['selectedDocument'];
}) => {
const mockProps: React.ComponentProps<typeof ManualForm> = {
formData: {},
isExpiryDateRequired: false,
onCancel: jest.fn(),
onSubmit: jest.fn(),
selectedDocument: selectedDocument ?? 'driving_licence',
Expand Down
17 changes: 12 additions & 5 deletions packages/account-v2/src/containers/ManualForm/manual-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Form, Formik, FormikValues } from 'formik';
import { InferType } from 'yup';
import { Button } from '@deriv-com/ui';
import { MANUAL_DOCUMENT_SELFIE, TManualDocumentTypes } from '../../constants/manualFormConstants';
import { useManualForm } from '../../hooks';
import { getManualFormValidationSchema, setInitialValues } from '../../utils/manual-form-utils';
import { ManualFormDocumentUpload } from './manual-form-document-upload';
import { ManualFormFooter } from './manual-form-footer';
Expand All @@ -13,14 +12,19 @@ type TmanualDocumentFormValues = InferType<ReturnType<typeof getManualFormValida

type TManualFormProps = {
formData: FormikValues;
isExpiryDateRequired: boolean;
onCancel: () => void;
onSubmit: (values: TmanualDocumentFormValues) => void;
selectedDocument: TManualDocumentTypes;
};

export const ManualForm = ({ formData, onCancel, onSubmit, selectedDocument }: TManualFormProps) => {
const { isExpiryDateRequired } = useManualForm();

export const ManualForm = ({
formData,
isExpiryDateRequired,
onCancel,
onSubmit,
selectedDocument,
}: TManualFormProps) => {
const validationSchema = getManualFormValidationSchema(selectedDocument, isExpiryDateRequired);

const initialValues = useMemo(() => {
Expand All @@ -40,7 +44,10 @@ export const ManualForm = ({ formData, onCancel, onSubmit, selectedDocument }: T
<Form>
<div className='flex flex-col min-h-screen w-full'>
<div className='flex flex-col gap-1200'>
<ManualFormInputs isExpiryDateRequired selectedDocument={selectedDocument} />
<ManualFormInputs
isExpiryDateRequired={isExpiryDateRequired}
selectedDocument={selectedDocument}
/>
<ManualFormDocumentUpload selectedDocument={selectedDocument} />
<ManualFormFooter />
</div>
Expand Down
61 changes: 35 additions & 26 deletions packages/account-v2/src/hooks/__tests__/useManualForm.spec.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
import { useSettings } from '@deriv/api';
import { useKycAuthStatus } from '@deriv/api';
import { renderHook } from '@testing-library/react-hooks';
import useManualForm from '../useManualForm';

jest.mock('@deriv/api', () => ({
...jest.requireActual('@deriv/api'),
useSettings: jest.fn(),
useKycAuthStatus: jest.fn(),
}));

describe('useManualForm', () => {
it('should return false if citizenship is ng', () => {
(useSettings as jest.Mock).mockReturnValue({
data: {
citizen: 'ng',
country_code: 'in',
it('should return false for expiry date if citizenship is ng and document is nimc slip', () => {
(useKycAuthStatus as jest.Mock).mockReturnValue({
isLoading: false,
kyc_auth_status: {
identity: {
available_services: ['onfido', 'manual'],
},
},
});
const { result } = renderHook(() => useManualForm());
const { isExpiryDateRequired } = result.current;
expect(isExpiryDateRequired).toBe(false);
const { result } = renderHook(() => useManualForm('ng', 'nimc_slip'));
const { isExpiryDateRequired, poiService } = result.current;
expect(isExpiryDateRequired).toBeFalsy();
expect(poiService).toBe('manual');
});

it('should return true if citizenship and country code is not ng', () => {
(useSettings as jest.Mock).mockReturnValue({
data: {
citizen: 'au',
country_code: 'au',
it('should return true for expiry date if citizenship is ng and document is passport', () => {
(useKycAuthStatus as jest.Mock).mockReturnValue({
isLoading: false,
kyc_auth_status: {
identity: {
available_services: ['onfido', 'manual'],
},
},
});
const { result } = renderHook(() => useManualForm());
const { isExpiryDateRequired } = result.current;
expect(isExpiryDateRequired).toBe(true);
const { result } = renderHook(() => useManualForm('ng', 'passport'));
const { isExpiryDateRequired, poiService } = result.current;
expect(isExpiryDateRequired).toBeTruthy();
expect(poiService).toBe('onfido');
});

it('should return true if citizenship is not ng but country code is ng', () => {
(useSettings as jest.Mock).mockReturnValue({
data: {
citizen: 'in',
country_code: 'ng',
it('should return manual as POI service if citizenship is in and document is passport', () => {
(useKycAuthStatus as jest.Mock).mockReturnValue({
isLoading: false,
kyc_auth_status: {
identity: {
available_services: ['onfido', 'manual'],
},
},
});
const { result } = renderHook(() => useManualForm());
const { isExpiryDateRequired } = result.current;
expect(isExpiryDateRequired).toBe(true);
const { result } = renderHook(() => useManualForm('in', 'passport'));
const { isExpiryDateRequired, poiService } = result.current;
expect(isExpiryDateRequired).toBeTruthy();
expect(poiService).toBe('manual');
});
});
31 changes: 25 additions & 6 deletions packages/account-v2/src/hooks/useManualForm.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import { useSettings } from '@deriv/api';
import { useKycAuthStatus } from '@deriv/api';
import { MANUAL_DOCUMENT_TYPES, TManualDocumentTypes } from '../constants/manualFormConstants';

/** A custom hook used for manual verification flow */
const useManualForm = () => {
const { data: settings } = useSettings();
const countryCode = settings?.citizen ?? settings?.country_code;
const isExpiryDateRequired = !!countryCode && countryCode !== 'ng';
const useManualForm = (countryCode: string, selectedDocument: TManualDocumentTypes) => {
const { isLoading, kyc_auth_status, ...rest } = useKycAuthStatus({ country: countryCode });
const servicesAvailable = kyc_auth_status?.identity?.available_services;

if (countryCode === 'ng') {
if (selectedDocument === MANUAL_DOCUMENT_TYPES.NIMC_SLIP) {
return {
isExpiryDateRequired: false,
isLoading,
poiService: 'manual',
...rest,
};
}
return {
isExpiryDateRequired: true,
isLoading,
poiService: isLoading ? null : servicesAvailable[0],
...rest,
};
}
return {
isExpiryDateRequired,
isExpiryDateRequired: true,
isLoading,
poiService: 'manual',
...rest,
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { ComponentProps } from 'react';
import { Formik } from 'formik';
import { fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { render, screen } from '@testing-library/react';
import { IDVForm } from '../idv-form';

jest.mock('@deriv-com/ui', () => ({
Expand Down
11 changes: 9 additions & 2 deletions packages/account-v2/src/modules/Onfido/OnfidoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ import { Button, Loader, Text } from '@deriv-com/ui';
import IcAccountMissingDetails from '../../assets/proof-of-identity/ic-account-missing-details.svg';
import { ErrorMessage } from '../../components/ErrorMessage';
import { IconWithMessage } from '../../components/IconWithMessage';
import { TManualDocumentTypes } from '../../constants/manualFormConstants';
import { OnfidoView } from '../../containers/Onfido/OnfidoView';

// TODO: Remove optional and default props when POI is ready
type TOnfidoContainer = {
country?: string;
isEnabledByDefault?: boolean;
onOnfidoSubmit?: () => void;
selectedDocument?: TManualDocumentTypes;
};

export const OnfidoContainer = ({ country = 'co', isEnabledByDefault = false, onOnfidoSubmit }: TOnfidoContainer) => {
export const OnfidoContainer = ({
country,
isEnabledByDefault = false,
onOnfidoSubmit,
selectedDocument,
}: TOnfidoContainer) => {
const [isOnfidoEnabled, setIsOnfidoEnabled] = useState(isEnabledByDefault);
const [transitionEnd, setTransitionEnd] = useState(false);
const history = useHistory();
Expand All @@ -27,7 +34,7 @@ export const OnfidoContainer = ({ country = 'co', isEnabledByDefault = false, on
isServiceTokenLoading,
onfidoInitializationError,
serviceTokenError,
} = useOnfido(country);
} = useOnfido(country, selectedDocument);

useEffect(() => {
if (hasSubmitted) {
Expand Down
Loading
Loading