All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
37 lines
872 B
TypeScript
37 lines
872 B
TypeScript
import { redirect } from "next/navigation";
|
|
import { OnboardingWizard } from "@/components/onboarding/OnboardingWizard";
|
|
import { API_BASE_URL } from "@/lib/config";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
interface OnboardingStatusResponse {
|
|
completed: boolean;
|
|
}
|
|
|
|
async function getOnboardingStatus(): Promise<OnboardingStatusResponse> {
|
|
try {
|
|
const response = await fetch(`${API_BASE_URL}/api/onboarding/status`, {
|
|
method: "GET",
|
|
cache: "no-store",
|
|
});
|
|
|
|
if (!response.ok) {
|
|
return { completed: false };
|
|
}
|
|
|
|
return (await response.json()) as OnboardingStatusResponse;
|
|
} catch {
|
|
return { completed: false };
|
|
}
|
|
}
|
|
|
|
export default async function OnboardingPage(): Promise<React.JSX.Element> {
|
|
const status = await getOnboardingStatus();
|
|
|
|
if (status.completed) {
|
|
redirect("/");
|
|
}
|
|
|
|
return <OnboardingWizard />;
|
|
}
|