Implement API - OCR SIM

This commit is contained in:
Rizqika 2024-11-20 10:49:54 +07:00
parent 536e5c553d
commit 231c637fa9
3 changed files with 95 additions and 55 deletions

View File

@ -591,55 +591,55 @@ const Verify = () => {
<td style={styles.tableCell}>{data.nik}</td> <td style={styles.tableCell}>{data.nik}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>District</td> <td style={styles.tableCell}>Nama</td>
<td style={styles.tableCell}>{data.district}</td>
</tr>
<tr>
<td style={styles.tableCell}>Name</td>
<td style={styles.tableCell}>{data.name}</td> <td style={styles.tableCell}>{data.name}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>City</td> <td style={styles.tableCell}>Alamat</td>
<td style={styles.tableCell}>{data.city}</td>
</tr>
<tr>
<td style={styles.tableCell}>Date of Birth</td>
<td style={styles.tableCell}>{data.dob}</td>
</tr>
<tr>
<td style={styles.tableCell}>State</td>
<td style={styles.tableCell}>{data.state}</td>
</tr>
<tr>
<td style={styles.tableCell}>Gender</td>
<td style={styles.tableCell}>{data.gender}</td>
</tr>
<tr>
<td style={styles.tableCell}>Religion</td>
<td style={styles.tableCell}>{data.religion}</td>
</tr>
<tr>
<td style={styles.tableCell}>Blood Type</td>
<td style={styles.tableCell}>{data.bloodType}</td>
</tr>
<tr>
<td style={styles.tableCell}>Marital Status</td>
<td style={styles.tableCell}>{data.maritalStatus}</td>
</tr>
<tr>
<td style={styles.tableCell}>Address</td>
<td style={styles.tableCell}>{data.address}</td> <td style={styles.tableCell}>{data.address}</td>
</tr> </tr>
<tr>
<td style={styles.tableCell}>Occupation</td>
<td style={styles.tableCell}>{data.occupation}</td>
</tr>
<tr> <tr>
<td style={styles.tableCell}>RT/RW</td> <td style={styles.tableCell}>RT/RW</td>
<td style={styles.tableCell}>{data.rtRw}</td> <td style={styles.tableCell}>{data.rtRw}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>Nationality</td> <td style={styles.tableCell}>Kecamatan</td>
<td style={styles.tableCell}>{data.district}</td>
</tr>
<tr>
<td style={styles.tableCell}>Kota</td>
<td style={styles.tableCell}>{data.city}</td>
</tr>
<tr>
<td style={styles.tableCell}>Provinsi</td>
<td style={styles.tableCell}>{data.state}</td>
</tr>
<tr>
<td style={styles.tableCell}>Tanggal Lahir</td>
<td style={styles.tableCell}>{data.dob}</td>
</tr>
<tr>
<td style={styles.tableCell}>Jenis Kelamin</td>
<td style={styles.tableCell}>{data.gender}</td>
</tr>
<tr>
<td style={styles.tableCell}>Agama</td>
<td style={styles.tableCell}>{data.religion}</td>
</tr>
<tr>
<td style={styles.tableCell}>Golongan Darah</td>
<td style={styles.tableCell}>{data.bloodType}</td>
</tr>
<tr>
<td style={styles.tableCell}>Status Perkawinan</td>
<td style={styles.tableCell}>{data.maritalStatus}</td>
</tr>
<tr>
<td style={styles.tableCell}>Pekerjaan</td>
<td style={styles.tableCell}>{data.occupation}</td>
</tr>
<tr>
<td style={styles.tableCell}>Kewarganegaraan</td>
<td style={styles.tableCell}>{data.nationality}</td> <td style={styles.tableCell}>{data.nationality}</td>
</tr> </tr>
</tbody> </tbody>

View File

@ -581,11 +581,11 @@ const Verify = () => {
<td style={styles.tableCell}>{data.npwp}</td> <td style={styles.tableCell}>{data.npwp}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>NPWP Name</td> <td style={styles.tableCell}>Nama</td>
<td style={styles.tableCell}>{data.npwpName}</td> <td style={styles.tableCell}>{data.npwpName}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>NPWP Address</td> <td style={styles.tableCell}>Alamat</td>
<td style={styles.tableCell}>{data.npwpAddress}</td> <td style={styles.tableCell}>{data.npwpAddress}</td>
</tr> </tr>
<tr> <tr>

View File

@ -173,7 +173,7 @@ const Verify = () => {
formData.append('file', file); formData.append('file', file);
try { try {
const response = await fetch(`${BASE_URL}/ocr-npwp`, { const response = await fetch(`${BASE_URL}/ocr-sim`, {
method: 'POST', method: 'POST',
headers: { headers: {
'accept': 'application/json', 'accept': 'application/json',
@ -192,14 +192,22 @@ const Verify = () => {
console.log('OCR API Response:', result); console.log('OCR API Response:', result);
if (result.status_code === 201) { if (result.status_code === 201) {
const responseData = result.details.data?.['data-npwp'] || {}; const responseData = result.details.data?.['data-sim'] || {};
const updateQuota = result.details.data.quota const updateQuota = result.details.data.quota
const data = { const data = {
npwp: responseData.npwp || 'N/A', sim: responseData.sim || 'N/A',
npwpName: responseData.name || 'N/A', simName: responseData.name || 'N/A',
npwpAddress: responseData.address || 'N/A', simAddress: responseData.address || 'N/A',
npwpX: responseData.npwp_x || 'N/A', simType: responseData.type || 'N/A',
simValidUntil: responseData.valid_until || 'N/A',
simDomain: responseData.domain || 'N/A',
simBirthPlace: responseData.birthplace || 'N/A',
simDob: responseData.dob || 'N/A',
simGender: responseData.gender || 'N/A',
simHeight: responseData.height || 'N/A',
simBlood: responseData.blood || 'N/A',
simOccupation: responseData.occupation || 'N/A',
imageUrl: result.details.data?.image_url || '', // Properly access image_url imageUrl: result.details.data?.image_url || '', // Properly access image_url
}; };
@ -577,20 +585,52 @@ const Verify = () => {
<table style={styles.tableStyle}> <table style={styles.tableStyle}>
<tbody> <tbody>
<tr> <tr>
<td style={styles.tableCell}>NPWP</td> <td style={styles.tableCell}>SIM</td>
<td style={styles.tableCell}>{data.npwp}</td> <td style={styles.tableCell}>{data.sim}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>NPWP Name</td> <td style={styles.tableCell}>Nama</td>
<td style={styles.tableCell}>{data.npwpName}</td> <td style={styles.tableCell}>{data.simName}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>NPWP Address</td> <td style={styles.tableCell}>Alamat</td>
<td style={styles.tableCell}>{data.npwpAddress}</td> <td style={styles.tableCell}>{data.simAddress}</td>
</tr> </tr>
<tr> <tr>
<td style={styles.tableCell}>NPWP (X)</td> <td style={styles.tableCell}>Tipe</td>
<td style={styles.tableCell}>{data.npwpX}</td> <td style={styles.tableCell}>{data.simType}</td>
</tr>
<tr>
<td style={styles.tableCell}>Masa Berlaku</td>
<td style={styles.tableCell}>{data.simValidUntil}</td>
</tr>
<tr>
<td style={styles.tableCell}>Domisili</td>
<td style={styles.tableCell}>{data.simDomain}</td>
</tr>
<tr>
<td style={styles.tableCell}>Tempat Lahir</td>
<td style={styles.tableCell}>{data.simBirthPlace}</td>
</tr>
<tr>
<td style={styles.tableCell}>Tanggal Lahir</td>
<td style={styles.tableCell}>{data.simDob}</td>
</tr>
<tr>
<td style={styles.tableCell}>Jenis Kelamin</td>
<td style={styles.tableCell}>{data.simGender}</td>
</tr>
<tr>
<td style={styles.tableCell}>TInggi Badan</td>
<td style={styles.tableCell}>{data.simHeight}</td>
</tr>
<tr>
<td style={styles.tableCell}>Golongan Darah</td>
<td style={styles.tableCell}>{data.simBlood}</td>
</tr>
<tr>
<td style={styles.tableCell}>Pekerjaan</td>
<td style={styles.tableCell}>{data.simOccupation}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>