From 24dccd421ac485ebe2492e1d3053383069ecdf99 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Fri, 18 Oct 2024 17:55:46 +0530 Subject: [PATCH] Use query params --- packages/backend/src/service.ts | 2 - .../components/projects/create/Configure.tsx | 42 +++++++++++-------- .../ProjectRepoCard/ProjectRepoCard.tsx | 14 +------ .../org-slug/projects/create/success/Id.tsx | 6 +-- .../projects/create/template/index.tsx | 12 +----- packages/gql-client/src/mutations.ts | 2 +- 6 files changed, 31 insertions(+), 47 deletions(-) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index ed45fe63..5a5286c9 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -322,8 +322,6 @@ export class Service { ); for (const project of projectsToBedeployed) { - log(`Auction ${project!.auctionId} completed`); - const deployerLrns = await this.laconicRegistry.getAuctionWinningDeployers(project!.auctionId!); if (!deployerLrns) { diff --git a/packages/frontend/src/components/projects/create/Configure.tsx b/packages/frontend/src/components/projects/create/Configure.tsx index e2b46527..d1361788 100644 --- a/packages/frontend/src/components/projects/create/Configure.tsx +++ b/packages/frontend/src/components/projects/create/Configure.tsx @@ -1,6 +1,6 @@ import { useCallback, useState } from 'react'; import { useForm, Controller, SubmitHandler } from 'react-hook-form'; -import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; +import { useNavigate, useSearchParams } from 'react-router-dom'; import { useMediaQuery } from 'usehooks-ts'; import { AuctionParams } from 'gql-client'; @@ -25,8 +25,16 @@ type ConfigureFormValues = { const Configure = () => { const [searchParams] = useSearchParams(); const templateId = searchParams.get('templateId'); - const location = useLocation(); - const { templateOwner, templateRepo, owner, name, isPrivate, orgSlug, repository } = location.state || {}; + const queryParams = new URLSearchParams(location.search); + + const owner = queryParams.get('owner'); + const name = queryParams.get('name'); + const defaultBranch = queryParams.get('defaultBranch'); + const fullName = queryParams.get('fullName'); + const orgSlug = queryParams.get('orgSlug'); + const templateOwner = queryParams.get('templateOwner'); + const templateRepo = queryParams.get('templateRepo'); + const isPrivate = queryParams.get('isPrivate') === 'true'; const navigate = useNavigate(); const { toast, dismiss } = useToast(); @@ -70,7 +78,7 @@ const Configure = () => { }; const { addProjectFromTemplate } = await client.addProjectFromTemplate( - orgSlug, + orgSlug!, projectData, lrn, auctionParams @@ -78,19 +86,18 @@ const Configure = () => { data.option === 'Auction' ? navigate( - `/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}`, - { state: { isAuction: true } } - ) + `/${orgSlug}/projects/create/success/${addProjectFromTemplate.id}?isAuction=true`, + ) : navigate( - `/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}` - ); + `/${orgSlug}/projects/create/template/deploy?projectId=${addProjectFromTemplate.id}&templateId=${templateId}` + ); } else { const { addProject } = await client.addProject( - orgSlug, + orgSlug!, { - name: repository.fullName, - prodBranch: repository.defaultBranch, - repository: repository.fullName, + name: fullName!, + prodBranch: defaultBranch!, + repository: fullName!, template: 'webapp', }, lrn, @@ -99,12 +106,11 @@ const Configure = () => { data.option === 'Auction' ? navigate( - `/${orgSlug}/projects/create/success/${addProject.id}`, - { state: { isAuction: true } } - ) + `/${orgSlug}/projects/create/success/${addProject.id}?isAuction=true` + ) : navigate( - `/${orgSlug}/projects/create/deploy?projectId=${addProject.id}` - ); + `/${orgSlug}/projects/create/deploy?projectId=${addProject.id}` + ); } } catch (error) { console.error('Error creating project:', error); diff --git a/packages/frontend/src/components/projects/create/ProjectRepoCard/ProjectRepoCard.tsx b/packages/frontend/src/components/projects/create/ProjectRepoCard/ProjectRepoCard.tsx index 115ff995..29b4b065 100644 --- a/packages/frontend/src/components/projects/create/ProjectRepoCard/ProjectRepoCard.tsx +++ b/packages/frontend/src/components/projects/create/ProjectRepoCard/ProjectRepoCard.tsx @@ -38,18 +38,8 @@ export const ProjectRepoCard: React.FC = ({ }); } - navigate(`configure`, - { - state: { - repository: { - owner: repository.owner?.login, - name: repository.name, - defaultBranch: repository.default_branch, - fullName: repository.full_name, - }, - orgSlug, - }, - } + navigate( + `configure?owner=${repository.owner?.login}&name=${repository.name}&defaultBranch=${repository.default_branch}&fullName=${repository.full_name}&orgSlug=${orgSlug}` ); }, [client, repository, orgSlug, setIsLoading, navigate, toast]); diff --git a/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx b/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx index 5a0ac2df..66dba7b9 100644 --- a/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx +++ b/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx @@ -1,4 +1,4 @@ -import { Link, useLocation, useParams } from 'react-router-dom'; +import { Link, useParams, useSearchParams } from 'react-router-dom'; import Lottie from 'lottie-react'; import { Badge } from 'components/shared/Badge'; @@ -18,8 +18,8 @@ const Id = () => { const { id, orgSlug } = useParams(); const client = useGQLClient(); const [project, setProject] = useState(null); - const location = useLocation(); - const { isAuction } = location.state || {}; + const [searchParams] = useSearchParams(); + const isAuction = searchParams.get('isAuction') === 'true'; const handleSetupDomain = async () => { if (id) { diff --git a/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx b/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx index 6bcacd05..ebb9f3b9 100644 --- a/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx +++ b/packages/frontend/src/pages/org-slug/projects/create/template/index.tsx @@ -54,17 +54,7 @@ const CreateRepo = () => { setIsLoading(true); navigate( - `configure?templateId=${template.id}`, - { - state: { - templateOwner: owner, - templateRepo: repo, - owner: data.account, - name: data.repoName, - isPrivate: false, - orgSlug - }, - } + `configure?templateId=${template.id}&templateOwner=${owner}&templateRepo=${repo}&owner=${data.account}&name=${data.repoName}&isPrivate=false&orgSlug=${orgSlug}` ); } catch (err) { setIsLoading(false); diff --git a/packages/gql-client/src/mutations.ts b/packages/gql-client/src/mutations.ts index 5a53eb97..1ad04e22 100644 --- a/packages/gql-client/src/mutations.ts +++ b/packages/gql-client/src/mutations.ts @@ -57,7 +57,7 @@ export const addProjectFromTemplate = gql` `; export const addProject = gql` - mutation ($organizationSlug: String!, $data: AddProjectInput!, $lrn: String, $auctionParams: Auctionparams) { + mutation ($organizationSlug: String!, $data: AddProjectInput!, $lrn: String, $auctionParams: AuctionParams) { addProject(organizationSlug: $organizationSlug, data: $data, lrn: $lrn, auctionParams: $auctionParams) { id }