Files
rubix-explore/src/pages/MainNetIdOverview.jsx

308 lines
12 KiB
React
Raw Normal View History

2024-10-17 18:00:44 +05:30
import { Box, Container, Grid, GridItem, Heading, HStack, Icon, Link, Select, Text, useColorMode, useToast, VStack } from "@chakra-ui/react";
2024-10-15 10:57:09 +05:30
import React, { useContext, useEffect } from "react";
import GlobalStateContext from "../Contexts/GlobalStateContext";
import Pagination from "../components/Pagination";
import { MdContentCopy, MdOutlineErrorOutline } from "react-icons/md";
import ToastBox from "../components/ToastBox";
import bannerImage from "../assets/images/bannerImg.png";
import { useParams } from "react-router-dom";
const MainNetOveriew = () => {
const { overview } = useContext(GlobalStateContext);
const { colorMode} = useColorMode();
const params = useParams()
const toast = useToast()
useEffect(() => {
window.scrollTo({ top: 0, behavior: "smooth" }); // Scroll to top smoothly when params change
}, []);
function copyToClipboard(text) {
navigator.clipboard
.writeText(text)
.then(() => {
// console.log('Text copied to clipboard');
// alert('Text copied to clipboard');
toast({
render: () => (
<ToastBox status={"warn"} message={"Text copied to clipboard"} />
),
});
})
.catch((err) => {
console.error("Failed to copy text: ", err);
});
}
return (
2024-10-23 16:09:56 +05:30
<Box minH={"100vh"} p={"6rem 0 4rem 0"} backgroundImage={colorMode !== "light" ? `url(${bannerImage})` : "none"} position={"relative"} backgroundSize="contain" backgroundRepeat="no-repeat">
2024-10-15 10:57:09 +05:30
<Container
maxW="6xl"
color="white"
2024-10-17 18:00:44 +05:30
display={{base :"block",md : "flex"}}
2024-10-15 10:57:09 +05:30
justifyContent={"space-between"}
mb={10}
>
2024-10-17 18:00:44 +05:30
<Heading fontSize={"md"} fontWeight={400} color={colorMode === "light" ? "#000" : "#fff"} mb={{base :"10px" ,md : "0px"}}>
2024-10-15 10:57:09 +05:30
Main net ID - {params?.id}
</Heading>
2024-10-22 15:27:47 +05:30
{/* <Text to="" style={{ fontSize: "14px" }} color={colorMode === "light" ? "#000" : "#fff"} display={"flex"} gap={"3"}>
2024-10-15 10:57:09 +05:30
View total number of records
<Select width={"70px"} rounded="md" size="xs">
<option value='option1'>10</option>
<option value='option2'>20</option>
<option value='option3'>30</option>
</Select>
2024-10-22 15:27:47 +05:30
</Text> */}
2024-10-15 10:57:09 +05:30
</Container>
<Box>
<Container maxW="6xl">
<Grid
2024-10-21 17:23:35 +05:30
templateColumns={{ base: "100% 0%", md: "10% 90%" }}
2024-10-15 10:57:09 +05:30
gap={0}
bg={colorMode === "light" ? "#230A79" : "#232127"}
// bg={"#232127"}
borderTopRightRadius={4}
borderTopLeftRadius={4}
>
2024-10-21 17:23:35 +05:30
<GridItem p={2} display={{ base: "none", md: "grid" }}>
2024-10-15 10:57:09 +05:30
<Text color={"#fff"}>Sr. no</Text>
</GridItem>
2024-10-21 17:23:35 +05:30
<GridItem p={2} >
2024-10-15 10:57:09 +05:30
<Text color={"#fff"}>Transactions</Text>
</GridItem>
</Grid>
<Box boxShadow={"rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;"}>
{overview.map((transaction, index) => (
<Grid
bg={
2024-10-17 18:00:44 +05:30
index % 2 === 0
2024-10-15 10:57:09 +05:30
? colorMode === "light"
2024-10-17 18:00:44 +05:30
? "#F2EFFF"
: "#312F35"
2024-10-15 10:57:09 +05:30
: colorMode === "light"
? "#fff"
: "#232127"
}
key={transaction.id}
2024-10-17 18:00:44 +05:30
templateColumns={{ base: "100% 0%", md: "10% 90%" }}
2024-10-15 10:57:09 +05:30
gap={0}
2024-10-17 18:00:44 +05:30
>
<GridItem
display={{ base: "none", md: "grid" }}
p={4}
color={colorMode === "light" ? "#000" : "#fff"}
2024-10-15 10:57:09 +05:30
>
2024-10-17 18:00:44 +05:30
{index + 1}.
2024-10-15 10:57:09 +05:30
</GridItem>
2024-10-17 18:00:44 +05:30
<GridItem p={4}>
{/* <Box> */}
<Text // This ensures the text is truncated with ellipsis when it overflows ss__298
display={"flex"}
fontSize={{base:"xs", md:"sm" }}
mb={2}
color={colorMode === "light" ? "#230A79" : "#B09AFF"}
>
2024-10-15 10:57:09 +05:30
<Text
2024-10-17 18:00:44 +05:30
maxW={{base:"100%",md:"100%"}} // Set a max-width to control when the truncation happens
// overflow={'hidden'} // Ensure overflow is hidden
whiteSpace={"nowrap"} // Prevent the text from wrapping
textOverflow={"ellipsis"}
isTruncated
cursor={"pointer"}
onClick={() =>
navigate(`/transaction/${transaction?.description}`)
}
2024-10-15 10:57:09 +05:30
>
2024-10-17 18:00:44 +05:30
{transaction.description}
2024-10-15 10:57:09 +05:30
</Text>
2024-10-17 18:00:44 +05:30
<Text
_hover={{ bg: "gray.50" }}
transition={"0.5s"}
rounded={"sm"}
p={1}
as={"span"}
ml={1}
cursor={"pointer"}
>
<MdContentCopy
onClick={() => copyToClipboard(transaction.description)}
/>
</Text>
</Text>
<HStack fontSize={{base:"xs", md:"sm" }} gap={{base:2,md:4}} mb={2}>
<Text color={colorMode === "light" ? "#0F0F0F" : "#E8E8E8"}>
Sender:
</Text>
2024-10-15 10:57:09 +05:30
<HStack
2024-10-17 18:00:44 +05:30
color={colorMode === "light" ? "#230A79" : "#B09AFF"}
textDecoration={"underline"}
w={'84%'}
justifyContent={'space-between'}
fontSize={{base:"xs", md:"sm" }}
2024-10-15 10:57:09 +05:30
>
2024-10-17 18:00:44 +05:30
<Text
cursor={"pointer"}
maxW={{base:"90%",md:"100%"}} // Set a max-width to control when the truncation happens
// overflow={'hidden'} // Ensure overflow is hidden
whiteSpace={"nowrap"} // Prevent the text from wrapping
textOverflow={"ellipsis"}
isTruncated
onClick={() =>
navigate(`/did-info/${transaction.sender}`)
}
>
{transaction.sender}
</Text>
<Text
_hover={{ bg: "gray.50" }}
transition={"0.5s"}
rounded={"sm"}
p={1}
as={"span"}
ml={1}
cursor={"pointer"}
>
<MdContentCopy
onClick={() => copyToClipboard(transaction.sender)}
/>
</Text>
</HStack>
</HStack>
<HStack fontSize={{base:"xs", md:"sm" }} cursor={"pointer"} gap={{base:2,md:4}} mb={3}>
<Text color={colorMode === "light" ? "#0F0F0F" : "#E8E8E8"}>
Receiver:
</Text>
<HStack
color={colorMode === "light" ? "#230A79" : "#B09AFF"}
textDecoration={"underline"}
fontSize={{base:"xs", md:"sm" }}
2024-10-21 17:23:35 +05:30
isTruncated
2024-10-17 18:00:44 +05:30
>
<Text
cursor={"pointer"}
maxW={{base:"55%",md:"100%"}}
whiteSpace={"nowrap"} // Prevent the text from wrapping
textOverflow={"ellipsis"}
isTruncated
onClick={() =>
navigate(`/did-info/${transaction.receiver}`)
}
>
{transaction.receiver}
</Text>
<Text
_hover={{ bg: "gray.50" }}
transition={"0.5s"}
rounded={"sm"}
p={1}
as={"span"}
ml={1}
cursor={"pointer"}
>
<MdContentCopy
onClick={() => copyToClipboard(transaction.receiver)}
/>
</Text>
</HStack>
</HStack>
<HStack
flexDirection={{ base: "column", md: "row" }}
justifyContent={{ base: "", md: "space-between" }}
alignItems={{ base: "flex-start", md: "" }}
// flexWrap={'wrap'}
// w={"80%"}
w={{ base: "100%", md: "80%" }}
fontSize={{ base: "xs", md: "sm" }}
mb={3}
>
<Box>
<Text
mb={2}
// fontSize={{base:"xs", md:"sm" }}
color={colorMode === "light" ? "#7B7B7B" : "#E8E8E8"}
>
Smart contract ID :
</Text>
<Text color={colorMode === "light" ? "#230A79" : "#B09AFF"}>
<Link to="/smart-contract">{transaction.contract}</Link>
</Text>
</Box>
<Box>
<Text
mb={2}
color={colorMode === "light" ? "#7B7B7B" : "#E8E8E8"}
>
Date and Time Stamp :
</Text>
<Text color={colorMode === "light" ? "#230A79" : "#B09AFF"}>
{transaction.date}
</Text>
</Box>
<Box>
<Text
mb={2}
color={colorMode === "light" ? "#7B7B7B" : "#E8E8E8"}
>
Amount:
</Text>
<Text color={colorMode === "light" ? "#230A79" : "#B09AFF"}>
{transaction.amount}
</Text>
</Box>
</HStack>
<HStack
fontSize={"sm"}
alignItems={"flex-start"}
position={"relative"}
>
<Icon
as={MdOutlineErrorOutline}
fontSize={"18px"}
display={{ base: "none", md: "block" }}
style={{
marginTop: "1px",
position: "absolute",
top: "2px",
left: "-24px",
}}
color="#7B7B7B"
/>
<VStack fontSize={{base:"xs", md:"sm" }}>
<HStack w={"100%"} justifyContent={"flex-start"}>
2024-10-15 10:57:09 +05:30
<Text
2024-10-17 18:00:44 +05:30
color={colorMode === "light" ? "#7B7B7B" : "#E8E8E8"}
2024-10-15 10:57:09 +05:30
>
2024-10-17 18:00:44 +05:30
Transaction type :
2024-10-15 10:57:09 +05:30
</Text>
<Text
2024-10-17 18:00:44 +05:30
color={colorMode === "light" ? "#230A79" : "#B09AFF"}
2024-10-15 10:57:09 +05:30
>
2024-10-17 18:00:44 +05:30
<Text>{transaction.transactionType}</Text>
2024-10-15 10:57:09 +05:30
</Text>
2024-10-17 18:00:44 +05:30
</HStack>
</VStack>
</HStack>
{/* </Box> */}
2024-10-15 10:57:09 +05:30
</GridItem>
2024-10-17 18:00:44 +05:30
</Grid>
2024-10-15 10:57:09 +05:30
))}
</Box>
<Pagination />
</Container>
</Box>
</Box>
);
};
export default MainNetOveriew;