<?php
$current_page = $_SERVER['SCRIPT_NAME'];
$nav = '
  <nav>
    <div class="row space_between no_margin full_width">
      <div class="site_navigation">
        <ul>
          <li><a href="/spaces.php?view=list"' . ($current_page == '/spaces.php' ? ' class="underline"' : '') . '>Spaces</a></li>
';

/* <li><a href="/index.php"' . ($current_page == '/index.php' ? ' class="underline"' : '') . '>Home</a></li> */
if (isset($_SESSION['user'])) {
  /* $nav .= ' */
  /* <li><a href="/user.php?view=display&user_id=' . unserialize($_SESSION['user'])->getId() . '"' . ($current_page == '/user.php' ? ' class="underline"' : '') . '>Account</a></li> */
  /* <li><a href="/todo.php?view=display"' . ($current_page == '/todo.php' ? ' class="underline"' : '') . '>Todos</a></li> */
  /* '; */

  if (unserialize($_SESSION['user'])->getRole() <= developer) {
    $nav .= '
            <li><a href="/admin.php?view=users"' . ($current_page == '/admin.php' ? ' class="underline"' : '') . '>Admin</a></li>
        ';
  }
}

$nav .= '
        </ul>
      </div>
      <div class="nav_right_hand">
        <form method="post">
';

$theme_toggle = '';
if ($_SESSION['theme'] == 'dark')
  $theme_toggle = 'light';
else
  $theme_toggle = 'dark';

$nav .= '
          <button id="theme_toggle" value="' . $theme_toggle . '" name="theme"><i class="nf ' . ($theme_toggle == 'dark' ? 'nf-oct-moon' : 'nf-oct-sun') . '"></i></button>
        </form>
';

if (isset($_SESSION['user'])) {
  $nav .= '
        <p class="link underline" id="logout">Log Out</p>
  ';
} else {
  $nav .= '
        <p class="link underline" id="login">Login</p>
        <p class="link underline" id="signup">Sign Up</p>
  ';
}

$nav .= '
      </div>
    </div>

  <script src="js/nav.js" defer></script>
  <script src="js/login.js" defer></script>
  </nav>
  <div id="notificationModal"></div>
  <div id="stdModal"></div>
';

echo $nav;
