<!--
 SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
 SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
    {{( pgettext "Users" "title" )}}
{{- end }}

{{ define "breadcrumb" -}}
{{- end }}

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/user.userIndex*/ -}}
    <a href="/admin/users/new">{{( pgettext "Add User" "action" )}}</a>
    <a href="/admin/users/login-attempts">{{( pgettext "Logs" "action" )}}</a>
    <h2>{{( pgettext "Users" "title" )}}</h2>
    <table>
        <thead>
        <tr>
            <th scope="col">{{( pgettext "Name" "header" )}}</th>
            <th scope="col">{{( pgettext "Email" "header" )}}</th>
            <th scope="col">{{( pgettext "Role" "header" )}}</th>
            <th scope="col">{{( pgettext "Actions" "header" )}}</th>
        </tr>
        </thead>
        <tbody>
        {{ $confirm := ( gettext "Are you sure you wish to delete this user?" )}}
        {{ range .Users -}}
            <tr>
                <td><a href="{{ .URL }}">{{ .Name }}</a></td>
                <td><a href="{{ .URL }}">{{ .Email }}</a></td>
                <td>{{( pgettext .Role "role" )}}</td>
                <td>
                    <button data-hx-delete="{{ .URL }}"
                            data-hx-confirm="{{ $confirm }}"
                            data-hx-headers='{ {{ CSRFHeader }} }'>
                        {{( pgettext "Delete" "action" )}}
                    </button>
                </td>
            </tr>
        {{- end }}
        </tbody>
    </table>
{{- end }}
