[WEB-5042] feat: sites vite migration (#7965)
This commit is contained in:
parent
315e1d5eb0
commit
118ecc81ba
126 changed files with 1062 additions and 739 deletions
|
|
@ -1,41 +0,0 @@
|
|||
import { notFound, redirect } from "next/navigation";
|
||||
// plane imports
|
||||
import { SitesProjectPublishService } from "@plane/services";
|
||||
import type { TProjectPublishSettings } from "@plane/types";
|
||||
|
||||
const publishService = new SitesProjectPublishService();
|
||||
|
||||
type Props = {
|
||||
params: {
|
||||
workspaceSlug: string;
|
||||
projectId: string;
|
||||
};
|
||||
searchParams: Record<"board" | "peekId", string | string[] | undefined>;
|
||||
};
|
||||
|
||||
export default async function IssuesPage(props: Props) {
|
||||
const { params, searchParams } = props;
|
||||
// query params
|
||||
const { workspaceSlug, projectId } = params;
|
||||
const { board, peekId } = searchParams;
|
||||
|
||||
let response: TProjectPublishSettings | undefined = undefined;
|
||||
try {
|
||||
response = await publishService.retrieveSettingsByProjectId(workspaceSlug, projectId);
|
||||
} catch (error) {
|
||||
console.error("Error fetching project publish settings:", error);
|
||||
notFound();
|
||||
}
|
||||
|
||||
let url = "";
|
||||
if (response?.entity_name === "project") {
|
||||
url = `/issues/${response?.anchor}`;
|
||||
const params = new URLSearchParams();
|
||||
if (board) params.append("board", String(board));
|
||||
if (peekId) params.append("peekId", String(peekId));
|
||||
if (params.toString()) url += `?${params.toString()}`;
|
||||
redirect(url);
|
||||
} else {
|
||||
notFound();
|
||||
}
|
||||
}
|
||||
53
apps/space/app/[workspaceSlug]/[projectId]/page.tsx
Normal file
53
apps/space/app/[workspaceSlug]/[projectId]/page.tsx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
"use client";
|
||||
|
||||
import { redirect } from "react-router";
|
||||
import type { ClientLoaderFunctionArgs } from "react-router";
|
||||
// plane imports
|
||||
import { SitesProjectPublishService } from "@plane/services";
|
||||
import type { TProjectPublishSettings } from "@plane/types";
|
||||
// components
|
||||
import { LogoSpinner } from "@/components/common/logo-spinner";
|
||||
|
||||
const publishService = new SitesProjectPublishService();
|
||||
|
||||
export const clientLoader = async ({ params, request }: ClientLoaderFunctionArgs) => {
|
||||
const { workspaceSlug, projectId } = params;
|
||||
|
||||
// Validate required params
|
||||
if (!workspaceSlug || !projectId) {
|
||||
throw redirect("/404");
|
||||
}
|
||||
|
||||
// Extract query params from the request URL
|
||||
const url = new URL(request.url);
|
||||
const board = url.searchParams.get("board");
|
||||
const peekId = url.searchParams.get("peekId");
|
||||
|
||||
let response: TProjectPublishSettings | undefined = undefined;
|
||||
|
||||
try {
|
||||
response = await publishService.retrieveSettingsByProjectId(workspaceSlug, projectId);
|
||||
} catch {
|
||||
throw redirect("/404");
|
||||
}
|
||||
|
||||
if (response?.entity_name === "project") {
|
||||
let redirectUrl = `/issues/${response?.anchor}`;
|
||||
const urlParams = new URLSearchParams();
|
||||
if (board) urlParams.append("board", String(board));
|
||||
if (peekId) urlParams.append("peekId", String(peekId));
|
||||
if (urlParams.toString()) redirectUrl += `?${urlParams.toString()}`;
|
||||
|
||||
throw redirect(redirectUrl);
|
||||
} else {
|
||||
throw redirect("/404");
|
||||
}
|
||||
};
|
||||
|
||||
export default function IssuesPage() {
|
||||
return (
|
||||
<div className="flex h-screen min-h-[500px] w-full justify-center items-center">
|
||||
<LogoSpinner />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue