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

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

{{ define "content" -}}
    {{- /*gotype: dev.tandem.ws/tandem/camper/pkg/app.profileForm*/ -}}
    <form data-hx-put="/me" enctype="multipart/form-data">
        <h2>{{( pgettext "Profile" "title" )}}</h2>
        {{ CSRFInput }}
        <fieldset>
            {{ with .Avatar -}}
                <label>
                    {{( pgettext "Profile Image" "inut" )}}<br>
                    <input type="file" name="{{ .Name }}"
                           accept="image/png image/jpeg"
                            {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .Name -}}
                <label>
                    {{( pgettext "Name" "input" )}}<br>
                    <input type="text" name="{{ .Name }}" value="{{ .Val }}"
                           autocomplete="name" required
                            {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            {{ with .Email -}}
                <label>
                    {{( pgettext "Email" "input" )}}<br>
                    <input type="email" name="{{ .Name }}" value="{{ .Val }}"
                           autocomplete="username" required
                            {{ template "error-attrs" . }}><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
            <fieldset>
                <legend>{{( pgettext "Change password" "legend" )}}</legend>
                {{ with .Password -}}
                    <label>
                        {{( pgettext "Password" "input" )}}<br>
                        <input type="password" name="{{ .Name }}" value="{{ .Val }}"
                               autocomplete="new-password"
                                {{ template "error-attrs" . }}><br>
                    </label>
                    {{ template "error-message" . }}
                {{- end }}
                {{ with .PasswordConfirm -}}
                    <label>
                        {{( pgettext "Password Confirmation" "input" )}}<br>
                        <input type="password" name="{{ .Name }}" value="{{ .Val }}"
                               autocomplete="new-password"
                                {{ template "error-attrs" . }}><br>
                    </label>
                    {{ template "error-message" . }}
                {{- end }}
            </fieldset>
            {{ with .Language -}}
                <label>
                    {{( pgettext "Language" "input" )}}<br>
                    <select name="{{ .Name }}"
                            required
                            {{ template "error-attrs" . }}>{{ template "list-options" . }}
                    </select><br>
                </label>
                {{ template "error-message" . }}
            {{- end }}
        </fieldset>
        <footer>
            <button type="submit">{{( pgettext "Save changes" "action" )}}</button>
        </footer>
    </form>
{{- end }}
