diff --git a/src/pages/Transaction/TransactionDetails.jsx b/src/pages/Transaction/TransactionDetails.jsx index 61c263b..1b602c6 100644 --- a/src/pages/Transaction/TransactionDetails.jsx +++ b/src/pages/Transaction/TransactionDetails.jsx @@ -9,6 +9,7 @@ import { Text, useColorMode, useToast, + VStack, } from "@chakra-ui/react"; import React, { useContext, useEffect, useState } from "react"; import { MdContentCopy } from "react-icons/md"; @@ -49,28 +50,25 @@ const TransactionDetails = () => { ), }); + setIsLoading(false) }) .catch((err) => { console.error("Failed to copy text: ", err); }); } - - const [ dataArray, setDataArray ] = useState(null) - + const [dataArray, setDataArray] = useState(null); + useEffect(() => { if (data?.data?.pledgeInfo?.pledgeDetails) { - const dataArrayOfObject = Object?.entries(data?.data?.pledgeInfo?.pledgeDetails)?.map(([id, linkedIds]) => ({ id, linkedIds })); - setDataArray(dataArrayOfObject) + const dataArrayOfObject = Object?.entries( + data?.data?.pledgeInfo?.pledgeDetails + )?.map(([id, linkedIds]) => ({ id, linkedIds })); + setDataArray(dataArrayOfObject); } - }, [data]) + }, [data]); console.log(dataArray); - - - - - // ===============================[ Table Header ] const tableHeadRow = [ @@ -95,11 +93,49 @@ const TransactionDetails = () => { ), })); + console.log(data?.data?.blockNumber); + + + + + + const [ isLoadingURL, setIsLoading ] = useState(false) + + const handleGenrateShortURL = async () => { + + setIsLoading(true) + const fullUrl = window.location.href; + try { + const response = await fetch('https://rexplorerapi.azurewebsites.net/api/ShortUrl/create', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(fullUrl), // Sending searchTerm as a JSON string + }); + + if (!response.ok) { + throw new Error('Failed to generate short URL'); + } + + const result = await response.json(); + copyToClipboard(result?.shortUrl) + // You can handle the result here, e.g., by updating a state with the short URL + } catch (error) { + console.error("Error generating short URL:", error); + } + }; + + + + + + + + + - console.log(data?.data?.blockNumber ); - const fullUrl = window.location.href; -console.log(fullUrl); return ( <> @@ -110,17 +146,19 @@ console.log(fullUrl); pb={"5rem"} > - - - {data?.data?.transactionType === "SC" ? "Smart Contract Info":"Transaction Info"} - - + + + {data?.data?.transactionType === "SC" + ? "Smart Contract Info" + : "Transaction Info"} + + Transaction ID - + - - - - Token Information - - + + + Token Information + + {data?.data?.scTokenHash && ( - copyToClipboard(data?.data?.scTokenHash) - } + onClick={() => copyToClipboard(data?.data?.scTokenHash)} /> @@ -253,46 +288,44 @@ console.log(fullUrl); )} - {data?.data?.transactionType === "SC" &&( + {data?.data?.transactionType === "SC" && ( - - Block number: - - - - {data?.data?.blockNumber} - {/* hello */} + + Block number: - - - copyToClipboard(data?.data?.blockNumber) - } - /> - - - + + {data?.data?.blockNumber} + {/* hello */} + + + copyToClipboard(data?.data?.blockNumber)} + /> + + + )} @@ -422,150 +455,137 @@ console.log(fullUrl); )} - - - -{data?.data?.creator&& + + Creator: + + - - Creator: - - navigate(`/did-info/${data?.data?.creator}`)} > - navigate(`/did-info/${data?.data?.creator}`)} - > - {data?.data?.creator} - - - copyToClipboard(data?.data?.creator)} - /> - - - } + {data?.data?.creator} + + + copyToClipboard(data?.data?.creator)} + /> + + + + )} - {data?.data?.executor&& + + Executor: + + - - Executor: - - + navigate(`/did-info/${data?.data?.executor}`) + } > - navigate(`/did-info/${data?.data?.executor}`)} - > - {data?.data?.executor} - - - copyToClipboard(data?.data?.executor)} - /> - - - } + {data?.data?.executor} + + + copyToClipboard(data?.data?.executor)} + /> + + + + )} - - {data?.data?.deployer&& + + Deployer: + + - - Deployer: - - + navigate(`/did-info/${data?.data?.deployer}`) + } > - navigate(`/did-info/${data?.data?.deployer}`)} - > - {data?.data?.deployer} - - - copyToClipboard(data?.data?.deployer)} - /> - - - } - - - - - - - - - - - - - - + {data?.data?.deployer} + + + copyToClipboard(data?.data?.deployer)} + /> + + + + )} - - - - - )} -{data?.data?.pledgeAmount&& - - Pledge Amount: - - - - {data?.data?.pledgeAmount} - - } + {data?.data?.pledgeAmount && ( + + + Pledge Amount: + + + + {data?.data?.pledgeAmount} + + + )} {data?.data?.timestamp && ( Timestamp @@ -615,6 +637,54 @@ console.log(fullUrl); )} + + + + + + Token Link: + + {data?.data?.tokenList?.map(({value,tokenId })=> + + + {tokenId} + + + copyToClipboard(tokenId)} + /> + + + + + + + )} + + + {extractedArray && ( @@ -625,7 +695,7 @@ console.log(fullUrl); /> )} - {dataArray&& } + {dataArray && }