text: import React, { useContext } from "react";
  import {
    BrowserRouter as Router,
    Switch,
    Route,
    Redirect,
  } from "react-router-dom";
  import { Login } from "../pages/login/Login";
  import { Signup } from "../pages/signup/Signup";
  import { Home } from "../pages/home/Home";
  import { Profile } from "../pages/profile/Profile"
  import { Stats } from "../pages/stats/Stats"
  import { Trainings } from "../pages/trainings/Trainings"
  import { UserContext } from "../context/UserContext";
  
  export const AppRouter = () => {
    const { user } = useContext(UserContext);
  
    return (
      <Router>
        <Switch>
          <Route exact path="/">
            {user ? <Home />  : <Redirect to="/login" />}
          </Route>
          <Route path="/login">{user ? <Redirect to="/" /> : <Login />}</Route>
          <Route path="/signup">
            {user ? <Redirect to="/" /> : <Signup />} 
          </Route>
          <Route path="/profile">
            {user ? <Profile />  : <Redirect to="/login" />}
          </Route>
          <Route path="/stats">
            {user ? <Stats />  : <Redirect to="/login" />}
          </Route>
          <Route path="/trainings">
            {user ? <Trainings />  : <Redirect to="/login" />}
          </Route>
        </Switch>
      </Router>
    );
  };
  