Introduce public /landing and /pricing pages for the SBMTR brand with bento features, convoy product demo, motion reveals, and scoped marketing tokens. Unauthenticated visitors route to the landing page. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
936 B
TypeScript
32 lines
936 B
TypeScript
import { redirect } from "next/navigation";
|
|
import { asc, eq } from "drizzle-orm";
|
|
|
|
import { auth } from "@/lib/auth";
|
|
import { db } from "@tasks/database/client";
|
|
import { workspaceMembers, workspaces } from "@tasks/database/schema";
|
|
|
|
/**
|
|
* Root landing route. Unauthenticated visitors go to the public marketing site;
|
|
* signed-in users land on their oldest workspace home (`/{slug}/`).
|
|
*/
|
|
export default async function HomePage() {
|
|
const session = await auth();
|
|
|
|
if (!session?.user?.id) {
|
|
redirect("/landing");
|
|
}
|
|
|
|
const [membership] = await db
|
|
.select({ slug: workspaces.slug })
|
|
.from(workspaceMembers)
|
|
.innerJoin(workspaces, eq(workspaces.id, workspaceMembers.workspaceId))
|
|
.where(eq(workspaceMembers.userId, session.user.id))
|
|
.orderBy(asc(workspaceMembers.createdAt))
|
|
.limit(1);
|
|
|
|
if (membership?.slug) {
|
|
redirect(`/${membership.slug}`);
|
|
}
|
|
|
|
redirect("/sign-in?error=no_workspace");
|
|
}
|