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

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

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/season.seasonIndex*/ -}}
    <a href="/admin/seasons/new">{{( pgettext "Add Season" "action" )}}</a>
    <h2>{{( pgettext "Seasons" "title" )}}</h2>
    {{ if .Seasons -}}
        <form id="season-index"
              class="sortable"
              data-hx-post="/admin/seasons/order"
              data-hx-trigger="end"
              data-hx-select="#season-index"
              data-hx-swap="outerHTML"
        >
            {{ CSRFInput }}
            <table>
                <thead>
                <tr>
                    <th scope="col">{{( pgettext "Color" "header" )}}</th>
                    <th scope="col">{{( pgettext "Name" "header" )}}</th>
                    <th scope="col">{{( pgettext "Active" "season" )}}</th>
                </tr>
                </thead>
                <tbody>
                {{ range .Seasons -}}
                    <tr>
                        <td>
                            <input type="hidden" name="slug" value="{{ .Slug }}">
                            <span class="handle"></span>
                            <svg width="20px" height="20px">
                                <circle cx="50%" cy="50%" r="49%" fill="{{ .Color }}" stroke="#000" stroke-width=".5"/>
                            </svg>
                        </td>
                        <td><a href="{{ .URL }}">{{ .Name }}</a></td>
                        <td>{{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}</td>
                    </tr>
                {{- end }}
                </tbody>
            </table>
        </form>
    {{ else -}}
        <p>{{( gettext "No seasons added yet." )}}</p>
    {{- end }}

    <h2>{{( pgettext "Calendar" "title" )}}</h2>
    {{ template "calendar.gohtml" .Calendar }}
{{- end }}
