update logs

This commit is contained in:
wayanrivan
2025-04-29 09:30:28 +07:00
parent 6664abd777
commit 04330e3acf
2 changed files with 61 additions and 49 deletions

View File

@ -504,38 +504,44 @@ const DetailApprovalTransaction = () => {
<table className="min-w-full table-auto"> <table className="min-w-full table-auto">
<thead> <thead>
<tr className="bg-gray-100"> <tr className="bg-gray-100">
<th className="px-4 py-2 text-left text-sm text-gray-500">Status</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Type</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request Date</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Request Date</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request Body</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Date</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Response Body</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Body</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Response Code</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Code</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request End Point</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Request Endpoint</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{transactionDetails?.log && transactionDetails?.log.length > 0 ? ( {transactionDetails?.log && transactionDetails?.log.length > 0 ? (
transactionDetails.log.map((log: { request_endpoint: string, status: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => ( transactionDetails.log.map((log: { type: string, request_endpoint: string, status: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => (
<tr key={index} className="border-t"> <tr key={index} className="border-t">
<td className="px-4 py-2 font-medium"> <td className="px-4 py-2 text-sm text-gray-500">{log.type}</td>
{(() => { <td className="px-4 py-2 text-sm text-gray-500">{log.request_date
let status; ? new Date(log.request_date).toLocaleDateString('en-GB', {
if (log.status === 'P') { day: '2-digit',
status = 'PENDING'; month: '2-digit',
} else if (log.status === 'O') { year: 'numeric',
status = 'ON PROCESS'; hour: '2-digit',
} else if (log.status === 'F') { minute: '2-digit',
status = 'FAILED'; second: '2-digit',
} else if (log.status === 'C') { hour12: false
status = 'COMPLETE'; })
} : ''}</td>
return status; <td className="px-4 py-2 text-sm text-gray-500">{log.response_date
})()} ? new Date(log.response_date).toLocaleDateString('en-GB', {
</td> day: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_date ?? '-'}</td> month: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.response_date ?? '-'}</td> year: 'numeric',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_body ?? '-'}</td> hour: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.response_body ?? '-'}</td> minute: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_endpoint ?? '-'}</td> second: '2-digit',
hour12: false
})
: ''}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.request_body}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.response_body}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.request_endpoint}</td>
</tr> </tr>
)) ))
) : ( ) : (

View File

@ -45,7 +45,7 @@ const DetailTransaction = () => {
id: selectedTransactionId id: selectedTransactionId
}); });
setTransactionDetails(response?.data); setTransactionDetails(response?.data);
// console.log(response?.data); console.log(response?.data);
// console.log(selectedTransactionId); // console.log(selectedTransactionId);
} catch (error) { } catch (error) {
console.error('Error fetching transaction', error); console.error('Error fetching transaction', error);
@ -515,38 +515,44 @@ const DetailTransaction = () => {
<table className="min-w-full table-auto"> <table className="min-w-full table-auto">
<thead> <thead>
<tr className="bg-gray-100"> <tr className="bg-gray-100">
<th className="px-4 py-2 text-left text-sm text-gray-500">Status</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Type</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request Date</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Request Date</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request Body</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Date</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Response Body</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Body</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Response Code</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Response Code</th>
<th className="px-4 py-2 text-left text-sm text-gray-500">Request End Point</th> <th className="px-4 py-2 text-left text-sm text-gray-500">Request Endpoint</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{transactionDetails?.log && transactionDetails?.log.length > 0 ? ( {transactionDetails?.log && transactionDetails?.log.length > 0 ? (
transactionDetails.log.map((log: { request_endpoint: string, status: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => ( transactionDetails.log.map((log: { type: string, request_endpoint: string, status: string; request_date: string; response_date: string; request_body: string; response_body: string; response_code: number }, index: number) => (
<tr key={index} className="border-t"> <tr key={index} className="border-t">
<td className="px-4 py-2 font-medium"> <td className="px-4 py-2 text-sm text-gray-500">{log.type}</td>
{(() => { <td className="px-4 py-2 text-sm text-gray-500">{log.request_date
let status; ? new Date(log.request_date).toLocaleDateString('en-GB', {
if (log.status === 'P') { day: '2-digit',
status = 'PENDING'; month: '2-digit',
} else if (log.status === 'O') { year: 'numeric',
status = 'ON PROCESS'; hour: '2-digit',
} else if (log.status === 'F') { minute: '2-digit',
status = 'FAILED'; second: '2-digit',
} else if (log.status === 'C') { hour12: false
status = 'COMPLETE'; })
} : ''}</td>
return status; <td className="px-4 py-2 text-sm text-gray-500">{log.response_date
})()} ? new Date(log.response_date).toLocaleDateString('en-GB', {
</td> day: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_date ?? '-'}</td> month: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.response_date ?? '-'}</td> year: 'numeric',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_body ?? '-'}</td> hour: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.response_body ?? '-'}</td> minute: '2-digit',
<td className="px-4 py-2 text-sm text-gray-500">{log.request_endpoint ?? '-'}</td> second: '2-digit',
hour12: false
})
: ''}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.request_body}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.response_body}</td>
<td className="px-4 py-2 text-sm text-gray-500">{log.request_endpoint}</td>
</tr> </tr>
)) ))
) : ( ) : (