ReactJS: Switch Different Navigation












0















I have problem regarding switching navigation in two different navbar, if the user is not logged in, then the only navigation bar should show is the Main Page,



However if the user logged in they can navigate two navigation bar




  1. The USER Page

  2. The ADMIN DASHBOARD Page


Scenario:




  • If i logged in the first navigation bar should show is the ADMIN DASHBOARD navigation

  • If i want to switch my navigation from ADMIN DASHBOARD PAGE to USER PAGE by just clicking our logo, the navigation should switch to user page.


Navigation 1:
USER NAVIGATION



Navigation 2:
ADMIN NAVIGATION



Question. How to switch my navigation bar if i click our logo even if I logged already?



    let find_token = localStorage.getItem('token');
let find_user = localStorage.getItem('user');

let logIn = find_token === null || find_user === null;


if(logIn)
{
return (

<Router>
<div>

<nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


<Link className="navbar-brand" to="/">
<img src="/images/nav-logo.png" height="30"/>
</Link>


<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
<li className="nav-item active">
<Link className="nav-link active" to="/index">Home <span className="sr-only">(current)</span></Link>
</li>
<li className="nav-item dropdown">
<a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
About Us
</a>
<div className="dropdown-menu" aria-labelledby="navbarDropdown">

<Link className="dropdown-item" to="/company-story">Our Company Story</Link>
<Link className="dropdown-item" to="/community">Community</Link>
<Link className="dropdown-item" to="/peoplegallery">People Gallery</Link>
</div>
</li>
<li className="nav-item">
<Link className="nav-link" to="/news-event">News Event</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/store-directory">Store Directory</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/careers">Careers</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/contact">Contact Us</Link>
</li>

</ul>

<ul className="navbar-nav">
<li className="nav-item">
<Link className="nav-link active" to="/login">Login</Link>
</li>

</ul>

</div>


</nav>



<Route path="/" exact component={Content}></Route>
<Route path="/index" exact component={Content}></Route>
<Route path="/login" exact component={Login}></Route>
<Route path="/contact" component={Contact}></Route>
<Route path="/company-story" exact component={CompanyStory}></Route>
<Route path="/news-event" exact component={News}></Route>
<Route path="/community" exact component={Community}></Route>
<Route path="/peoplegallery" exact component={PeopleGallery}></Route>
<Route path="/store-directory" exact component={Directory}></Route>
<Route path="/careers" exact component={Careers}></Route>
<Route path="/news-event/description/:id" component={EventDescription}></Route>
<Route path="/peoplegallery/images/:id" component={AlbumImages}></Route>
<Route path="/job/description/:id" component={JobDetails}></Route>
<Route path="/job/online-application/:id" component={OnlineApplication}></Route>
<Route path="/careers_filter/:id" component={CareersFilter}></Route>


<Route path="/hiflyer-dashboard" exact component={logIn ? Dashboard:Content}></Route>


</Router>

)
}
else
{
let dec = localStorage.getItem('user');
let json_object = JSON.parse(dec);
let json_email = json_object["email"];

const storedToken = localStorage.getItem("token");

if (storedToken){

let decodedData = decode(storedToken);

let expirationDate = decodedData.exp;

var current_time = Date.now() / 1000;

if(expirationDate < current_time)
{
localStorage.removeItem('token');
localStorage.removeItem('exp');
localStorage.removeItem('user');

location.assign('/login');

}

else
{
console.log('Expiration not yet expired')
}

}


return (

<Router>

<div>

<nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


<Link className="navbar-brand" to="/">
<img src="/images/nav-logo.png" height="30"/>
</Link>


<button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="collapse navbar-collapse" id="navbarSupportedContent">
<ul className="navbar-nav mr-auto">
<li className="nav-item active">
<Link className="nav-link active" to="/index">Dashboard <span className="sr-only">(current)</span></Link>
</li>
<li className="nav-item dropdown">
<a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Pages Manager
</a>
<div className="dropdown-menu" aria-labelledby="navbarDropdown">

<Link className="dropdown-item" to="/home-content">Home Content</Link>
<Link className="dropdown-item" to="/story-content">Our Company Story Content</Link>
<Link className="dropdown-item" to="/news-content">News Content</Link>
<Link className="dropdown-item" to="/gallery-content">People Gallery Content</Link>
<Link className="dropdown-item" to="/store-content">Store Directory Content</Link>
<Link className="dropdown-item" to="/community-content">Community Content</Link>
<Link className="dropdown-item" to="/job-content">Job Content</Link>
<Link className="dropdown-item" to="/slider-content">Slider Content</Link>
</div>
</li>
<li className="nav-item dropdown">
<a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Update Pages Manager
</a>
<div className="dropdown-menu" aria-labelledby="navbarDropdown">

<Link className="dropdown-item" to="/update-home-content">Update Home Content</Link>
<Link className="dropdown-item" to="/update-story-content">Update Our Company Story Content</Link>
<Link className="dropdown-item" to="/update-news-content">Update News Content</Link>
<Link className="dropdown-item" to="/update-gallery-content">Update People Gallery Content</Link>
<Link className="dropdown-item" to="/update-store-content">Update Store Directory Content</Link>
<Link className="dropdown-item" to="/update-community-content">Update Community Content</Link>
<Link className="dropdown-item" to="/update-job-content">Update Job Content</Link>
<Link className="dropdown-item" to="/update-slider">Update Slider</Link>
</div>
</li>
<li className="nav-item">
<Link className="nav-link" to="/user-management">User Management</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/applicants">Applicants</Link>
</li>



</ul>

<ul className="navbar-nav">

<li className="nav-item dropdown">
<a id="navbarDropdown" className="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{json_email} <span className="caret"></span>
</a>

<div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">

<a className="dropdown-item" href="/hiflyer-dashboard">Dashboard</a>
<a className="dropdown-item" href="/index" onClick={this.handleLogout}>Logout</a>


</div>
</li>


</ul>



</div>


</nav>

</div>

</Router>
)
}









