<script>

  import { getAuthInfo, saveAuthInfo } from "$lib/auth/Auth";
  import { redirect } from "$lib/tools/url/URLTools";
  import { jwtDecode } from "jwt-decode";

</script>
<div class="navbar bg-base-100">
  <div class="navbar-start">
    <div class="dropdown">
      <div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          class="h-5 w-5"
          fill="none"
          viewBox="0 0 24 24"
          stroke="currentColor"
        >
          <path
            stroke-linecap="round"
            stroke-linejoin="round"
            stroke-width="2"
            d="M4 6h16M4 12h8m-8 6h16"
          />
        </svg>
      </div>
      <ul
        class="menu menu-sm dropdown-content bg-base-100 rounded-box z-[1] mt-3 w-52 p-2 shadow"
      >
        <li>
          <a href="/admin/userslist">Пользователи</a>
        </li>
        <li>
          <a href="/admin/newuser">Добавить пользователя</a>
        </li>
        <li><a href="/admin/disputes">Споры</a></li>
      </ul>
    </div>
    <a href="/admin/" class="btn btn-ghost text-xl">HostaPay</a>
    <p class="text-sm ml-1 mt-2">{jwtDecode(getAuthInfo()?.a)?.role == "4" ? "Admin":"Moder"}</p>
  </div>
  <div class="navbar-center hidden lg:flex">
    <ul class="menu menu-horizontal px-1">
      <li>
        <a href="/admin/userslist">Пользователи</a>
      </li>
      <li>
        <a href="/admin/newuser">Добавить пользователя</a>
      </li>
      <li><a href="/admin/disputes">Споры</a></li>
      <!-- <li><a>Item 3</a></li> -->
    </ul>
  </div>
  <div class="navbar-end">
    <button on:click={()=>{
      saveAuthInfo("");
      redirect("/admin/");
    }} class="btn btn-error btn-outline">Выход</button>
  </div>
</div>
