From bb60023874eeb196ca78edadfb551413fcfc0377 Mon Sep 17 00:00:00 2001 From: Jaxcoder Date: Thu, 21 Sep 2023 13:02:18 -0400 Subject: [PATCH] chore: finish up details/some cleanup --- src/app/pool/[chain]/[id]/page.tsx | 2 -- src/app/pool/page.tsx | 2 +- src/app/profile/[chain]/[id]/page.tsx | 15 ------------ src/components/Address.tsx | 26 ++++++++------------- src/components/Loading.tsx | 20 ++-------------- src/components/Navbar.tsx | 16 ++----------- src/components/Pool/Pool.tsx | 7 +----- src/components/Pool/PoolDetail.tsx | 28 +++++++++++------------ src/components/Pool/types.ts | 1 - src/components/Registry/ProfileDetail.tsx | 2 +- src/components/Table.tsx | 10 ++++---- 11 files changed, 34 insertions(+), 95 deletions(-) diff --git a/src/app/pool/[chain]/[id]/page.tsx b/src/app/pool/[chain]/[id]/page.tsx index 857c14b..952130c 100644 --- a/src/app/pool/[chain]/[id]/page.tsx +++ b/src/app/pool/[chain]/[id]/page.tsx @@ -21,7 +21,6 @@ export default async function PoolDetail({ const { pool }: { pool: TPoolDetail } = poolDetails; - console.log("Details", poolDetails); let poolMetadata = "{}"; try { @@ -32,7 +31,6 @@ export default async function PoolDetail({ // Check if the response status is OK (200) if (response.ok) { poolMetadata = await response.text(); - console.log("Pool metadata ", poolMetadata); } } catch (error) { console.log(error); diff --git a/src/app/pool/page.tsx b/src/app/pool/page.tsx index db273df..19015e9 100644 --- a/src/app/pool/page.tsx +++ b/src/app/pool/page.tsx @@ -6,7 +6,7 @@ import { request } from "graphql-request"; import { Suspense } from "react"; export default async function PoolHome() { - // FIXME: THE API DOES NOT RETURN THE POOL NAME AND STATUS + // FIXME: THE API DOES NOT RETURN THE STATUS const data: any = await request(graphqlEndpoint, getPoolDataQuery); const { pools } = data; diff --git a/src/app/profile/[chain]/[id]/page.tsx b/src/app/profile/[chain]/[id]/page.tsx index 1b9fb2f..9a9c604 100644 --- a/src/app/profile/[chain]/[id]/page.tsx +++ b/src/app/profile/[chain]/[id]/page.tsx @@ -9,20 +9,6 @@ export default async function ProfileDetailPage({ }: { params: { id: string, chain: number }; }) { -// const profile: TProfileDetails = { -// profileId: -// "0x2b4a116a803067abc982458913a2eac20b9348777dbe9795bf3b1aa522160415", -// anchor: "0x3f15B8c6F9939879Cb030D6dd935348E57109637", -// name: "1000x Super Shiba Doge Moon Elon", -// chainId: params.chain, -// creator: "0xa671616e3580D3611139834Cd34D7838e82A04cD", -// metadataProtocol: 1, -// metadataPointer: "bafkreigwiljyskihuaeyjsedoei3taprwbbheldxig25lhoqvw2kpcf4bu", - -// nonce: 1337, -// owner: "0xa671616e3580D3611139834Cd34D7838e82A04cD", -// }; - const profileDetails: any = await request( graphqlEndpoint, getProfileDetailDataQuery, @@ -40,7 +26,6 @@ export default async function ProfileDetailPage({ let metadata = ""; - // Check if the response status is OK (200) if (response.ok) { metadata = await response.text(); } diff --git a/src/components/Address.tsx b/src/components/Address.tsx index 3838f4b..7bdf25c 100644 --- a/src/components/Address.tsx +++ b/src/components/Address.tsx @@ -1,5 +1,3 @@ -"use client"; - import { getNetworks } from "@/utils/networks"; import { TbCopy, TbExternalLink } from "react-icons/tb"; @@ -31,12 +29,7 @@ export const Address = (props: { address: string; chainId: number }) => {
- +
@@ -64,12 +57,7 @@ export const AddressFull = (props: { address: string; chainId: number }) => {
- +
@@ -83,10 +71,14 @@ export const AddressResponsive = (props: { }) => { return (
-
{/* Show on sm screens, hide on md screens */} +
+ {" "} + {/* Show on sm screens, hide on md screens */}
-
{/* Show on md screens, hide on sm screens */} +
+ {" "} + {/* Show on md screens, hide on sm screens */}
@@ -95,4 +87,4 @@ export const AddressResponsive = (props: { export const truncatedString = (str: string) => { return
{str}
; -} +}; diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx index 9eafba7..31835c7 100644 --- a/src/components/Loading.tsx +++ b/src/components/Loading.tsx @@ -1,23 +1,7 @@ export const Loading = () => { return ( -
- - Loading... +
+
); }; diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 148a82b..d2568a9 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,16 +1,9 @@ "use client"; import logo from "@/assets/logo.svg"; -import { Disclosure, Menu, Transition } from "@headlessui/react"; -import { Bars3Icon, BellIcon, XMarkIcon } from "@heroicons/react/24/outline"; +import { Disclosure } from "@headlessui/react"; +import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline"; import Image from "next/image"; import Link from "next/link"; -import { Fragment } from "react"; -// import SelectNetwork from "./SelectNetwork"; -// import Sort from "./Sort"; - -// function classNames(...classes: any) { -// return classes.filter(Boolean).join(" "); -// } const Navbar = () => { return ( @@ -49,11 +42,6 @@ const Navbar = () => {
- {/*
-
- -
-
*/}
{/* Mobile menu button */} diff --git a/src/components/Pool/Pool.tsx b/src/components/Pool/Pool.tsx index ac76438..28fb20e 100644 --- a/src/components/Pool/Pool.tsx +++ b/src/components/Pool/Pool.tsx @@ -1,5 +1,5 @@ "use client"; -// eslint-disable-file react/jsx-key + import Table from "../Table"; import { TTableData } from "@/types/types"; import { Address } from "../Address"; @@ -9,7 +9,6 @@ import { shortenPoolName, } from "@/utils/utils"; import Link from "next/link"; -// import Status from "../Status"; const Pool = ({data, header, description}: {data: any, header?: string, description?: string}) => { @@ -17,10 +16,8 @@ const Pool = ({data, header, description}: {data: any, header?: string, descript headers: [ "ID", "Address", - // "Name", "Token", "Amount", - // "Status", "Profile Name", "Profile Owner", "Network", @@ -37,8 +34,6 @@ const Pool = ({data, header, description}: {data: any, header?: string, descript , // eslint-disable-next-line react/jsx-key
, - // pool.name, FIXME: THE API DOES NOT RETURN THE POOL NAME - // shortenPoolName("Pool Name is really long"), // eslint-disable-next-line react/jsx-key
, formatAmount(pool.amount), diff --git a/src/components/Pool/PoolDetail.tsx b/src/components/Pool/PoolDetail.tsx index 4bb308d..95bd1ef 100644 --- a/src/components/Pool/PoolDetail.tsx +++ b/src/components/Pool/PoolDetail.tsx @@ -1,14 +1,13 @@ "use client"; import { convertChainIdToNetworkName } from "@/utils/utils"; -import { AddressResponsive, truncatedString } from "../Address"; +import { AddressResponsive } from "../Address"; import { TPoolDetail } from "./types"; import { MetadataProtocol } from "@/types/types"; import { TbExternalLink } from "react-icons/tb"; import JsonView from "@uiw/react-json-view"; import { ethers } from "ethers"; import Link from "next/link"; -import { Loading } from "../Loading"; import { getNetworks } from "@/utils/networks"; const PoolDetailPage = ({ @@ -18,15 +17,14 @@ const PoolDetailPage = ({ pool: TPoolDetail; poolMetadata: string; }) => { - - let metadataObj; - try { - metadataObj = JSON.parse(poolMetadata); - } catch (error) { - metadataObj = { - error: "Error parsing metadata", - }; - } + let metadataObj; + try { + metadataObj = JSON.parse(poolMetadata); + } catch (error) { + metadataObj = { + error: "Error parsing metadata", + }; + } return (
@@ -86,7 +84,7 @@ const PoolDetailPage = ({
{ethers.formatUnits( pool.amount ?? 0, - pool.tokenMetadata.decimals ?? 18, + pool.tokenMetadata.decimals ?? 18 )}{" "} {pool.tokenMetadata.symbol ?? getNetworks()[Number(pool.chainId)].symbol} @@ -110,9 +108,11 @@ const PoolDetailPage = ({
{pool.profile.name} - +
- {pool.profile.profileId} + + {pool.profile.profileId} +
diff --git a/src/components/Pool/types.ts b/src/components/Pool/types.ts index 3dd170a..4c3b8b3 100644 --- a/src/components/Pool/types.ts +++ b/src/components/Pool/types.ts @@ -18,5 +18,4 @@ export type TPoolDetail = { symbol: string; decimals: number; }; - }; diff --git a/src/components/Registry/ProfileDetail.tsx b/src/components/Registry/ProfileDetail.tsx index 83a5c16..8ce37a8 100644 --- a/src/components/Registry/ProfileDetail.tsx +++ b/src/components/Registry/ProfileDetail.tsx @@ -18,7 +18,7 @@ const ProfileDetail = ({ }) => { let metadataObj; try { - metadataObj = JSON.parse(metadata); + metadataObj = JSON.parse(metadata ?? ""); } catch (error) { metadataObj = { error: "Error parsing metadata", diff --git a/src/components/Table.tsx b/src/components/Table.tsx index edcfd5f..1f1c478 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -1,5 +1,8 @@ import { TTableData } from "@/types/types"; +/** TODO: the mobile view needs to be completed + * we could create a new component for mobile view entirely +*/ const Table = ({ data, header, @@ -37,7 +40,7 @@ const Table = ({
- + {data.headers.map((header, index) => ( - - - {/* TODO: we need to dynamically display Anchor or Address depnding on profile or pool table */} - - {data.rows.map((row, index) => (
))}
IDAnchress