diff --git a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx index a812094..4b0cda6 100644 --- a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx +++ b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx @@ -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 (
-Token KWh EDTL
-- {(edtl.tokenDec ?? "-") - .match(/.{1,4}/g) // bagi per 4 karakter - ?.join(" ") // gabungkan dengan spasi - } + {edtl != null && ( + <> +
Token KWh EDTL
++ {formatTokenDec(edtl.tokenDec)} +
+Meter SN
-- {edtl.meterSn ?? "-"} -
-Power Steps Desc
-- {edtl.powerStepsDesc ?? "-"} -
-Customer Name
-- {edtl.customerName ?? "-"} -
-Customer Addr
-- {edtl.customerAddr ?? "-"} -
-Amount
-- {edtl.customerPaymentAmount != null - ? new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(edtl.customerPaymentAmount) - : "-"} -
-Meter SN
++ {edtl.meterSn ?? "-"} +
+Power Steps Desc
++ {edtl.powerStepsDesc ?? "-"} +
+Customer Name
++ {edtl.customerName ?? "-"} +
+Customer Addr
++ {edtl.customerAddr ?? "-"} +
+Amount
++ {edtl.customerPaymentAmount != null + ? new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(edtl.customerPaymentAmount) + : "-"} +
+Provider Type