fix: redirect from old path

This commit is contained in:
Aaryan Khandelwal 2024-06-05 01:21:56 +05:30
parent 83a1b0cf1f
commit 1e59b2789c
3 changed files with 9 additions and 11 deletions

View File

@ -1,3 +1,5 @@
"use client";
type Props = { type Props = {
children: React.ReactNode; children: React.ReactNode;
params: { params: {
@ -6,7 +8,7 @@ type Props = {
}; };
}; };
const IssuesLayout = async (props: Props) => { const IssuesLayout = (props: Props) => {
const { children } = props; const { children } = props;
return <>{children}</>; return <>{children}</>;

View File

@ -1,11 +1,9 @@
"use client"; "use client";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { notFound, useSearchParams } from "next/navigation"; import { notFound, useSearchParams, useRouter } from "next/navigation";
// components // components
import { LogoSpinner } from "@/components/common"; import { LogoSpinner } from "@/components/common";
// helpers
import { navigate } from "@/helpers/actions";
// services // services
import PublishService from "@/services/publish.service"; import PublishService from "@/services/publish.service";
const publishService = new PublishService(); const publishService = new PublishService();
@ -22,6 +20,8 @@ const IssuesPage = (props: Props) => {
const { workspaceSlug, projectId } = params; const { workspaceSlug, projectId } = params;
// states // states
const [error, setError] = useState(false); const [error, setError] = useState(false);
// router
const router = useRouter();
// params // params
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const board = searchParams.get("board"); const board = searchParams.get("board");
@ -39,11 +39,12 @@ const IssuesPage = (props: Props) => {
if (board) params.append("board", board); if (board) params.append("board", board);
if (peekId) params.append("peekId", peekId); if (peekId) params.append("peekId", peekId);
if (params.toString()) url += `?${params.toString()}`; if (params.toString()) url += `?${params.toString()}`;
navigate(url); router.push(url);
// navigate(url);
} else throw Error("Invalid entity name"); } else throw Error("Invalid entity name");
}) })
.catch(() => setError(true)); .catch(() => setError(true));
}, [board, peekId, projectId, workspaceSlug]); }, [board, peekId, projectId, router, workspaceSlug]);
if (error) notFound(); if (error) notFound();

View File

@ -1,5 +0,0 @@
"use server";
import { redirect } from "next/navigation";
export const navigate = async (path: string) => redirect(path);