Version 3 of the kit: - Radix UI replaced with Base UI (using the Shadcn UI patterns) - next-intl replaces react-i18next - enhanceAction deprecated; usage moved to next-safe-action - main layout now wrapped with [locale] path segment - Teams only mode - Layout updates - Zod v4 - Next.js 16.2 - Typescript 6 - All other dependencies updated - Removed deprecated Edge CSRF - Dynamic Github Action runner
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { redirect } from 'next/navigation';
|
|
|
|
import { createAccountsApi } from '@kit/accounts/api';
|
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|
|
|
import { AppLogo } from '~/components/app-logo';
|
|
import featuresFlagConfig from '~/config/feature-flags.config';
|
|
import pathsConfig from '~/config/paths.config';
|
|
import { requireUserInServerComponent } from '~/lib/server/require-user-in-server-component';
|
|
|
|
import { CreateFirstTeamForm } from './_components/create-first-team-form';
|
|
|
|
async function CreateTeamPage() {
|
|
const data = await loadData();
|
|
|
|
if (data.redirectTo) {
|
|
redirect(data.redirectTo);
|
|
}
|
|
|
|
return (
|
|
<div className="flex min-h-screen flex-col items-center justify-center gap-y-8">
|
|
<AppLogo />
|
|
|
|
<CreateFirstTeamForm />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default CreateTeamPage;
|
|
|
|
async function loadData() {
|
|
await requireUserInServerComponent();
|
|
|
|
if (!featuresFlagConfig.enableTeamsOnly) {
|
|
return { redirectTo: pathsConfig.app.home };
|
|
}
|
|
|
|
const client = getSupabaseServerClient();
|
|
const api = createAccountsApi(client);
|
|
const accounts = await api.loadUserAccounts();
|
|
|
|
if (accounts.length > 0 && accounts[0]?.value) {
|
|
return {
|
|
redirectTo: pathsConfig.app.accountHome.replace(
|
|
'[account]',
|
|
accounts[0].value,
|
|
),
|
|
};
|
|
}
|
|
|
|
return { redirectTo: null };
|
|
}
|