- Updated CanvasSidebar to accept canvasId as a prop, enabling dynamic content based on the current canvas. - Refactored CanvasToolbar to implement a dropdown menu for adding nodes, improving usability and organization. - Introduced new node types and updated existing ones in the node template picker for better categorization and searchability. - Enhanced AssetNode to utilize context for asset browser interactions, streamlining asset management on the canvas. - Improved overall layout and styling for better user experience across canvas components.
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import { notFound, redirect } from "next/navigation";
|
|
|
|
import Canvas from "@/components/canvas/canvas";
|
|
import ConnectionBanner from "@/components/canvas/connection-banner";
|
|
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 canvasId={typedCanvasId} />
|
|
<div className="relative min-h-0 min-w-0 flex-1">
|
|
<ConnectionBanner />
|
|
<Canvas canvasId={typedCanvasId} />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|