// In this file, all Page components from 'src/pages` are auto-imported. Nested
// directories are supported, and should be uppercase. Each subdirectory will be
// prepended onto the component name.
//
// Examples:
//
// 'src/pages/HomePage/HomePage.js'         -> HomePage
// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage

import { Set, Router, Route, PrivateSet } from '@redwoodjs/router'

import ScaffoldLayout from 'src/layouts/ScaffoldLayout'
import SidebarLayout from 'src/layouts/SidebarLayout'

import { useAuth } from './auth'

const Routes = () => {
  return (
    <Router useAuth={useAuth}>
      <PrivateSet wrap={SidebarLayout} unauthenticated="home">
        <Route path="/dashboard" page={DashboardPage} name="dashboard" />
        <Route path="/search" page={SearchPage} name="search" />
        <Route path="/calendar" page={CalendarPage} name="calendar" />
        <Route path="/offer" page={OfferPage} name="offer" />

        <PrivateSet unauthenticated="home" roles="admin">
          <Set wrap={ScaffoldLayout} title="Posts" titleTo="posts" buttonLabel="New Post" buttonTo="newPost">
            <Route path="/admin/posts/new" page={PostNewPostPage} name="newPost" />
            <Route path="/admin/posts/{id:Int}/edit" page={PostEditPostPage} name="editPost" />
            <Route path="/admin/posts/{id:Int}" page={PostPostPage} name="post" />
            <Route path="/admin/posts" page={PostPostsPage} name="posts" />
          </Set>
          <Set wrap={ScaffoldLayout} title="Nachhilfeangebots" titleTo="nachhilfeangebots" buttonLabel="New Nachhilfeangebot" buttonTo="newNachhilfeangebot">
            <Route path="/nachhilfeangebots/new" page={NachhilfeangebotNewNachhilfeangebotPage} name="newNachhilfeangebot" />
            <Route path="/nachhilfeangebots/{id:Int}/edit" page={NachhilfeangebotEditNachhilfeangebotPage} name="editNachhilfeangebot" />
            <Route path="/nachhilfeangebots/{id:Int}" page={NachhilfeangebotNachhilfeangebotPage} name="nachhilfeangebot" />
            <Route path="/nachhilfeangebots" page={NachhilfeangebotNachhilfeangebotsPage} name="nachhilfeangebots" />
          </Set>
        </PrivateSet>
      </PrivateSet>

      <Route path="/" page={HomePage} name="home" />
      <Route notfound page={NotFoundPage} />
    </Router>
  )
}

export default Routes