share|improve this question



























    0















    I have problem regarding switching navigation in two different navbar, if the user is not logged in, then the only navigation bar should show is the Main Page,



    However if the user logged in they can navigate two navigation bar




    1. The USER Page

    2. The ADMIN DASHBOARD Page


    Scenario:




    • If i logged in the first navigation bar should show is the ADMIN DASHBOARD navigation

    • If i want to switch my navigation from ADMIN DASHBOARD PAGE to USER PAGE by just clicking our logo, the navigation should switch to user page.


    Navigation 1:
    USER NAVIGATION



    Navigation 2:
    ADMIN NAVIGATION



    Question. How to switch my navigation bar if i click our logo even if I logged already?



        let find_token = localStorage.getItem('token');
    let find_user = localStorage.getItem('user');

    let logIn = find_token === null || find_user === null;


    if(logIn)
    {
    return (

    <Router>
    <div>

    <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


    <Link className="navbar-brand" to="/">
    <img src="/images/nav-logo.png" height="30"/>
    </Link>


    <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span className="navbar-toggler-icon"></span>
    </button>
    <div className="collapse navbar-collapse" id="navbarSupportedContent">
    <ul className="navbar-nav mr-auto">
    <li className="nav-item active">
    <Link className="nav-link active" to="/index">Home <span className="sr-only">(current)</span></Link>
    </li>
    <li className="nav-item dropdown">
    <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    About Us
    </a>
    <div className="dropdown-menu" aria-labelledby="navbarDropdown">

    <Link className="dropdown-item" to="/company-story">Our Company Story</Link>
    <Link className="dropdown-item" to="/community">Community</Link>
    <Link className="dropdown-item" to="/peoplegallery">People Gallery</Link>
    </div>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/news-event">News Event</Link>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/store-directory">Store Directory</Link>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/careers">Careers</Link>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/contact">Contact Us</Link>
    </li>

    </ul>

    <ul className="navbar-nav">
    <li className="nav-item">
    <Link className="nav-link active" to="/login">Login</Link>
    </li>

    </ul>

    </div>


    </nav>



    <Route path="/" exact component={Content}></Route>
    <Route path="/index" exact component={Content}></Route>
    <Route path="/login" exact component={Login}></Route>
    <Route path="/contact" component={Contact}></Route>
    <Route path="/company-story" exact component={CompanyStory}></Route>
    <Route path="/news-event" exact component={News}></Route>
    <Route path="/community" exact component={Community}></Route>
    <Route path="/peoplegallery" exact component={PeopleGallery}></Route>
    <Route path="/store-directory" exact component={Directory}></Route>
    <Route path="/careers" exact component={Careers}></Route>
    <Route path="/news-event/description/:id" component={EventDescription}></Route>
    <Route path="/peoplegallery/images/:id" component={AlbumImages}></Route>
    <Route path="/job/description/:id" component={JobDetails}></Route>
    <Route path="/job/online-application/:id" component={OnlineApplication}></Route>
    <Route path="/careers_filter/:id" component={CareersFilter}></Route>


    <Route path="/hiflyer-dashboard" exact component={logIn ? Dashboard:Content}></Route>


    </Router>

    )
    }
    else
    {
    let dec = localStorage.getItem('user');
    let json_object = JSON.parse(dec);
    let json_email = json_object["email"];

    const storedToken = localStorage.getItem("token");

    if (storedToken){

    let decodedData = decode(storedToken);

    let expirationDate = decodedData.exp;

    var current_time = Date.now() / 1000;

    if(expirationDate < current_time)
    {
    localStorage.removeItem('token');
    localStorage.removeItem('exp');
    localStorage.removeItem('user');

    location.assign('/login');

    }

    else
    {
    console.log('Expiration not yet expired')
    }

    }


    return (

    <Router>

    <div>

    <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


    <Link className="navbar-brand" to="/">
    <img src="/images/nav-logo.png" height="30"/>
    </Link>


    <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span className="navbar-toggler-icon"></span>
    </button>
    <div className="collapse navbar-collapse" id="navbarSupportedContent">
    <ul className="navbar-nav mr-auto">
    <li className="nav-item active">
    <Link className="nav-link active" to="/index">Dashboard <span className="sr-only">(current)</span></Link>
    </li>
    <li className="nav-item dropdown">
    <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Pages Manager
    </a>
    <div className="dropdown-menu" aria-labelledby="navbarDropdown">

    <Link className="dropdown-item" to="/home-content">Home Content</Link>
    <Link className="dropdown-item" to="/story-content">Our Company Story Content</Link>
    <Link className="dropdown-item" to="/news-content">News Content</Link>
    <Link className="dropdown-item" to="/gallery-content">People Gallery Content</Link>
    <Link className="dropdown-item" to="/store-content">Store Directory Content</Link>
    <Link className="dropdown-item" to="/community-content">Community Content</Link>
    <Link className="dropdown-item" to="/job-content">Job Content</Link>
    <Link className="dropdown-item" to="/slider-content">Slider Content</Link>
    </div>
    </li>
    <li className="nav-item dropdown">
    <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Update Pages Manager
    </a>
    <div className="dropdown-menu" aria-labelledby="navbarDropdown">

    <Link className="dropdown-item" to="/update-home-content">Update Home Content</Link>
    <Link className="dropdown-item" to="/update-story-content">Update Our Company Story Content</Link>
    <Link className="dropdown-item" to="/update-news-content">Update News Content</Link>
    <Link className="dropdown-item" to="/update-gallery-content">Update People Gallery Content</Link>
    <Link className="dropdown-item" to="/update-store-content">Update Store Directory Content</Link>
    <Link className="dropdown-item" to="/update-community-content">Update Community Content</Link>
    <Link className="dropdown-item" to="/update-job-content">Update Job Content</Link>
    <Link className="dropdown-item" to="/update-slider">Update Slider</Link>
    </div>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/user-management">User Management</Link>
    </li>
    <li className="nav-item">
    <Link className="nav-link" to="/applicants">Applicants</Link>
    </li>



    </ul>

    <ul className="navbar-nav">

    <li className="nav-item dropdown">
    <a id="navbarDropdown" className="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    {json_email} <span className="caret"></span>
    </a>

    <div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">

    <a className="dropdown-item" href="/hiflyer-dashboard">Dashboard</a>
    <a className="dropdown-item" href="/index" onClick={this.handleLogout}>Logout</a>


    </div>
    </li>


    </ul>



    </div>


    </nav>

    </div>

    </Router>
    )
    }









    share|improve this question

























      0












      0








      0








      I have problem regarding switching navigation in two different navbar, if the user is not logged in, then the only navigation bar should show is the Main Page,



      However if the user logged in they can navigate two navigation bar




      1. The USER Page

      2. The ADMIN DASHBOARD Page


      Scenario:




      • If i logged in the first navigation bar should show is the ADMIN DASHBOARD navigation

      • If i want to switch my navigation from ADMIN DASHBOARD PAGE to USER PAGE by just clicking our logo, the navigation should switch to user page.


      Navigation 1:
      USER NAVIGATION



      Navigation 2:
      ADMIN NAVIGATION



      Question. How to switch my navigation bar if i click our logo even if I logged already?



          let find_token = localStorage.getItem('token');
      let find_user = localStorage.getItem('user');

      let logIn = find_token === null || find_user === null;


      if(logIn)
      {
      return (

      <Router>
      <div>

      <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


      <Link className="navbar-brand" to="/">
      <img src="/images/nav-logo.png" height="30"/>
      </Link>


      <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span className="navbar-toggler-icon"></span>
      </button>
      <div className="collapse navbar-collapse" id="navbarSupportedContent">
      <ul className="navbar-nav mr-auto">
      <li className="nav-item active">
      <Link className="nav-link active" to="/index">Home <span className="sr-only">(current)</span></Link>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      About Us
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/company-story">Our Company Story</Link>
      <Link className="dropdown-item" to="/community">Community</Link>
      <Link className="dropdown-item" to="/peoplegallery">People Gallery</Link>
      </div>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/news-event">News Event</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/store-directory">Store Directory</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/careers">Careers</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/contact">Contact Us</Link>
      </li>

      </ul>

      <ul className="navbar-nav">
      <li className="nav-item">
      <Link className="nav-link active" to="/login">Login</Link>
      </li>

      </ul>

      </div>


      </nav>



      <Route path="/" exact component={Content}></Route>
      <Route path="/index" exact component={Content}></Route>
      <Route path="/login" exact component={Login}></Route>
      <Route path="/contact" component={Contact}></Route>
      <Route path="/company-story" exact component={CompanyStory}></Route>
      <Route path="/news-event" exact component={News}></Route>
      <Route path="/community" exact component={Community}></Route>
      <Route path="/peoplegallery" exact component={PeopleGallery}></Route>
      <Route path="/store-directory" exact component={Directory}></Route>
      <Route path="/careers" exact component={Careers}></Route>
      <Route path="/news-event/description/:id" component={EventDescription}></Route>
      <Route path="/peoplegallery/images/:id" component={AlbumImages}></Route>
      <Route path="/job/description/:id" component={JobDetails}></Route>
      <Route path="/job/online-application/:id" component={OnlineApplication}></Route>
      <Route path="/careers_filter/:id" component={CareersFilter}></Route>


      <Route path="/hiflyer-dashboard" exact component={logIn ? Dashboard:Content}></Route>


      </Router>

      )
      }
      else
      {
      let dec = localStorage.getItem('user');
      let json_object = JSON.parse(dec);
      let json_email = json_object["email"];

      const storedToken = localStorage.getItem("token");

      if (storedToken){

      let decodedData = decode(storedToken);

      let expirationDate = decodedData.exp;

      var current_time = Date.now() / 1000;

      if(expirationDate < current_time)
      {
      localStorage.removeItem('token');
      localStorage.removeItem('exp');
      localStorage.removeItem('user');

      location.assign('/login');

      }

      else
      {
      console.log('Expiration not yet expired')
      }

      }


      return (

      <Router>

      <div>

      <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


      <Link className="navbar-brand" to="/">
      <img src="/images/nav-logo.png" height="30"/>
      </Link>


      <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span className="navbar-toggler-icon"></span>
      </button>
      <div className="collapse navbar-collapse" id="navbarSupportedContent">
      <ul className="navbar-nav mr-auto">
      <li className="nav-item active">
      <Link className="nav-link active" to="/index">Dashboard <span className="sr-only">(current)</span></Link>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Pages Manager
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/home-content">Home Content</Link>
      <Link className="dropdown-item" to="/story-content">Our Company Story Content</Link>
      <Link className="dropdown-item" to="/news-content">News Content</Link>
      <Link className="dropdown-item" to="/gallery-content">People Gallery Content</Link>
      <Link className="dropdown-item" to="/store-content">Store Directory Content</Link>
      <Link className="dropdown-item" to="/community-content">Community Content</Link>
      <Link className="dropdown-item" to="/job-content">Job Content</Link>
      <Link className="dropdown-item" to="/slider-content">Slider Content</Link>
      </div>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Update Pages Manager
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/update-home-content">Update Home Content</Link>
      <Link className="dropdown-item" to="/update-story-content">Update Our Company Story Content</Link>
      <Link className="dropdown-item" to="/update-news-content">Update News Content</Link>
      <Link className="dropdown-item" to="/update-gallery-content">Update People Gallery Content</Link>
      <Link className="dropdown-item" to="/update-store-content">Update Store Directory Content</Link>
      <Link className="dropdown-item" to="/update-community-content">Update Community Content</Link>
      <Link className="dropdown-item" to="/update-job-content">Update Job Content</Link>
      <Link className="dropdown-item" to="/update-slider">Update Slider</Link>
      </div>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/user-management">User Management</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/applicants">Applicants</Link>
      </li>



      </ul>

      <ul className="navbar-nav">

      <li className="nav-item dropdown">
      <a id="navbarDropdown" className="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {json_email} <span className="caret"></span>
      </a>

      <div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">

      <a className="dropdown-item" href="/hiflyer-dashboard">Dashboard</a>
      <a className="dropdown-item" href="/index" onClick={this.handleLogout}>Logout</a>


      </div>
      </li>


      </ul>



      </div>


      </nav>

      </div>

      </Router>
      )
      }









      share|improve this question














      I have problem regarding switching navigation in two different navbar, if the user is not logged in, then the only navigation bar should show is the Main Page,



      However if the user logged in they can navigate two navigation bar




      1. The USER Page

      2. The ADMIN DASHBOARD Page


      Scenario:




      • If i logged in the first navigation bar should show is the ADMIN DASHBOARD navigation

      • If i want to switch my navigation from ADMIN DASHBOARD PAGE to USER PAGE by just clicking our logo, the navigation should switch to user page.


      Navigation 1:
      USER NAVIGATION



      Navigation 2:
      ADMIN NAVIGATION



      Question. How to switch my navigation bar if i click our logo even if I logged already?



          let find_token = localStorage.getItem('token');
      let find_user = localStorage.getItem('user');

      let logIn = find_token === null || find_user === null;


      if(logIn)
      {
      return (

      <Router>
      <div>

      <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


      <Link className="navbar-brand" to="/">
      <img src="/images/nav-logo.png" height="30"/>
      </Link>


      <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span className="navbar-toggler-icon"></span>
      </button>
      <div className="collapse navbar-collapse" id="navbarSupportedContent">
      <ul className="navbar-nav mr-auto">
      <li className="nav-item active">
      <Link className="nav-link active" to="/index">Home <span className="sr-only">(current)</span></Link>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      About Us
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/company-story">Our Company Story</Link>
      <Link className="dropdown-item" to="/community">Community</Link>
      <Link className="dropdown-item" to="/peoplegallery">People Gallery</Link>
      </div>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/news-event">News Event</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/store-directory">Store Directory</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/careers">Careers</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/contact">Contact Us</Link>
      </li>

      </ul>

      <ul className="navbar-nav">
      <li className="nav-item">
      <Link className="nav-link active" to="/login">Login</Link>
      </li>

      </ul>

      </div>


      </nav>



      <Route path="/" exact component={Content}></Route>
      <Route path="/index" exact component={Content}></Route>
      <Route path="/login" exact component={Login}></Route>
      <Route path="/contact" component={Contact}></Route>
      <Route path="/company-story" exact component={CompanyStory}></Route>
      <Route path="/news-event" exact component={News}></Route>
      <Route path="/community" exact component={Community}></Route>
      <Route path="/peoplegallery" exact component={PeopleGallery}></Route>
      <Route path="/store-directory" exact component={Directory}></Route>
      <Route path="/careers" exact component={Careers}></Route>
      <Route path="/news-event/description/:id" component={EventDescription}></Route>
      <Route path="/peoplegallery/images/:id" component={AlbumImages}></Route>
      <Route path="/job/description/:id" component={JobDetails}></Route>
      <Route path="/job/online-application/:id" component={OnlineApplication}></Route>
      <Route path="/careers_filter/:id" component={CareersFilter}></Route>


      <Route path="/hiflyer-dashboard" exact component={logIn ? Dashboard:Content}></Route>


      </Router>

      )
      }
      else
      {
      let dec = localStorage.getItem('user');
      let json_object = JSON.parse(dec);
      let json_email = json_object["email"];

      const storedToken = localStorage.getItem("token");

      if (storedToken){

      let decodedData = decode(storedToken);

      let expirationDate = decodedData.exp;

      var current_time = Date.now() / 1000;

      if(expirationDate < current_time)
      {
      localStorage.removeItem('token');
      localStorage.removeItem('exp');
      localStorage.removeItem('user');

      location.assign('/login');

      }

      else
      {
      console.log('Expiration not yet expired')
      }

      }


      return (

      <Router>

      <div>

      <nav className="navbar navbar-expand-lg navbar-light bg-light fixed-top" id="custom-nav">


      <Link className="navbar-brand" to="/">
      <img src="/images/nav-logo.png" height="30"/>
      </Link>


      <button className="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span className="navbar-toggler-icon"></span>
      </button>
      <div className="collapse navbar-collapse" id="navbarSupportedContent">
      <ul className="navbar-nav mr-auto">
      <li className="nav-item active">
      <Link className="nav-link active" to="/index">Dashboard <span className="sr-only">(current)</span></Link>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Pages Manager
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/home-content">Home Content</Link>
      <Link className="dropdown-item" to="/story-content">Our Company Story Content</Link>
      <Link className="dropdown-item" to="/news-content">News Content</Link>
      <Link className="dropdown-item" to="/gallery-content">People Gallery Content</Link>
      <Link className="dropdown-item" to="/store-content">Store Directory Content</Link>
      <Link className="dropdown-item" to="/community-content">Community Content</Link>
      <Link className="dropdown-item" to="/job-content">Job Content</Link>
      <Link className="dropdown-item" to="/slider-content">Slider Content</Link>
      </div>
      </li>
      <li className="nav-item dropdown">
      <a className="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      Update Pages Manager
      </a>
      <div className="dropdown-menu" aria-labelledby="navbarDropdown">

      <Link className="dropdown-item" to="/update-home-content">Update Home Content</Link>
      <Link className="dropdown-item" to="/update-story-content">Update Our Company Story Content</Link>
      <Link className="dropdown-item" to="/update-news-content">Update News Content</Link>
      <Link className="dropdown-item" to="/update-gallery-content">Update People Gallery Content</Link>
      <Link className="dropdown-item" to="/update-store-content">Update Store Directory Content</Link>
      <Link className="dropdown-item" to="/update-community-content">Update Community Content</Link>
      <Link className="dropdown-item" to="/update-job-content">Update Job Content</Link>
      <Link className="dropdown-item" to="/update-slider">Update Slider</Link>
      </div>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/user-management">User Management</Link>
      </li>
      <li className="nav-item">
      <Link className="nav-link" to="/applicants">Applicants</Link>
      </li>



      </ul>

      <ul className="navbar-nav">

      <li className="nav-item dropdown">
      <a id="navbarDropdown" className="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
      {json_email} <span className="caret"></span>
      </a>

      <div className="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">

      <a className="dropdown-item" href="/hiflyer-dashboard">Dashboard</a>
      <a className="dropdown-item" href="/index" onClick={this.handleLogout}>Logout</a>


      </div>
      </li>


      </ul>



      </div>


      </nav>

      </div>

      </Router>
      )
      }






      reactjs






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 8:29









      DevGeDevGe

      607




      607
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295874%2freactjs-switch-different-navigation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295874%2freactjs-switch-different-navigation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine