This commit is contained in:
wayanrivan
2025-07-21 10:16:31 +07:00
parent 1ffa8115be
commit 8a375b68e4

View File

@ -50,14 +50,14 @@ const DetailTransaction = () => {
id: selectedTransactionId
});
// setTransactionDetails(response?.data);
if (response?.data.result_edtl) {
// console.log(response?.data.result_edtl)
if (response?.data.result_edtl == undefined) {
setTransactionDetails(response?.data)
setEdtl(null);
} else {
setTransactionDetails(response?.data.detail)
setEdtl(response?.data.result_edtl.data)
} else {
setTransactionDetails(response?.data)
}
// console.log(response?.data.result_edtl.data);
// console.log(selectedTransactionId);
} catch (error) {
console.error('Error fetching transaction', error);
}
@ -134,6 +134,15 @@ const DetailTransaction = () => {
return null;
};
const formatTokenDec = (token) => {
if (token != null && token !== "") {
return token.match(/.{1,4}/g)?.join(" ");
} else {
return "-";
}
};
return (
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden">
@ -305,16 +314,15 @@ const DetailTransaction = () => {
</p>
</div>
{edtl != null && (
<>
<div>
<p className="text-sm text-gray-500">Token KWh EDTL </p>
<p className="text-sm text-gray-500">Token KWh EDTL</p>
<p className="font-medium">
{(edtl.tokenDec ?? "-")
.match(/.{1,4}/g) // bagi per 4 karakter
?.join(" ") // gabungkan dengan spasi
}
{formatTokenDec(edtl.tokenDec)}
</p>
</div>
<div>
<p className="text-sm text-gray-500">Meter SN</p>
<p className="font-medium">
@ -347,6 +355,8 @@ const DetailTransaction = () => {
: "-"}
</p>
</div>
</>
)}
<div>
<p className="text-sm text-gray-500">Provider Type</p>