import { Switch, Route, Redirect } from "react-router-dom"

import Welcome from "./pages/Welcome"
import Login from "./pages/Login"
import Home from "./pages/Home"
import ForgotPasword from "./pages/ForgotPassword"
import { Courses } from "./pages/Courses"
import { CourseExercises } from "./pages/CourseExercises"
import { Exercise } from "./pages/Exercise"

import Settings from "./pages/Settings"
import CourseComplete from "./pages/CourseComplete"

import { getRouteWelcome } from "./shared/consts/router"
import { getRouteLogin } from "./shared/consts/router"
import { getRouteHome } from "./shared/consts/router"
import { getRouteForgotPassword } from "./shared/consts/router"
import { getRouteCourses } from "./shared/consts/router"
import { getRouteSettings } from "./shared/consts/router"
import { getRouteCourseComplete } from "./shared/consts/router"

const AppRoutes = () => (
  <Switch>
    {/* Редирект с корня на /welcome */}
    <Redirect exact from="/" to={getRouteWelcome()} />

    {/* Остальные маршруты */}
    <Route path={getRouteWelcome()} component={Welcome} />
    <Route path={getRouteLogin()} component={Login} />
    <Route path={getRouteHome()} component={Home} />
    <Route path={getRouteForgotPassword()} component={ForgotPasword} />
    <Route exact path={getRouteCourses()} component={Courses} />
    <Route exact path="/course/:id" component={CourseExercises} />
    <Route exact path="/course/:courseId/:exerciseId" component={Exercise} />
    <Route path={getRouteSettings()} component={Settings} />
    <Route path={getRouteCourseComplete()} component={CourseComplete} />
  </Switch>
)

export default AppRoutes
