I have completed the character creation screen on the avatar branch and am preparing to merge it into main.
23 lines
656 B
TypeScript
23 lines
656 B
TypeScript
import { redirect } from "next/navigation";
|
|
|
|
import { requireSessionUser } from "@/lib/auth-helpers";
|
|
import { fetchOnboardingStatusForUser } from "@/lib/onboarding-status";
|
|
import { routes } from "@/lib/routes";
|
|
import { createClient } from "@/lib/supabase/server";
|
|
|
|
type OnboardingAuthGateProps = {
|
|
children: React.ReactNode;
|
|
};
|
|
|
|
export async function OnboardingAuthGate({ children }: OnboardingAuthGateProps) {
|
|
const user = await requireSessionUser();
|
|
const supabase = await createClient();
|
|
const status = await fetchOnboardingStatusForUser(user.id, supabase);
|
|
|
|
if (status.appComplete) {
|
|
redirect(routes.avatar);
|
|
}
|
|
|
|
return children;
|
|
}
|