<%#
 Copyright 2013-2026 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<div>
  <div class="d-flex justify-content-center">
    <div class="col-md-8">
    @if (settingsForm.value.login) {
      <h2>__jhiTranslateTag__('settings.title', { "username": "settingsForm.value.login" })</h2>
    }

    @if (success()) {
      <div class="alert alert-success">__jhiTranslateTag__('settings.messages.success')</div>
    }

      <<%= jhiPrefixDashed %>-alert-error />

    @if (settingsForm.value.login) {
      <form name="form" (ngSubmit)="save()" [formGroup]="settingsForm" novalidate>
        <div class="mb-3">
          <label class="form-label" for="firstName">__jhiTranslateTag__('settings.form.firstname')</label>
          <input
            type="text"
            class="form-control"
            id="firstName"
            name="firstName"
            placeholder="__jhiTranslatePipe__('settings.form.firstname.placeholder')"
            formControlName="firstName"
            data-cy="firstname"
          />

        @let firstNameRef = settingsForm.get('firstName')!;
        @if (firstNameRef.invalid && (firstNameRef.dirty || firstNameRef.touched)) {
          <div>
          @if (firstNameRef?.errors?.required) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.firstname.required')</small>
          }

          @if (firstNameRef?.errors?.minlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.firstname.minlength')</small>
          }

          @if (firstNameRef?.errors?.maxlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.firstname.maxlength')</small>
          }
          </div>
        }
        </div>

        <div class="mb-3">
          <label class="form-label" for="lastName">__jhiTranslateTag__('settings.form.lastname')</label>
          <input
            type="text"
            class="form-control"
            id="lastName"
            name="lastName"
            placeholder="__jhiTranslatePipe__('settings.form.lastname.placeholder')"
            formControlName="lastName"
            data-cy="lastname"
          />

        @let lastNameRef = settingsForm.get('lastName')!;
        @if (lastNameRef.invalid && (lastNameRef.dirty || lastNameRef.touched)) {
          <div>
          @if (lastNameRef?.errors?.required) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.lastname.required')</small>
          }

          @if (lastNameRef?.errors?.minlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.lastname.minlength')</small>
          }

          @if (lastNameRef?.errors?.maxlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('settings.messages.validate.lastname.maxlength')</small>
          }
          </div>
        }
        </div>

        <div class="mb-3">
          <label class="form-label" for="email">__jhiTranslateTag__('global.form.email.label')</label>
          <input
            type="email"
            class="form-control"
            id="email"
            name="email"
            placeholder="__jhiTranslatePipe__('global.form.email.placeholder')"
            formControlName="email"
            data-cy="email"
          />

        @let emailRef = settingsForm.get('email')!;
        @if (emailRef.invalid && (emailRef.dirty || emailRef.touched)) {
          <div>
          @if (emailRef?.errors?.required) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('global.messages.validate.email.required')</small>
          }

          @if (emailRef?.errors?.email) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('global.messages.validate.email.invalid')</small>
          }

          @if (emailRef?.errors?.minlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('global.messages.validate.email.minlength')</small>
          }

          @if (emailRef?.errors?.maxlength) {
            <small class="form-text text-danger"
            >__jhiTranslateTag__('global.messages.validate.email.maxlength')</small>
          }
          </div>
        }
        </div>
        <%_ if (enableTranslation) { _%>

      @if (languages && languages.length > 0) {
        <div class="mb-3">
          <label for="langKey">__jhiTranslateTag__('settings.form.language')</label>
          <select class="form-control" id="langKey" name="langKey" formControlName="langKey" data-cy="langKey">
          @for (language of languages; track $index) {
            <option [value]="language">{{ language | findLanguageFromKey }}</option>
          }
          </select>
        </div>
      }
        <%_ } _%>

        <button
          type="submit"
          [disabled]="settingsForm.invalid"
          class="btn btn-primary"
          data-cy="submit"
        >__jhiTranslateTag__('settings.form.button')</button>
      </form>
    }
    </div>
  </div>
</div>
