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

{{ define "breadcrumb" -}}
    <li><a href="./">{{( pgettext "Campsites" "title" )}}</a></li>
{{- end }}

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/campsite/types.typeIndex*/ -}}
    <a href="/admin/campsites/types/new">{{( pgettext "Add Type" "action" )}}</a>
    <h2>{{( pgettext "Campsite Types" "title" )}}</h2>
    {{ if .Types -}}
        <form id="type-index"
              class="sortable"
              data-hx-post="/admin/campsites/types/order"
              data-hx-trigger="end"
              data-hx-select="#type-index"
              data-hx-swap="outerHTML"
        >
            {{ CSRFInput }}
            <table>
                <thead>
                <tr>
                    <th scope="col">{{( pgettext "Name" "header" )}}</th>
                    <th scope="col">{{( pgettext "Features" "header" )}}</th>
                    <th scope="col">{{( pgettext "Options" "header" )}}</th>
                    <th scope="col">{{( pgettext "Carousel" "header" )}}</th>
                    <th scope="col">{{( pgettext "Active" "campsite type" )}}</th>
                </tr>
                </thead>
                <tbody>
                {{ range $type := .Types -}}
                    <tr>
                        <td>
                            <span class="handle"></span>
                            <input type="hidden" name="slug" value="{{ .Slug }}">
                            <a href="/admin/campsites/types/{{ .Slug }}">{{ .Name }}</a>
                        </td>
                        <td>
                            <a href="/admin/campsites/types/{{ .Slug }}/features">{{( pgettext "Edit Features" "action" )}}</a>
                        </td>
                        <td>
                            <a href="/admin/campsites/types/{{ .Slug }}/options">{{( pgettext "Edit Options" "action" )}}</a>
                        </td>
                        <td>
                            <a href="/admin/campsites/types/{{ .Slug }}/slides">{{( pgettext "Edit Carousel" "action" )}}</a>
                        </td>
                        <td>{{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}</td>
                    </tr>
                {{- end }}
                </tbody>
            </table>
        </form>
    {{ else -}}
        <p>{{( gettext "No campsite types added yet." )}}</p>
    {{- end }}
{{- end }}
