1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

[MMI] Added compliance details modal and compliance details component (#18118)

* Added compliance details modal and compliance details component

* Finished component

* Fixed test name
This commit is contained in:
Albert Olivé 2023-05-05 14:07:51 +02:00 committed by GitHub
parent f62d8fce61
commit 319696b4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 81 additions and 7 deletions

View File

@ -358,6 +358,9 @@
"message": "Allow $1 to withdraw and spend up to the following amount:",
"description": "The url of the site that requested permission to 'withdraw and spend'"
},
"amlCompliance": {
"message": "AML/CFT Compliance"
},
"amount": {
"message": "Amount"
},

View File

@ -0,0 +1,36 @@
import PropTypes from 'prop-types';
import React, { useContext } from 'react';
import { useDispatch } from 'react-redux';
import Modal from '../../app/modal';
import { hideModal } from '../../../store/actions';
import ComplianceDetails from '../compliance-details';
import { I18nContext } from '../../../contexts/i18n';
export default function ComplianceDetailsModal({
onGenerateComplianceReport,
reportAddress,
}) {
const dispatch = useDispatch();
const handleClose = () => dispatch(hideModal);
const t = useContext(I18nContext);
return (
<Modal
headerText={t('amlCompliance')}
hideFooter="true"
onClose={handleClose}
contentClass="compliance-details-modal-content"
>
<ComplianceDetails
address={reportAddress}
onClose={handleClose}
onGenerate={onGenerateComplianceReport}
/>
</Modal>
);
}
ComplianceDetailsModal.propTypes = {
reportAddress: PropTypes.func.isRequired,
onGenerateComplianceReport: PropTypes.func.isRequired,
};

View File

@ -0,0 +1,31 @@
import React from 'react';
import { renderWithProvider } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import ComplianceDetailsModal from './compliance-details-modal';
const props = {
hideModal: jest.fn(),
onGenerateComplianceReport: jest.fn(),
reportAddress: '0xAddress',
};
const render = () => {
const store = configureStore({
...mockState,
metamask: {},
history: {
mostRecentOverviewPage: 'test',
},
});
return renderWithProvider(<ComplianceDetailsModal {...props} />, store);
};
describe('Compliance Modal', function () {
it('render correctly with the correct header', function () {
const { getByText } = render();
expect(getByText('AML/CFT Compliance')).toBeVisible();
});
});

View File

@ -0,0 +1 @@
export { default } from './compliance-details-modal';

View File

@ -0,0 +1,3 @@
.compliance-details-modal-content {
padding: 0;
}

View File

@ -29,19 +29,19 @@ const { actions, reducer } = slice;
export default reducer;
export const getComplianceProjectId = (state) =>
state.metamask[name].complianceProjectId;
state.metamask[name]?.complianceProjectId;
export const getComplianceClientId = (state) =>
state.metamask[name].complianceClientId;
state.metamask[name]?.complianceClientId;
export const getComplianceTenantSubdomain = (state) =>
state.metamask[name].complianceTenantSubdomain;
state.metamask[name]?.complianceTenantSubdomain;
export const getComplianceHistoricalReports = (state) =>
state.metamask[name].historicalReports;
state.metamask[name]?.historicalReports;
export const getComplianceReportsInProgress = (state) =>
state.metamask[name].reportsInProgress;
state.metamask[name]?.reportsInProgress;
export const getInstitutionalConnectRequests = (state) =>
state.metamask[name].connectRequests;
state.metamask[name]?.connectRequests;
export const complianceActivated = (state) =>
Boolean(state.metamask[name].complianceProjectId);
Boolean(state.metamask[name]?.complianceProjectId);
export const getComplianceHistoricalReportsByAddress = (address) =>
createSelector(getComplianceHistoricalReports, (reports) =>