import { createRouter, createRootRoute, createRoute } from '@tanstack/react-router'
import Layout from './components/layout'
import MainPage from './pages/main'
import HomePage from './pages/home'
import RecipePage from './pages/recipe'

// Create a root route with layout
const rootRoute = createRootRoute({
  component: Layout,
})

// Home page route (main landing page at /)
const indexRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/',
  component: HomePage,
})

// Main page route (40+ page)
const mainRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/40+',
  component: MainPage,
})

// Recipe page route (under 40+)
const recipeRoute = createRoute({
  getParentRoute: () => rootRoute,
  path: '/40+/recipe',
  component: RecipePage,
})

// Create the router
const router = createRouter({
  routeTree: rootRoute.addChildren([indexRoute, mainRoute, recipeRoute]),
})

export default router