import { Separator } from "@/components/ui/separator"; // import { db, schema } from "@/lib/db"; // import { ingestAuditLogs } from "@/lib/tinybird"; // import { auth } from "@clerk/nextjs"; // import { newId } from "@aigxion/id"; import { ArrowRight } from "lucide-react"; import { headers } from "next/headers"; import Link from "next/link"; import { notFound, redirect } from "next/navigation"; import { CreateApi } from "./create-api"; import { AsideContent, CreateWorkspace } from "./create-workspace"; import { Keys } from "./keys"; import { nanoid } from "nanoid"; import { auth } from '@/auth' import { Session } from '@/lib/types' import { getMissingKeys } from '../../actions' import { Chat as ChatAI } from '@/components-ai/chat' import { AI } from '@/lib/chat/actions' import { ChatStaff } from "@/components/chat-staff"; type Props = { searchParams: { workspaceId?: string; apiId?: string; }; }; type PropsHeader = { title: React.ReactNode; description?: string; /** * A set of components displayed in the top right * null components are filtered out */ actions?: React.ReactNode[]; }; const PageHeader: React.FC = ({ title, description, actions }) => { const actionRows: React.ReactNode[][] = []; if (actions) { for (let i = 0; i < actions.length; i += 3) { actionRows.push(actions.slice(i, i + 3)); } } return (

{title}

{description}

{actionRows.map((row, i) => ( ))}
); }; export default async function (props: Props) { // const { userId } = auth(); // if (props.searchParams.apiId) { // const api = await db.query.apis.findFirst({ // where: (table, { eq }) => eq(table.id, props.searchParams.apiId!), // }); // if (!api) { // return notFound(); // } // return ( //
// // Skip {" "} // , // ]} // /> // // //
// ); // } // if (props.searchParams.workspaceId) { // const workspace = await db.query.workspaces.findFirst({ // where: (table, { and, eq, isNull }) => // and(eq(table.id, props.searchParams.workspaceId!), isNull(table.deletedAt)), // }); // if (!workspace) { // return redirect("/new"); // } // return ( //
// // Skip {" "} // , // ]} // /> // // //
// ); // } // if (userId) { // const personalWorkspace = await db.query.workspaces.findFirst({ // where: (table, { and, eq, isNull }) => // and(eq(table.tenantId, userId), isNull(table.deletedAt)), // }); // // if no personal workspace exists, we create one // if (!personalWorkspace) { // const workspaceId = newId("workspace"); // await db.insert(schema.workspaces).values({ // id: workspaceId, // tenantId: userId, // name: "Personal", // plan: "free", // stripeCustomerId: null, // stripeSubscriptionId: null, // features: {}, // betaFeatures: {}, // subscriptions: null, // createdAt: new Date(), // }); // await ingestAuditLogs({ // workspaceId: workspaceId, // event: "workspace.create", // actor: { // type: "user", // id: userId, // }, // description: `Created ${workspaceId}`, // resources: [ // { // type: "workspace", // id: workspaceId, // }, // ], // context: { // userAgent: headers().get("user-agent") ?? undefined, // location: headers().get("x-forwarded-for") ?? process.env.VERCEL_REGION ?? "unknown", // }, // }); // return redirect(`/new?workspaceId=${workspaceId}`); // } // } const id = nanoid() const session = (await auth()) as Session const missingKeys = await getMissingKeys() return (
{/* */}