Use query params
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m13s

This commit is contained in:
IshaVenikar 2024-10-18 17:55:46 +05:30
parent 71c202317b
commit 24dccd421a
6 changed files with 31 additions and 47 deletions

View File

@ -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) {

View File

@ -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}`
);
} 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,8 +106,7 @@ 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}`

View File

@ -38,18 +38,8 @@ export const ProjectRepoCard: React.FC<ProjectRepoCardProps> = ({
});
}
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]);

View File

@ -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<Project | null>(null);
const location = useLocation();
const { isAuction } = location.state || {};
const [searchParams] = useSearchParams();
const isAuction = searchParams.get('isAuction') === 'true';
const handleSetupDomain = async () => {
if (id) {

View File

@ -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);

View File

@ -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
}