<!DOCTYPE html>
<html lang="en" xmlns:th="http://thymeleaf.org" xmlns:custom="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="UTF-8">
  <title>Zahtevi za naloge</title>
  <link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>
</head>
<body>

<script>
    function post(url, data) {
    return fetch(url, { method: "POST", body: data });
}

function izbrisi(idkorisnika){
    var odgovor = post("http://localhost:8080/izbrisi", idkorisnika);
}
funtion odobri(idKorisnika){
    var odgovor= post("http://localhost:8080/odobri", idKorisnika);
}
</script>

<div class="container text-center">


  <div>
    <form th:action="@{/logout}" method="post">
      <p>
        Dobrodosli <b>[[${#request.userPrincipal.principal.fullName}]]</b>
      </p>
      <input type="submit" value="Izloguj Se" />
    </form>




  </div>

  <h1>Lista svih zahteva za admin nalog </h1>


  <div>
    <table class="table-striped table-bordered">
      <thead class="thead-dark">
      <th>ID</th>
      <th>Ime</th>
      <th>Email</th>
      <th>Lozinka</th>
      <th>Telefon</th>
      <th>ID tipa</th>
      <th>Prezime</th>
      <th>Korisnicko ime</th>
      <th>Izbrisi</th>
      <th>Odobri</th>
      </thead>

      <tbody>
      <tr th:each="korisnik: ${zahtevi}">
        <td th:text="${korisnik.idKorisnika}">ID</td>
        <td th:text="${korisnik.ime}">Ime</td>
        <td th:text="${korisnik.email}">Email</td>
        <td th:text="${korisnik.lozinka}">Lozinka</td>
        <td th:text="${korisnik.telefon}">Telefon</td>
        <td th:text="${korisnik.idTipaKorisnika}">ID tipa</td>
        <td th:text="${korisnik.prezime}">Prezime</td>
        <td th:text="${korisnik.username}">Korisnicko ime</td>
        <td><a th:href="@{/izbrisi(idKorisnika=${korisnik.idKorisnika})}" custom:linkMethod="post">Obrisi korisnika</a></td>
        <td><a th:href="@{/odobri(idKorisnika=${korisnik.idKorisnika})}" custom:linkMethod="post">Odobri admin nalog</a></td>
      </tr>

      </tbody>

    </table>
  </div>

  <a th:href="@{/lista_oglasa}">Lista Oglasa</a>
  <a th:href="@{/lista_korisnika}">Lista korisnika</a>
  <a th:href="@{/}">Pocetna stranica</a>

</div>
</body>
</html>