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

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

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/payment.settingsForm*/ -}}
    <form data-hx-put="/admin/payments/settings">
        <h2>{{ template "title" . }}</h2>
        {{ CSRFInput }}
        <fieldset>
            {{ with .MerchantCode -}}
                <label>
                    {{( pgettext "Merchant Code" "input")}}<br>
                    <input type="text" name="{{ .Name }}" value="{{ .Val }}"
                           required minlength="9"
                            {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .TerminalNumber -}}
                <label>
                    {{( pgettext "Terminal Number" "input")}}<br>
                    <input type="number" name="{{ .Name }}" value="{{ .Val }}"
                           min="1" max="999"
                           required {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .EncryptKey -}}
                <label>
                    {{ if $.MerchantCode.Val -}}
                        {{( pgettext "Merchant Key (only if must change it)" "input")}}<br>
                    {{- else -}}
                        {{( pgettext "Merchant Key" "input")}}<br>
                    {{- end }}
                    <input type="text" name="{{ .Name }}" value="{{ .Val }}"
                           {{ if not $.MerchantCode.Val }}required{{end }}
                            {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .Environment -}}
                <fieldset>
                    <legend>{{( pgettext "Environment" "title")}}</legend>
                    {{ template "radio-options" . }}
                </fieldset>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .Integration -}}
                <fieldset>
                    <legend>{{( pgettext "Integration" "title")}}</legend>
                    {{ template "radio-options" . }}
                </fieldset>
                {{ template "error-message" . }}
            {{- end }}
        </fieldset>
        <footer>
            <button type="submit">{{( pgettext "Save changes" "action" )}}</button>
        </footer>
    </form>
{{- end }}