<!--
  -- Sicherheitsunterweisung
  -- Copyright (C) 2023  Jason Streifling
  --
  -- This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  --
  -- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  --
  -- You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->

{{define "refresh"}}
<button hx-post="/refresh-summary/{{.SessionID}}/{{.Login}}/" hx-target="#id-{{.Login}}"
  type="button">Aktualisieren</button>
{{end}}

{{define "retry"}}
<button hx-post="/allow-retry/{{.SessionID}}/{{.Login}}/" hx-swap="delete" type="button">Wiederholen erlauben</button>
{{end}}

{{define "participant"}}
<div id="id-{{.Login}}">
  <h2>{{.Login}}</h2>
  {{if not .LastName}}
  {{template "refresh" .}}
  {{else}}
  <p>{{.FirstName}} {{.LastName}}</p>
  <p>{{.Company}}</p>
  {{if lt .NoIncorrect 0}}
  {{template "refresh" .}}
  {{else if gt .NoIncorrect 0}}
  <p>{{.NoIncorrect}} Fehler</p>
  {{template "retry" .}}
  {{template "refresh" .}}
  {{else}}
  <p>{{.NoIncorrect}} Fehler</p>
  {{end}}
  {{end}}
</div>
{{end}}

{{define "content"}}
<button hx-post="/briefing-done/{{.SessionID}}/" hx-target="#content" type="button">Beenden</button>
{{range .ParticipantsData}}
{{template "participant" .}}
{{end}}
{{end}}