import { Redirect, Route } from 'react-router-dom';
import {
  CONNECTIVE_REVISION_LINK,
  DEBUG_LINK,
  FAVORITE_LINK,
  LESSON_LINK,
  LESSON_WORD_PAGE_LINK,
  LISTENING_PRACTICE_LINK,
  MATCHING_FRENZY_LINK,
  QUIZ_MAIN_MENU_LINK,
  RECORD_LINK,
} from './constants';
import ConnectiveRevisionQuizRun from './pages/ConnectiveRevision/QuizRun';
import ConnectiveRevisionQuizResult from './pages/ConnectiveRevision/Result';
// import CorrectionRoute from './pages/MatchingFrenzy/Route/Correction';
// import PracticeFinish from './pages/MatchingFrenzy/Finish';
import ConnectiveRevisionSelectCategory from './pages/ConnectiveRevision/SelectCategory';
import DebugPage from './pages/DebugPage';
import FavConnectivesPage from './pages/Favorite/Connectives';
import ConnectivesWordPage from './pages/Favorite/ConnectivesWordPage';
import FavVocabularyPage from './pages/Favorite/Vocabulary';
import FavoriteVocabularyPage from './pages/Favorite/WordPage';
import ConnectivesPage from './pages/Lesson/ConnectivesPage';
import Lesson from './pages/Lesson/index';
import LessonWordPage from './pages/Lesson/WordPage';
//
import ListeningPractice from './pages/ListeningPractice';
import PracticeFinish from './pages/ListeningPractice/Finish';
import PracticeResult from './pages/ListeningPractice/Result';
import QuestionRoute from './pages/ListeningPractice/Route';
import CorrectionRoute from './pages/ListeningPractice/Route/CorrectionRoute';
import MatchingFrenzyMatchFinished from './pages/MatchingFrenzy/Finished';
import MatchingFrenzyMatchRun from './pages/MatchingFrenzy/MatchRun';
import MatchingFrenzyMatchResult from './pages/MatchingFrenzy/Result';
//
import MatchingFrenzySelectCategory from './pages/MatchingFrenzy/SelectCategory';
import Page from './pages/Page';
import QuizzesMainMenu from './pages/QuizzesMainMenu';
//
import MyAchievementPage from './pages/Record/index';
import Setting from './pages/Setting/indx';
import Tab1 from './pages/Tab1';
import Tab2 from './pages/Tab2';
import Tab3 from './pages/Tab3';

function RouteConfig() {
  return (
    <>
      {/*  */}
      <Route exact path={QUIZ_MAIN_MENU_LINK}>
        <QuizzesMainMenu />
      </Route>
      {/*  */}
      <Route exact path={RECORD_LINK}>
        <MyAchievementPage />
      </Route>
      {/*  */}
      <Route exact path={`${LESSON_LINK}/a/:act_category`}>
        <Lesson />
      </Route>

      <Route exact path={LESSON_LINK}>
        <Lesson />
      </Route>
      {/*  */}
      {/* http://localhost:5173/listening_practice/c/0 */}
      <Route exact path={`${LISTENING_PRACTICE_LINK}/c/:p_route`}>
        <CorrectionRoute />
      </Route>

      {/* http://localhost:5173/listening_practice/r/0 */}
      <Route exact path={`${LISTENING_PRACTICE_LINK}/r/:p_route`}>
        <QuestionRoute />
      </Route>
      <Route exact path={`${LISTENING_PRACTICE_LINK}/finished`}>
        <PracticeFinish />
      </Route>
      <Route exact path={`${LISTENING_PRACTICE_LINK}/result`}>
        <PracticeResult />
      </Route>
      <Route exact path={LISTENING_PRACTICE_LINK}>
        <ListeningPractice />
      </Route>
      {/*  */}
      <Route exact path={`${CONNECTIVE_REVISION_LINK}/r/:p_route`}>
        <ConnectiveRevisionQuizRun />
      </Route>
      <Route exact path={`${CONNECTIVE_REVISION_LINK}/finished`}>
        <ConnectiveRevisionQuizResult />
      </Route>
      <Route exact path={CONNECTIVE_REVISION_LINK}>
        <ConnectiveRevisionSelectCategory />
      </Route>
      {/*  */}
      <Route exact path={`${MATCHING_FRENZY_LINK}/r/:p_route`}>
        <MatchingFrenzyMatchRun />
      </Route>
      <Route exact path={`${MATCHING_FRENZY_LINK}/finished`}>
        <MatchingFrenzyMatchFinished />
      </Route>
      <Route exact path={`${MATCHING_FRENZY_LINK}/result`}>
        <MatchingFrenzyMatchResult />
      </Route>
      <Route exact path={MATCHING_FRENZY_LINK}>
        <MatchingFrenzySelectCategory />
      </Route>

      <Route exact path={`${FAVORITE_LINK}/v/:lesson_idx/:cat_idx/:word_idx`}>
        <FavoriteVocabularyPage />
      </Route>

      <Route exact path={`${FAVORITE_LINK}/v`}>
        <FavVocabularyPage />
      </Route>

      <Route exact path={`${FAVORITE_LINK}/c/:lesson_idx/:cat_idx/:word_idx`}>
        {/* <FavoriteVocabularyPage /> */}
        {/* <FavConnectivesContentPage /> */}
        <ConnectivesWordPage />
      </Route>
      <Route exact path={`${FAVORITE_LINK}/c`}>
        <FavConnectivesPage />
      </Route>

      <Route exact path={`${LESSON_WORD_PAGE_LINK}/v/:lesson_idx/:cat_idx/:word_idx`}>
        <LessonWordPage />
      </Route>
      <Route exact path={`${LESSON_WORD_PAGE_LINK}/c/:lesson_idx/:cat_idx/:word_idx`}>
        <ConnectivesPage />
      </Route>

      {/* TODO: remove below */}
      <Route exact path="/tab1">
        <Tab1 />
      </Route>
      <Route exact path="/tab2">
        <Tab2 />
      </Route>
      <Route path="/tab3">
        <Tab3 />
      </Route>
      <Route path="/setting">
        <Setting />
      </Route>
      <Route path="/page/:name" exact={true}>
        <Page />
      </Route>
      <Route exact path={DEBUG_LINK}>
        <DebugPage />
      </Route>
      <Route exact path="/">
        <Redirect to={LESSON_LINK} />
      </Route>
    </>
  );
}

export { RouteConfig };
