mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
Merge branch 'refactor/space-app' of github.com:makeplane/plane into refactor/space-app
This commit is contained in:
commit
cf359f6f14
@ -1,17 +0,0 @@
|
||||
"use client";
|
||||
|
||||
type Props = {
|
||||
children: React.ReactNode;
|
||||
params: {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
};
|
||||
|
||||
const IssuesLayout = (props: Props) => {
|
||||
const { children } = props;
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default IssuesLayout;
|
42
space/app/[workspaceSlug]/[projectId]/page.ts
Normal file
42
space/app/[workspaceSlug]/[projectId]/page.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
// types
|
||||
import { TPublishSettings } from "@/types/publish";
|
||||
|
||||
const publishService = new PublishService();
|
||||
|
||||
type Props = {
|
||||
params: {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
searchParams: any;
|
||||
};
|
||||
|
||||
export default async function IssuesPage(props: Props) {
|
||||
const { params, searchParams } = props;
|
||||
// query params
|
||||
const { workspaceSlug, projectId } = params;
|
||||
const { board, peekId } = searchParams;
|
||||
|
||||
let response: TPublishSettings | undefined = undefined;
|
||||
try {
|
||||
response = await publishService.fetchAnchorFromProjectDetails(workspaceSlug, projectId);
|
||||
} catch (error) {
|
||||
// redirect to 404 page on error
|
||||
notFound();
|
||||
}
|
||||
|
||||
let url = "";
|
||||
if (response.entity_name === "project") {
|
||||
url = `/issues/${response.anchor}`;
|
||||
const params = new URLSearchParams();
|
||||
if (board) params.append("board", board);
|
||||
if (peekId) params.append("peekId", peekId);
|
||||
if (params.toString()) url += `?${params.toString()}`;
|
||||
redirect(url);
|
||||
} else {
|
||||
notFound();
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { notFound, useSearchParams, useRouter } from "next/navigation";
|
||||
// components
|
||||
import { LogoSpinner } from "@/components/common";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
const publishService = new PublishService();
|
||||
|
||||
type Props = {
|
||||
params: {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
};
|
||||
|
||||
const IssuesPage = (props: Props) => {
|
||||
const { params } = props;
|
||||
const { workspaceSlug, projectId } = params;
|
||||
// states
|
||||
const [error, setError] = useState(false);
|
||||
// router
|
||||
const router = useRouter();
|
||||
// params
|
||||
const searchParams = useSearchParams();
|
||||
const board = searchParams.get("board");
|
||||
const peekId = searchParams.get("peekId");
|
||||
|
||||
useEffect(() => {
|
||||
if (!workspaceSlug || !projectId) return;
|
||||
publishService
|
||||
.fetchAnchorFromProjectDetails(workspaceSlug, projectId)
|
||||
.then((res) => {
|
||||
let url = "";
|
||||
if (res.entity_name === "project") {
|
||||
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()}`;
|
||||
router.push(url);
|
||||
// navigate(url);
|
||||
} else throw Error("Invalid entity name");
|
||||
})
|
||||
.catch(() => setError(true));
|
||||
}, [board, peekId, projectId, router, workspaceSlug]);
|
||||
|
||||
if (error) notFound();
|
||||
|
||||
return <LogoSpinner />;
|
||||
};
|
||||
|
||||
export default IssuesPage;
|
Loading…
Reference in New Issue
Block a user