mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { notFound, useSearchParams } 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();
|
|
|
|
type Props = {
|
|
params: {
|
|
workspaceSlug: string;
|
|
projectId: string;
|
|
};
|
|
};
|
|
|
|
const ProjectIssuesPage = (props: Props) => {
|
|
const { params } = props;
|
|
const { workspaceSlug, projectId } = params;
|
|
// states
|
|
const [error, setError] = useState(false);
|
|
// params
|
|
const searchParams = useSearchParams();
|
|
const board = searchParams.get("board") || undefined;
|
|
const peekId = searchParams.get("peekId") || undefined;
|
|
|
|
useEffect(() => {
|
|
if (!workspaceSlug || !projectId) return;
|
|
publishService
|
|
.fetchAnchorFromProjectDetails(workspaceSlug, projectId)
|
|
.then((res) => {
|
|
let url = `/issues/${res.anchor}`;
|
|
const params = new URLSearchParams();
|
|
if (board) params.append("board", board);
|
|
if (peekId) params.append("peekId", peekId);
|
|
if (params.toString()) url += `?${params.toString()}`;
|
|
navigate(url);
|
|
})
|
|
.catch(() => setError(true));
|
|
}, [board, peekId, projectId, workspaceSlug]);
|
|
|
|
if (error) notFound();
|
|
|
|
return <LogoSpinner />;
|
|
};
|
|
|
|
export default ProjectIssuesPage;
|