From 002849afdcb5e6453dc945faa11f4aa7334714d0 Mon Sep 17 00:00:00 2001 From: YasinShaikh123 <123150391+YasinShaikh123@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:13:39 +0530 Subject: [PATCH 1/2] update button --- src/Services/api.service.js | 12 ++--- src/pages/DidInfo.jsx | 55 ++++++++++++++++---- src/pages/Home.jsx | 2 +- src/pages/SubnetIdOverview.jsx | 37 ++++++++++++- src/pages/Transaction/TransactionDetails.jsx | 15 ++---- 5 files changed, 91 insertions(+), 30 deletions(-) diff --git a/src/Services/api.service.js b/src/Services/api.service.js index ba9c4a9..eafec9c 100644 --- a/src/Services/api.service.js +++ b/src/Services/api.service.js @@ -90,16 +90,16 @@ export const rubix = createApi({ }), - // getSubnetAll: builder.query({ - // query: ({ pageNumber = 1, pageSize = 10 }) => `SubNet/GetAllSubnetworks?pageNumber=${pageNumber}&pageSize=${pageSize}`, - // providesTags: ["getTransAll"], - // }), - getSubnetAll: builder.query({ - query: ({ pageNumber = 1, pageSize = 10 }) => `SubNet/GetAllSubnetworks?pageNumber=${pageNumber}&pageSize=${pageSize}?subnetId=${searchTerm || ""}`, + query: ({ pageNumber = 1, pageSize = 10 }) => `SubNet/GetAllSubnetworks?pageNumber=${pageNumber}&pageSize=${pageSize}`, providesTags: ["getTransAll"], }), + // getSubnetAll: builder.query({ + // query: ({ pageNumber = 1, pageSize = 10 }) => `SubNet/GetAllSubnetworks?pageNumber=${pageNumber}&pageSize=${pageSize}?subnetId=${searchTerm || ""}`, + // providesTags: ["getTransAll"], + // }), + gnerateShortUrl: builder.mutation({ query: (data) => ({ diff --git a/src/pages/DidInfo.jsx b/src/pages/DidInfo.jsx index 6be11d7..3ff02e3 100644 --- a/src/pages/DidInfo.jsx +++ b/src/pages/DidInfo.jsx @@ -1,5 +1,6 @@ import { Box, + Button, Container, Divider, Heading, @@ -9,7 +10,7 @@ import { useColorMode, useToast, } from "@chakra-ui/react"; -import React, { useEffect } from "react"; +import React, { useEffect, useState } from "react"; import { MdContentCopy } from "react-icons/md"; import { Link, useNavigate, useParams } from "react-router-dom"; import RelatedTransactions from "../components/RelatedTransactions/RelatedTransactions"; @@ -22,6 +23,9 @@ import FullScreenLoaader from "../components/FullScreenLoaader/FullScreenLoaader import { OPACITY_ON_LOAD } from "../Layout/animations"; const DidInfo = () => { + + const [ isLoadingURL, setIsLoading ] = useState(false) + useEffect(() => { window.scrollTo({ top: 0, behavior: "smooth" }); // Scroll to top smoothly when params change }, []); @@ -42,6 +46,7 @@ const DidInfo = () => { ), }); + setIsLoading(false) }) .catch((err) => { console.error("Failed to copy text: ", err); @@ -55,6 +60,31 @@ const DidInfo = () => { console.log(data?.message); + 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); + } + }; + return ( isLoading? @@ -73,15 +103,20 @@ const DidInfo = () => { pb={"8rem"} > - - DID Info - - + + + DID Info + + + + {data?.data ? - View all + View all diff --git a/src/pages/SubnetIdOverview.jsx b/src/pages/SubnetIdOverview.jsx index 1856e62..45fb917 100644 --- a/src/pages/SubnetIdOverview.jsx +++ b/src/pages/SubnetIdOverview.jsx @@ -1,4 +1,4 @@ -import { Box, Container, Grid, Image,GridItem, Heading, HStack, Icon, Link, Select, Text, useColorMode, useToast, VStack } from "@chakra-ui/react"; +import { Box, Container, Grid, Image,GridItem, Heading, HStack, Icon, Link, Select, Text, useColorMode, useToast, VStack, Button } from "@chakra-ui/react"; import React, { useContext, useEffect, useState } from "react"; import GlobalStateContext from "../Contexts/GlobalStateContext"; import Pagination from "../components/Pagination"; @@ -26,6 +26,7 @@ const SubnetInner = () => { const [totalItems, setTotalItems] = useState(null); // Total items in the dataset const [lastRefreshedTime, setLastRefreshedTime] = useState(new Date()); // Store the last refresh time const [relativeRefreshTime, setRelativeRefreshTime] = useState("Just now"); + const [ isLoadingURL, setIsLoading ] = useState(false) const toast = useToast() useEffect(() => { @@ -43,6 +44,7 @@ const SubnetInner = () => { ), }); + setIsLoading(false) }) .catch((err) => { console.error("Failed to copy text: ", err); @@ -96,6 +98,31 @@ const SubnetInner = () => { } }; + 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); + } + }; + return ( @@ -104,7 +131,7 @@ const SubnetInner = () => { color="white" display={{base :"block",md : "flex"}} justifyContent={"space-between"} - mb={10} + mb={5} > Subnet ID - {params?.id} @@ -121,6 +148,12 @@ const SubnetInner = () => { */} + + + {data?.data?.items?.length===0 || isLoading? diff --git a/src/pages/Transaction/TransactionDetails.jsx b/src/pages/Transaction/TransactionDetails.jsx index d511ea4..20464bb 100644 --- a/src/pages/Transaction/TransactionDetails.jsx +++ b/src/pages/Transaction/TransactionDetails.jsx @@ -127,16 +127,6 @@ const TransactionDetails = () => { }; - - - - - - - - - - return ( <> { ? "Smart Contract Info" : "Transaction Info"} - + Date: Mon, 4 Nov 2024 17:42:24 +0530 Subject: [PATCH 2/2] update btn color --- src/pages/DidInfo.jsx | 2 +- src/pages/SubnetId.jsx | 2 +- src/pages/SubnetIdOverview.jsx | 7 ++++--- src/pages/Transaction/TransactionDetails.jsx | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/DidInfo.jsx b/src/pages/DidInfo.jsx index 3ff02e3..8922fd6 100644 --- a/src/pages/DidInfo.jsx +++ b/src/pages/DidInfo.jsx @@ -112,7 +112,7 @@ const DidInfo = () => { DID Info - diff --git a/src/pages/SubnetId.jsx b/src/pages/SubnetId.jsx index 0bb1992..a4ce62a 100644 --- a/src/pages/SubnetId.jsx +++ b/src/pages/SubnetId.jsx @@ -191,7 +191,7 @@ const SubnetId = () => { fontSize={"sm"} rounded={0} border="none" - bg={colorMode === "light" ? "#4023A6" : "#565252"} + bg={colorMode === "light" ? "#230A79" : "#565252"} _hover={{ opacity: 0.9, bg: colorMode !== "light" && "#333248", diff --git a/src/pages/SubnetIdOverview.jsx b/src/pages/SubnetIdOverview.jsx index 45fb917..8b34972 100644 --- a/src/pages/SubnetIdOverview.jsx +++ b/src/pages/SubnetIdOverview.jsx @@ -12,6 +12,7 @@ import { HiOutlineRefresh } from "react-icons/hi"; import { rotate } from "../components/LatestTransactions/LatestTransactions"; import Search from '../assets/images/search.png' import { formatUTCToDDMMYYHHMMSS } from "../Constants/Constants"; +import FullScreenLoaader from "../components/FullScreenLoaader/FullScreenLoaader"; const SubnetInner = () => { @@ -149,12 +150,12 @@ const SubnetInner = () => { */} - - + {isLoading ? : {data?.data?.items?.length===0 || isLoading? {"No records found"} @@ -487,7 +488,7 @@ const SubnetInner = () => { currentPage={currentPage} /> } - + } ); }; diff --git a/src/pages/Transaction/TransactionDetails.jsx b/src/pages/Transaction/TransactionDetails.jsx index 72adbd9..95461c3 100644 --- a/src/pages/Transaction/TransactionDetails.jsx +++ b/src/pages/Transaction/TransactionDetails.jsx @@ -148,7 +148,7 @@ const TransactionDetails = () => { ? "Smart Contract Info" : "Transaction Info"} -