Add feature to detect citizenship and bumpitera right through mykad

This commit is contained in:
afiq.hamzah
2022-08-10 16:42:29 +08:00
parent d08acfd2d2
commit 723f6954cd
+18 -1
View File
@@ -18,6 +18,11 @@ let handleMyKadReader = () => {
getMyKadDetail()
.then(response => myKadDetail = response[0])
.then(() => {
if (myKadDetail.ReadStatus === 'ERROR') {
throw new Error('Sila sambungkan pembaca MyKad dengan betul');
}
})
.then(() => checkIfMyKadExist(myKadDetail.IdNo))
.then(response => response[0])
.then(response => {
@@ -26,10 +31,11 @@ let handleMyKadReader = () => {
} else {
let input_search_noic = document.getElementById("noic");
let form_search_noic = document.querySelector("form[name='frmsearch']");
input_search_noic.value = myKadDetail.IdNo;
input_search_noic.value = myKadDetail.IdNo;
form_search_noic.submit();
}
})
.catch(error => alert(error));
};
@@ -78,11 +84,22 @@ let populateDaftarPelangganModal = (data) => {
return parseInt(days);
};
let getBumiputeraStatus = (ethnicity) => {
const non_bumiputera_ethnicity = ['INDIA', 'CINA'];
let isBumiputera = !non_bumiputera_ethnicity.includes(ethnicity);
return isBumiputera;
};
modal_form.querySelector("input[name='name']").value = data.Name;
modal_form.querySelector("input[name='noic']").value = data.IdNo;
modal_form.querySelector("input[name='tarikh_lahir']").value = getFormattedDateOfBirth(data.DateOfBirth);
modal_form.querySelector("input[name='negeri_lahir']").value = data.State;
modal_form.querySelector("input[name='jantina']").value = data.Gender == 'L' ? 'Lelaki' : 'Perempuan';
modal_form.querySelector("input[name='warganegara']").checked = data.Citizenship === 'WARGANEGARA' ? true : false;
modal_form.querySelector("input[name='bumiputera']").checked = getBumiputeraStatus(data.Ethnicity);
modal_form.querySelector("select[name='agama']").value = getCodeFromValue(data.Religion, religions);
modal_form.querySelector("textarea[name='alamat']").value = [data.Address1, data.Address2, data.Address3].join(", ");
modal_form.querySelector("input[name='poskod']").value = data.Postcode;