From 37518b97b6eb43d8080328cbe5c4a295dad066d3 Mon Sep 17 00:00:00 2001 From: Ruben Torres Date: Fri, 29 Jul 2022 22:30:24 -0400 Subject: [PATCH] Fix Issue #1 - Get max project id from project list regardless of sorting - Make sure core contract address is lower case for the query to work properly - Fix live view links --- src/components/ProjectList.tsx | 7 ++++--- src/components/TokenPreview.tsx | 2 +- src/components/pages/ProjectPage.tsx | 2 +- src/hooks/useProject.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/ProjectList.tsx b/src/components/ProjectList.tsx index b2fd381..8f0f69d 100644 --- a/src/components/ProjectList.tsx +++ b/src/components/ProjectList.tsx @@ -27,9 +27,10 @@ const ProjectList = () => { useEffect(() => { if (data?.projects?.length) { - const { projectId } = data.projects[data.projects.length - 1]; - if (projectId > highestProjectId) { - setHighestProjectId(projectId); + const projectIds = data.projects.map((project: Project) => Number(project.projectId)); + const maxProjectId = Math.max(...projectIds); + if (maxProjectId > highestProjectId) { + setHighestProjectId(maxProjectId); } } }, [data, data?.projects, highestProjectId]); diff --git a/src/components/TokenPreview.tsx b/src/components/TokenPreview.tsx index 89391fd..43396e4 100644 --- a/src/components/TokenPreview.tsx +++ b/src/components/TokenPreview.tsx @@ -72,7 +72,7 @@ const TokenPreview = ({ padding: [0, 0, 'default'] }} onClick={() => { - window.open(`${generatorUrl}/${tokenId}`); + window.open(`${generatorUrl}/${coreContractAddress?.toLowerCase()}/${tokenId}`); }} > diff --git a/src/components/pages/ProjectPage.tsx b/src/components/pages/ProjectPage.tsx index 948fb1f..e406ace 100644 --- a/src/components/pages/ProjectPage.tsx +++ b/src/components/pages/ProjectPage.tsx @@ -11,7 +11,7 @@ const ProjectPage = () => { { projectId ? ( - + ) : ( Project not found diff --git a/src/hooks/useProject.ts b/src/hooks/useProject.ts index a4e1257..947b1a4 100644 --- a/src/hooks/useProject.ts +++ b/src/hooks/useProject.ts @@ -6,7 +6,7 @@ import { const projectQuery = (id: string) => ` query GetProject { project( - id: "${id}" + id: "${id.toLowerCase()}" ) { id projectId