{{ define "kontor/user-detail.html" }}
{{ template "header.html" .}}
{{ template "admin-menu.html" .}}
<ul class="nav nav-tabs">
  <li role="presentation" class="active"><a href="/admin/user">User</a></li>
  <li role="presentation"><a href="/admin/data">Data</a></li>
</ul>

  <div class="panel-body">
    <!--If there's an error, display the error-->
    {{ if .ErrorTitle}}
    <p class="bg-danger">
      {{.ErrorTitle}}: {{.ErrorMessage}}
    </p>
    {{end}}
    <form action="/admin/user/view" method="POST">
      <div class="form-group">
        <label for="username">Username</label>
        {{ if .payload.Username }}
          <input type="text" class="form-control" id="username" name="username" value={{.payload.Username}}>
        {{ else }}
          <input type="text" class="form-control" id="username" name="username" placeholder="Username">
        {{ end }}
      </div>
      <div class="form-row">
        <div class="form-group col-md-6">
          <label for="firstname">First Name</label>
          {{ if .payload.Firstname }}
            <input type="text" class="form-control" id="firstname" name="firstname" value={{.payload.Firstname}}>
          {{ else }}
            <input type="text" class="form-control" id="firstname" name="firstname" placeholder="First Name">
          {{ end }}
        </div>
        <div class="form-group col-md-6">
          <label for="lastname">Last Name</label>
          {{ if .payload.Lastname }}
            <input type="text" class="form-control" id="lastname" name="lastname" value={{.payload.Lastname}}>
          {{ else }}
            <input type="text" class="form-control" id="lastname" name="lastname" placeholder="Last Name">
          {{ end }}
        </div>
      </div>
      <div class="form-group">
        <label for="password">Password</label>
        <input type="password" name="password" class="form-control" id="password" placeholder="Password">
      </div>
      <div class="form-check">
        <input type="checkbox" class="form-check-input" value="true" name="admin" id="admin" {{ if .payload.IsAdmin }}checked{{end}}>
        <label class="form-check-label" for="admin">Administrator</label>
      </div>
      <input type="hidden" name="userid" id="userid" value={{.payload.ID.Hex}}>
      <button type="submit" class="btn btn-primary" name="action" value={{.action}}>{{.action}}</button>
      {{ if eq .action "Save" }}
        <button type="submit" class="btn btn-primary" name="action" value="Delete">Delete</button>
      {{ end }}
    </form>
  </div>
{{ template "footer.html" .}}
{{end}}
