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] 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"}
-
+