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 = {
children: React.ReactNode;
params: {
@ -6,7 +8,7 @@ type Props = {
};
};
const IssuesLayout = async (props: Props) => {
const IssuesLayout = (props: Props) => {
const { children } = props;
return <>{children}</>;

View File

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

View File

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