2025-05-16 15:54:17 +02:00
|
|
|
import { redirect } from "next/navigation";
|
2026-06-23 16:06:20 +02:00
|
|
|
import { getCurrentOrganizationSlug } from "@/features/organizations/utils/organization-cookie";
|
2025-05-16 15:54:17 +02:00
|
|
|
import { currentUser } from "@/lib/auth/current-user";
|
2026-06-22 16:56:17 +02:00
|
|
|
import { isOnboardingDone } from "@/db/services/setting";
|
|
|
|
|
import { env } from "@/env.mjs";
|
2024-11-03 21:12:40 +01:00
|
|
|
|
2024-11-03 15:29:30 +01:00
|
|
|
export default async function Index() {
|
2026-06-22 16:56:17 +02:00
|
|
|
if (env.SKIP_ONBOARDING !== "true" && !(await isOnboardingDone())) {
|
2026-06-17 09:40:59 +02:00
|
|
|
redirect("/welcome");
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-16 15:54:17 +02:00
|
|
|
const user = await currentUser();
|
2024-11-03 15:29:30 +01:00
|
|
|
if (user) {
|
2025-05-16 15:54:17 +02:00
|
|
|
const currentOrganizationSlug = await getCurrentOrganizationSlug();
|
2025-07-26 14:43:59 +02:00
|
|
|
redirect(`/dashboard/home`);
|
2024-11-03 15:29:30 +01:00
|
|
|
}
|
2025-05-16 15:54:17 +02:00
|
|
|
redirect("/login");
|
2024-11-03 15:29:30 +01:00
|
|
|
}
|