import { cookies } from 'next/headers';
import { redirect } from 'next/navigation';

export default async function Home() {
  const cookieStore = await cookies();
  const token = cookieStore.get('habit-tracker-token');

  // If user has a token, redirect to dashboard, otherwise to welcome
  if (token?.value) {
    redirect('/dashboard');
  } else {
    redirect('/welcome');
  }
}
