update for edtl detail transaction
This commit is contained in:
@ -30,6 +30,7 @@ const DetailTransaction = () => {
|
|||||||
} = useTransactionContext();
|
} = useTransactionContext();
|
||||||
|
|
||||||
const [transactionDetails, setTransactionDetails] = useState<any>(null);
|
const [transactionDetails, setTransactionDetails] = useState<any>(null);
|
||||||
|
const [edtl, setEdtl] = useState<any>(null);
|
||||||
|
|
||||||
const [showResend, setResend] = useState(false);
|
const [showResend, setResend] = useState(false);
|
||||||
|
|
||||||
@ -48,8 +49,14 @@ const DetailTransaction = () => {
|
|||||||
const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionId}`, {
|
const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionId}`, {
|
||||||
id: selectedTransactionId
|
id: selectedTransactionId
|
||||||
});
|
});
|
||||||
setTransactionDetails(response?.data);
|
// setTransactionDetails(response?.data);
|
||||||
// console.log(response?.data);
|
if (response?.data.result_edtl) {
|
||||||
|
setTransactionDetails(response?.data.detail)
|
||||||
|
setEdtl(response?.data.result_edtl.data)
|
||||||
|
} else {
|
||||||
|
setTransactionDetails(response?.data)
|
||||||
|
}
|
||||||
|
// console.log(response?.data.result_edtl.data);
|
||||||
// console.log(selectedTransactionId);
|
// console.log(selectedTransactionId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching transaction', error);
|
console.error('Error fetching transaction', error);
|
||||||
@ -127,35 +134,6 @@ const DetailTransaction = () => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// const [formattedJson, setFormattedJson] = useState('');
|
|
||||||
// const [highlightedJson, setHighlightedJson] = useState('');
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const obj = { a: 1, 'b': 'foo', c: [false, 'false', null, 'null', { d: { e: 1.3e5, f: '1.3e5' } }] };
|
|
||||||
// const str = JSON.stringify(obj, undefined, 4);
|
|
||||||
// setFormattedJson(str);
|
|
||||||
// setHighlightedJson(syntaxHighlight(str));
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
// function syntaxHighlight(json: any) {
|
|
||||||
// json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
||||||
// return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])"(\s:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match: any) {
|
|
||||||
// let cls = 'number';
|
|
||||||
// if (/^"/.test(match)) {
|
|
||||||
// if (/:$/.test(match)) {
|
|
||||||
// cls = 'key';
|
|
||||||
// } else {
|
|
||||||
// cls = 'string';
|
|
||||||
// }
|
|
||||||
// } else if (/true|false/.test(match)) {
|
|
||||||
// cls = 'boolean';
|
|
||||||
// } else if (/null/.test(match)) {
|
|
||||||
// cls = 'null';
|
|
||||||
// }
|
|
||||||
// return '<span className="' + cls + '">' + match + '</span>';
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
||||||
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden">
|
<DialogContent className="container-fixed max-w-[1024px] flex flex-col p-5 overflow-hidden">
|
||||||
@ -326,6 +304,38 @@ const DetailTransaction = () => {
|
|||||||
{transactionDetails?.purchase?.product?.provider?.description ?? "-"}
|
{transactionDetails?.purchase?.product?.provider?.description ?? "-"}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-gray-500">Token KWh EDTL </p>
|
||||||
|
<p className="font-medium">
|
||||||
|
{edtl.tokenDec ?? "-"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-gray-500">Meter SN</p>
|
||||||
|
<p className="font-medium">
|
||||||
|
{edtl.meterSn ?? "-"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-gray-500">Power Steps Desc</p>
|
||||||
|
<p className="font-medium">
|
||||||
|
{edtl.powerStepsDesc ?? "-"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-gray-500">Customer Name</p>
|
||||||
|
<p className="font-medium">
|
||||||
|
{edtl.customerName ?? "-"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p className="text-sm text-gray-500">Customer Addr</p>
|
||||||
|
<p className="font-medium">
|
||||||
|
{edtl.customerAddr ?? "-"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p className="text-sm text-gray-500">Provider Type</p>
|
<p className="text-sm text-gray-500">Provider Type</p>
|
||||||
<p className="font-medium">
|
<p className="font-medium">
|
||||||
|
|||||||
Reference in New Issue
Block a user