- Added remote image patterns to the Next.js configuration for enhanced image handling. - Updated TypeScript configuration to exclude the 'implement' directory. - Refactored layout component to fetch initial authentication token and pass it to Providers. - Replaced CanvasToolbar with CanvasSidebar for improved UI layout and functionality. - Enhanced Canvas component with new drag-and-drop file upload capabilities and batch node movement. - Updated various node components to support new status handling and improved user interactions. - Added debounced saving for note and prompt nodes to optimize performance.
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { notFound, redirect } from "next/navigation";
|
|
|
|
import Canvas from "@/components/canvas/canvas";
|
|
import CanvasSidebar from "@/components/canvas/canvas-sidebar";
|
|
import { api } from "@/convex/_generated/api";
|
|
import type { Id } from "@/convex/_generated/dataModel";
|
|
import { fetchAuthQuery, isAuthenticated } from "@/lib/auth-server";
|
|
|
|
export default async function CanvasPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ canvasId: string }>;
|
|
}) {
|
|
const authenticated = await isAuthenticated();
|
|
if (!authenticated) {
|
|
redirect("/auth/sign-in");
|
|
}
|
|
|
|
const { canvasId } = await params;
|
|
let typedCanvasId: Id<"canvases">;
|
|
|
|
if (/^\d+$/.test(canvasId)) {
|
|
const oneBasedIndex = Number(canvasId);
|
|
if (!Number.isSafeInteger(oneBasedIndex) || oneBasedIndex < 1) {
|
|
notFound();
|
|
}
|
|
|
|
const canvases = await fetchAuthQuery(api.canvases.list, {});
|
|
const selectedCanvas = canvases[oneBasedIndex - 1];
|
|
if (!selectedCanvas) {
|
|
notFound();
|
|
}
|
|
|
|
typedCanvasId = selectedCanvas._id;
|
|
} else {
|
|
typedCanvasId = canvasId as Id<"canvases">;
|
|
}
|
|
|
|
try {
|
|
const canvas = await fetchAuthQuery(api.canvases.get, {
|
|
canvasId: typedCanvasId,
|
|
});
|
|
if (!canvas) {
|
|
notFound();
|
|
}
|
|
} catch {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-screen w-screen overflow-hidden">
|
|
<CanvasSidebar />
|
|
<div className="flex-1">
|
|
<Canvas canvasId={typedCanvasId} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|