Skip to content

Commit

Permalink
Merge branch 'master' into evgeniy/89431/no_error_message_for_idv_dup…
Browse files Browse the repository at this point in the history
…licated_document_numbers
  • Loading branch information
yauheni-deriv committed Mar 9, 2023
2 parents 1da6ea5 + be2e42e commit 311036a
Show file tree
Hide file tree
Showing 225 changed files with 3,564 additions and 3,313 deletions.
38 changes: 25 additions & 13 deletions package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ describe('proof-of-ownership-form.jsx', () => {
render(
<ProofOfOwnershipForm
grouped_payment_method_data={{ beyonic: grouped_payment_method_data.beyonic }}
total_documents_required={1}
updateAccountStatus={jest.fn()}
refreshNotifications={jest.fn()}
is_dark_mode={false}
Expand All @@ -22,7 +21,6 @@ describe('proof-of-ownership-form.jsx', () => {
render(
<ProofOfOwnershipForm
grouped_payment_method_data={grouped_payment_method_data}
total_documents_required={7}
updateAccountStatus={jest.fn()}
refreshNotifications={jest.fn()}
is_dark_mode={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import ExpandedCard from './expanded-card.jsx';
import PropTypes from 'prop-types';

const Card = ({ card, error, handleBlur, handleChange, index, setFieldValue, updateErrors, validateField, values }) => {
const Card = ({ card, error, index, setFieldValue, updateErrors, values }) => {
const [is_open, setIsOpen] = React.useState(false);
const onClickHandler = e => {
e.preventDefault();
Expand Down Expand Up @@ -43,13 +43,10 @@ const Card = ({ card, error, handleBlur, handleChange, index, setFieldValue, upd
{is_open && (
<ExpandedCard
card_details={card}
handleChange={handleChange}
handleBlur={handleBlur}
values={values}
setFieldValue={setFieldValue}
index={index}
error={error}
validateField={validateField}
updateErrors={updateErrors}
/>
)}
Expand All @@ -59,13 +56,10 @@ const Card = ({ card, error, handleBlur, handleChange, index, setFieldValue, upd

Card.propTypes = {
card: PropTypes.object,
error: PropTypes.array,
handleBlur: PropTypes.func,
handleChange: PropTypes.func,
error: PropTypes.object,
index: PropTypes.number,
setFieldValue: PropTypes.func,
updateErrors: PropTypes.func,
validateField: PropTypes.func,
values: PropTypes.object,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import SampleCreditCardModal from 'Components/sample-credit-card-modal';
import classNames from 'classnames';
import { IDENTIFIER_TYPES, VALIDATIONS } from './constants/constants.js';

const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors, validateField, values }) => {
const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors, values }) => {
const [is_sample_modal_open, setIsSampleModalOpen] = useState(false);
const handleUploadedFile = (name, file) => {
setFieldValue(name, file);
const handleUploadedFile = async (name, file) => {
await setFieldValue(name, file);
};
const handleBlur = (name, payment_method_identifier, item_id, item_index) => {
const handleBlur = (name, payment_method_identifier, identifier_type, item_id, item_index, documents_required) => {
handleIdentifierChange(
name,
formatIdentifier(payment_method_identifier, card_details?.identifier_type),
formatIdentifier(payment_method_identifier, identifier_type),
item_id,
item_index
item_index,
documents_required
);
};
const handleIdentifierChange = (name, payment_method_identifier, item_id, item_index) => {
const handleIdentifierChange = (name, payment_method_identifier, item_id, item_index, documents_required) => {
setFieldValue(`${name}`, {
...values.data?.[index]?.[item_index],
documents_required,
id: item_id,
payment_method_identifier,
is_generic_pm: card_details.is_generic_pm,
Expand Down Expand Up @@ -92,16 +94,19 @@ const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors,
`data[${index}].[${item_index}]`,
e.currentTarget.value.trim(),
item.id,
item_index
item_index,
card_details.documents_required
);
}}
value={values?.data?.[index]?.[item_index]?.payment_method_identifier ?? ''}
value={values?.data?.[index]?.[item_index]?.payment_method_identifier || ''}
onBlur={e => {
handleBlur(
`data[${index}].[${item_index}]`,
e.currentTarget.value.trim(),
card_details?.identifier_type,
item.id,
item_index
item_index,
card_details.documents_required
);
}}
data-testid='dt_payment_method_identifier'
Expand Down Expand Up @@ -129,9 +134,10 @@ const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors,
onChange={e => {
handleIdentifierChange(
`data[${index}].[${item_index}]`,
e.currentTarget.value,
e.currentTarget.value.trim(),
item.id,
item_index
item_index,
card_details.documents_required
);
}}
value={
Expand All @@ -141,9 +147,11 @@ const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors,
onBlur={e => {
handleBlur(
`data[${index}].[${item_index}]`,
e.currentTarget.value,
e.currentTarget.value.trim(),
card_details?.identifier_type,
item.id,
item_index
item_index,
card_details.documents_required
);
}}
data-testid='dt_payment_method_identifier'
Expand All @@ -163,7 +171,6 @@ const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors,
class_name='proof-of-ownership__card-open-inputs-photo'
name={`data[${index}].[${item_index}].files[${i}]`}
error={error?.[item_index]?.files?.[i]}
validateField={validateField}
index={index}
item_index={item_index}
sub_index={i}
Expand All @@ -189,11 +196,10 @@ const ExpandedCard = ({ card_details, error, index, setFieldValue, updateErrors,

ExpandedCard.propTypes = {
card_details: PropTypes.object,
error: PropTypes.array,
error: PropTypes.object,
index: PropTypes.number,
setFieldValue: PropTypes.func,
updateErrors: PropTypes.func,
validateField: PropTypes.func,
values: PropTypes.object,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ const FileUploader = ({
name,
sub_index,
updateErrors,
validateField,
}) => {
const [show_browse_button, setShowBrowseButton] = React.useState(!file_name);
// Create a reference to the hidden file input element
const hidden_file_input = React.useRef(null);
const handleClick = e => {
e.stopPropagation();
e.nativeEvent.preventDefault();
e.nativeEvent.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
hidden_file_input.current.click();
};

const handleChange = async event => {
event.stopPropagation();
event.nativeEvent.preventDefault();
event.nativeEvent.stopPropagation();
event.nativeEvent.stopImmediatePropagation();
const file_to_upload = await compressImageFiles([event.target.files[0]]);
handleFile(name, file_to_upload[0]);
setShowBrowseButton(!file_to_upload[0]);
};
const handleIconClick = e => {
e.stopPropagation();
const handleIconClick = async e => {
e.nativeEvent.preventDefault();
e.nativeEvent.stopPropagation();
e.nativeEvent.stopImmediatePropagation();
hidden_file_input.current.value = '';
handleFile(name, '');
await handleFile(name, '');
setShowBrowseButton(prevState => !prevState);
updateErrors(index, item_index, sub_index);
validateField('files');
await updateErrors(index, item_index, sub_index);
};
return (
<div className={`file-uploader ${class_name}`}>
Expand Down Expand Up @@ -98,7 +99,6 @@ FileUploader.propTypes = {
name: PropTypes.string,
sub_index: PropTypes.number,
updateErrors: PropTypes.func,
validateField: PropTypes.func,
};

export default FileUploader;
Loading

0 comments on commit 311036a

Please sign in to comment.