<template>
  <div class="d-flex justify-content-center">
    <div class="col-8">
      <form name="editForm" novalidate @submit.prevent="save()">
        <h2 id="smartbookingApp.conferma.home.createOrEditLabel" data-cy="ConfermaCreateUpdateHeading">
          {{ t$('smartbookingApp.conferma.home.createOrEditLabel') }}
        </h2>
        <div>
          <div class="mb-3" v-if="conferma.id">
            <label for="id">{{ t$('global.field.id') }}</label>
            <input type="text" class="form-control" id="id" name="id" v-model="conferma.id" readonly />
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="conferma">{{ t$('smartbookingApp.conferma.motivoConferma') }}</label>
            <input
              type="text"
              class="form-control"
              name="motivoConferma"
              id="conferma-motivoConferma"
              data-cy="motivoConferma"
              :class="{ valid: !v$.motivoConferma.$invalid, invalid: v$.motivoConferma.$invalid }"
              v-model="v$.motivoConferma.$model"
            />
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="conferma">{{ t$('smartbookingApp.conferma.tipoConferma') }}</label>
            <select
              class="form-control"
              name="tipoConferma"
              :class="{ valid: !v$.tipoConferma.$invalid, invalid: v$.tipoConferma.$invalid }"
              v-model="v$.tipoConferma.$model"
              id="conferma-tipoConferma"
              data-cy="tipoConferma"
            >
              <option
                v-for="tipoConferma in tipoConfermaValues"
                :key="tipoConferma"
                :value="tipoConferma"
                :label="t$('smartbookingApp.TipoConferma.' + tipoConferma)"
              >
                {{ tipoConferma }}
              </option>
            </select>
          </div>
          <div class="mb-3">
            <label class="form-control-label" for="conferma">{{ t$('smartbookingApp.conferma.confermataDa') }}</label>
            <select
              class="form-control"
              id="conferma-confermataDa"
              data-cy="confermataDa"
              name="confermataDa"
              v-model="conferma.confermataDa"
            >
              <option :value="null"></option>
              <option
                :value="conferma.confermataDa && utenteAppOption.id === conferma.confermataDa.id ? conferma.confermataDa : utenteAppOption"
                v-for="utenteAppOption in utenteApps"
                :key="utenteAppOption.id"
              >
                {{ utenteAppOption.username }}
              </option>
            </select>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" @click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>{{ t$('entity.action.cancel') }}</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="v$.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>{{ t$('entity.action.save') }}</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./conferma-update.component.ts"></script>
