Skip to content

Commit

Permalink
fix(account): add a missing update
Browse files Browse the repository at this point in the history
ref: MANAGER-15555

Signed-off-by: Maxime Bajeux <[email protected]>
  • Loading branch information
Maxime Bajeux committed Oct 4, 2024
1 parent d179159 commit ab6852a
Showing 1 changed file with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
USER_TYPE,
PROOF_TYPE,
DOCUMENT_TYPE,
TRACKING_TASK_TAG,
TRACKING_VARIABLES,
LEGAL_LINK1,
Expand Down Expand Up @@ -36,8 +37,10 @@ export default class AccountUserIdentityDocumentsController {
this.TRACKING_TASK_TAG = TRACKING_TASK_TAG;
this.USER_TYPE = USER_TYPE;
this.PROOF_TYPE = PROOF_TYPE;
this.DOCUMENT_TYPE = DOCUMENT_TYPE;
this.DOCUMENTS_MATRIX = DOCUMENTS_MATRIX;
this.isValid = false;
this.hasAadhaarCard = false;
}

$onInit() {
Expand Down Expand Up @@ -114,20 +117,36 @@ export default class AccountUserIdentityDocumentsController {
this.isOpenInformationModal = open;
}

addDocuments(proofType, documentType, files) {
this.files[proofType] = {
document: documentType,
files,
};
addDocuments(proofType, documentType, files, isReset) {
if (isReset) {
delete this.files[proofType];
} else {
this.files[proofType] = {
document: documentType,
files,
};
}
this.checkValidity();
}

checkInvidualValidity() {
this.hasAadhaarCard =
!!this.files[this.PROOF_TYPE.aadhaar_card] ||
!!Object.entries(this.files).find(
([, value]) => value.document === this.DOCUMENT_TYPE.aadhaar_card,
);

const isComplete =
!!this.files[this.PROOF_TYPE.identity] &&
!!this.files[this.PROOF_TYPE.address];

return this.hasAadhaarCard || isComplete;
}

checkValidity() {
this.isValid =
this.user_type === this.USER_TYPE.individual
? this.files[this.PROOF_TYPE.aadhaar_card] ||
(this.files[this.PROOF_TYPE.identity] &&
this.files[this.PROOF_TYPE.address])
? this.checkInvidualValidity()
: Object.keys(this.proofs).reduce(
(acc, proofType) =>
(acc &&
Expand Down

0 comments on commit ab6852a

Please sign in to comment.