Skip to content

Commit

Permalink
fix: add long document number support
Browse files Browse the repository at this point in the history
  • Loading branch information
felixindrawan committed Dec 10, 2024
1 parent 4ea534d commit a44e22c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ export function extractDocumentFields(result) {
};
};

const getDocumentNumber = (documentType) => {
const primaryField = documentType === "P" ? "passportNumber" : "documentNumber";
const primaryNumber = fieldWithStatus(primaryField);
const longNumber = fieldWithStatus("longDocumentNumber");

return primaryNumber?.text ? primaryNumber : longNumber;
};

const documentType = result.getFieldValue("documentCode");
const documentNumberField = documentType === "P" ? "passportNumber" : "documentNumber";

return {
Surname: fieldWithStatus("primaryIdentifier"),
"Given Name": fieldWithStatus("secondaryIdentifier"),
Nationality: fieldWithStatus("nationality"),
"Document Number": fieldWithStatus(documentNumberField),
"Document Number": getDocumentNumber(documentType),
"Issuing State": fieldWithStatus("issuingState"),
Sex: fieldWithStatus("sex"),
"Date of Birth (YYYY-MM-DD)": parseDate("birthYear", "birthMonth", "birthDay"),
Expand Down

0 comments on commit a44e22c

Please sign in to comment.