Skip to content

Commit d7f18e6

Browse files
committed
fix: refactor useParams
1 parent 6f0a6a3 commit d7f18e6

File tree

11 files changed

+11
-22
lines changed

11 files changed

+11
-22
lines changed

app/(protected)/deeploys/job-draft/[draftId]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ export default function EditJobDraft() {
1919
const { setStep } = useDeploymentContext() as DeploymentContextType;
2020

2121
const router = useRouter();
22-
const params = useParams<{ draftId?: string }>();
23-
const draftId = params?.draftId;
22+
const { draftId } = useParams<{ draftId?: string }>();
2423

2524
const draftJob: DraftJob | undefined | null = useLiveQuery(
2625
draftId ? () => db.jobs.get(parseInt(draftId)) : () => undefined,

app/(protected)/deeploys/job/[jobId]/edit/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export default function EditJob() {
4848
const { setFetchAppsRequired, setStep, escrowContractAddress } = useDeploymentContext() as DeploymentContextType;
4949

5050
const router = useRouter();
51-
const params = useParams<{ jobId?: string }>();
52-
const jobId = params?.jobId;
51+
const { jobId } = useParams<{ jobId?: string }>();
5352
const { job, isLoading: isJobLoading } = useRunningJob(jobId, {
5453
onError: () => router.replace('/404'),
5554
});

app/(protected)/deeploys/job/[jobId]/extend/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import { RiArrowLeftLine } from 'react-icons/ri';
1313

1414
export default function ExtendJob() {
1515
const router = useRouter();
16-
const params = useParams<{ jobId?: string }>();
17-
const jobId = params?.jobId;
16+
const { jobId } = useParams<{ jobId?: string }>();
1817
const { job, isLoading } = useRunningJob(jobId, {
1918
onError: () => router.replace('/404'),
2019
});

app/(protected)/deeploys/job/[jobId]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import { RiArrowLeftLine, RiCloseFill } from 'react-icons/ri';
2525
export default function Job() {
2626
const { fetchApps } = useDeploymentContext() as DeploymentContextType;
2727
const router = useRouter();
28-
const params = useParams<{ jobId?: string }>();
29-
const jobId = params?.jobId;
28+
const { jobId } = useParams<{ jobId?: string }>();
3029

3130
const { job, isLoading, fetchJob } = useRunningJob(jobId, {
3231
onError: () => router.replace(routePath.notFound),

app/(protected)/deeploys/project-draft/[projectHash]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export default function ProjectDraft() {
1717
const { jobType, setJobType, projectPage, setProjectPage } = useDeploymentContext() as DeploymentContextType;
1818

1919
const router = useRouter();
20-
const params = useParams<{ projectHash?: string }>();
21-
const projectHash = params?.projectHash;
20+
const { projectHash } = useParams<{ projectHash?: string }>();
2221

2322
const project: DraftProject | undefined | null = useLiveQuery(
2423
isValidProjectHash(projectHash) ? () => db.projects.get(projectHash) : () => undefined,

app/(protected)/deeploys/project/[projectHash]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ export default function Project() {
3636

3737
const publicClient = usePublicClient();
3838

39-
const params = useParams<{ projectHash?: string }>();
40-
const projectHash = params?.projectHash;
39+
const { projectHash } = useParams<{ projectHash?: string }>();
4140

4241
// Used to display a message with the successfully deployed jobs right after deployment
4342
const [successfulJobs, setSuccessfulJobs] = useState<{ text: string; serverAlias: string }[]>([]);

app/(protected)/tunnels/[id]/page.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ export default function TunnelPage() {
4141
const { confirm } = useInteractionContext() as InteractionContextType;
4242

4343
const router = useRouter();
44-
const params = useParams<{ id?: string }>();
45-
const id = params?.id;
44+
const { id } = useParams<{ id?: string }>();
4645

4746
const [tunnel, setTunnel] = useState<Tunnel | undefined>();
4847

src/components/create-job/JobFormHeader.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import { useEffect, useState } from 'react';
1414
function JobFormHeader({ steps }: { steps: string[] }) {
1515
const { jobType, getProjectName } = useDeploymentContext() as DeploymentContextType;
1616

17-
const params = useParams<{ projectHash?: string }>();
18-
const projectHash = params?.projectHash;
17+
const { projectHash } = useParams<{ projectHash?: string }>();
1918

2019
const [projectName, setProjectName] = useState<string | undefined>();
2120

src/components/create-job/JobFormWrapper.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ const JOB_TYPE_STEPS: Record<JobType, Step[]> = {
3232
};
3333

3434
function JobFormWrapper({ projectName, draftJobsCount }) {
35-
const params = useParams<{ projectHash?: string }>();
36-
const projectHash = params?.projectHash;
35+
const { projectHash } = useParams<{ projectHash?: string }>();
3736

3837
const { step, jobType, setJobType, setProjectOverviewTab } = useDeploymentContext() as DeploymentContextType;
3938
const { account } = useAuthenticationContext() as AuthenticationContextType;

src/components/create-job/steps/deployment/ServiceDeployment.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ function ServiceDeployment({ isEditingRunningJob }: { isEditingRunningJob?: bool
2626
const { tunnelingSecrets } = useTunnelsContext() as TunnelsContextType;
2727

2828
const { watch, setValue } = useFormContext();
29-
const params = useParams<{ projectHash?: string }>();
30-
const projectHash = params?.projectHash;
29+
const { projectHash } = useParams<{ projectHash?: string }>();
3130

3231
const serviceId: number = watch('serviceId');
3332
const alias: string = watch('deployment.jobAlias');

0 commit comments

Comments
 (0)