<!--
 SPDX-FileCopyrightText: 2023 jordi fita mas <jordi@tandem.blog>
 SPDX-License-Identifier: AGPL-3.0-only
-->
{{ define "title" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.adminBookingForm*/ -}}
    {{ if .ID }}
        {{( pgettext "Edit Booking" "title" )}}
    {{ else }}
        {{( pgettext "New Booking" "title" )}}
    {{ end }}
{{- end }}

{{ define "head" -}}
    <script src="/static/idiomorph-ext@0.3.0.min.js"></script>
{{- end }}

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

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/booking.adminBookingForm*/ -}}
    {{ if .ID -}}
        <a href="{{ .URL }}/check-in">{{( pgettext "Check-in Booking" "action" )}}</a>
    {{- end }}
    <h2>{{ template "title" .}}</h2>
    <form id="booking-form"
          data-hx-ext="morph"
          data-hx-swap="morph:innerHTML"
          data-hx-include="this"
          data-hx-target="#booking-form-fields"
          data-hx-replace-url="true"
            {{- if .URL }} data-hx-put="{{ .URL }}"
            {{- else }} action="/admin/bookings" method="post"
            {{- end -}}
    >
        {{ CSRFInput }}
        <fieldset id="booking-form-fields">
            {{ template "fields.gohtml" . }}
        </fieldset>
        <footer>
            <button type="submit">
                {{- if .ID -}}
                    {{( pgettext "Update" "action" )}}
                {{- else -}}
                    {{( pgettext "Add" "action" )}}
                {{- end -}}
            </button>
        </footer>
    </form>
{{- end }}
