{{ header }}
<div id="root">
  <div class="page-loader" v-show="isLoading"></div>

  <validation-observer
    tag="div"
    ref="validationObserver"
    v-slot="{ handleSubmit }">
    <form
      ref="form"
      @submit.prevent="handleSubmit(onSubmit)"
      action="{{ data.action }}"
      method="post">

      <the-header
        title="{{ heading_title }}"
        help="http://manual.futurasistemas.com.br/manual-do-sistema/modulo-de-envio-pela-transportadora-tnt/"
        :breadcrumbs='{{ breadcrumbs|json_encode() }}'>

        <base-button href="{{ data.back }}" apperance="outline">
          {{ button_cancel }}
        </base-button>
        <base-button type="submit">
          {{ button_save }}
        </base-button>

        <template #notification>
          <base-alert
            v-show="alert.type"
            :apperance="alert.type"
            @close="alert = {}">
            <span v-text="alert.message"></span>
          </base-alert>
        </template>
      </the-header>

      <div class="container-fluid">
        <div class="row">
          <div class="col-xs-12 col-sm-8 col-md-6">
            <base-card class="padding-large">

              <validation-provider
                tag="div"
                rules="required|email"
                name="tnt_user_login"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_user_login }}"
                  name="tnt_user_login"
                  v-model="configurations.tnt_user_login"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                rules="required"
                name="tnt_tipo_pessoa"
                v-slot="{ errors, valid }">
                <base-select
                  class="top-margin-large"
                  label="{{ entry_tipo_pessoa }}"
                  name="tnt_tipo_pessoa"
                  v-model="configurations.tnt_tipo_pessoa"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                  {% for  key, value in Type_CadastroPessoa %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                :rules="configurations.tnt_tipo_pessoa == 'F' ? 'required|cpf' : 'required|cnpj'"
                name="tnt_cnpj"
                v-slot="{ errors, valid }">
                <base-input
                  :label="configurations.tnt_tipo_pessoa == 'F' ? '{{ entry_cpf }}' : '{{ entry_cnpj }}'"
                  description="{{ entry_cnpj_description }}"
                  name="tnt_cnpj"
                  v-model="configurations.tnt_cnpj"
                  :mask="configurations.tnt_tipo_pessoa == 'F' ? 'cpf' : 'cnpj'"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                :class="['top-margin-large', {'hidden': configurations.tnt_tipo_pessoa == 'F'}]"
                :rules="configurations.tnt_tipo_pessoa == 'J' ? 'required' : ''"
                name="tnt_ie"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_ie }}"
                  name="tnt_ie"
                  v-model="configurations.tnt_ie"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_situacao_trib"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_situacao_trib }}"
                  name="tnt_situacao_trib"
                  v-model="configurations.tnt_situacao_trib"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required|cep"
                name="tnt_postcode"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_postcode }}"
                  name="tnt_postcode"
                  v-model="configurations.tnt_postcode"
                  mask="cep"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_tipo_servico"
                v-slot="{ errors, valid }">
                <base-select
                  class="top-margin-large"
                  label="{{ entry_tipo_servico }}"
                  name="tnt_tipo_servico"
                  v-model="configurations.tnt_tipo_servico"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                  {% for  key, value in Type_TntServico %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_tipo_frete"
                v-slot="{ errors, valid }">
                <base-select
                  class="top-margin-large"
                  label="{{ entry_tipo_frete }}"
                  name="tnt_tipo_frete"
                  v-model="configurations.tnt_tipo_frete"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                  {% for  key, value in Type_TntFrete %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_divisao_cliente"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_divisao_cliente }}"
                  name="tnt_divisao_cliente"
                  v-model="configurations.tnt_divisao_cliente"
                  :error="errors[0]"
                  :valid="valid"
                  required>
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="minmax_number:0,100"
                name="tnt_adicional"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_adicional }}"
                  description="{{ entry_adicional_description }}"
                  name="tnt_adicional"
                  v-model="configurations.tnt_adicional"
                  mask="percentage"
                  :error="errors[0]"
                  :valid="valid">
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="numeric|min_value:1"
                name="tnt_prazo_adicional"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_prazo_adicional }}"
                  description="{{ entry_prazo_adicional_description }}"
                  name="tnt_prazo_adicional"
                  v-model="configurations.tnt_prazo_adicional"
                  mask="integer"
                  :error="errors[0]"
                  :valid="valid">
                </base-input>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_tipo_peso"
                v-slot="{ errors, valid }">
                <base-select
                  class="top-margin-large"
                  label="{{ entry_tipo_peso }}"
                  name="tnt_tipo_peso"
                  v-model="configurations.tnt_tipo_peso"
                  :error="errors[0]"
                  :valid="valid">
                  {% for  key, value in Type_TntPeso %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="required"
                name="tnt_geo_zone_id"
                v-slot="{ errors, valid }">
                <base-select
                  class="top-margin-large"
                  label="{{ entry_geo_zone }}"
                  name="tnt_geo_zone_id"
                  v-model="configurations.tnt_geo_zone_id"
                  :error="errors[0]"
                  :valid="valid">
                  <option value="0">{{ text_all_zones }}</option>
                  {% for geo_zone in geo_zones %}
                    <option value="{{ geo_zone.geo_zone_id }}">{{ geo_zone.name }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

            </base-card>
          </div>
          <div class="col-xs-12 col-sm-4">
            <base-card class="padding-large">
              <validation-provider
                tag="div"
                rules="required"
                name="tnt_status"
                v-slot="{ errors, valid }">
                <base-select
                  label="{{ entry_status }}"
                  name="tnt_status"
                  v-model="configurations.tnt_status"
                  :error="errors[0]"
                  :valid="valid">
                  {% for key, value in Type_Status %}
                    <option value="{{ key }}">{{ value }}</option>
                  {% endfor %}
                </base-select>
              </validation-provider>

              <validation-provider
                tag="div"
                class="top-margin-large"
                rules="numeric"
                name="tnt_sort_order"
                v-slot="{ errors, valid }">
                <base-input
                  label="{{ entry_sort_order }}"
                  name="tnt_sort_order"
                  v-model="configurations.tnt_sort_order"
                  mask="integer"
                  :error="errors[0]"
                  :valid="valid">
                </base-input>
              </validation-provider>
            </base-card>
          </div>
        </div>
      </div>
    </form>
  </validation-observer>
</div>

<script>
  const DATA = {{ data|json_encode() }};
</script>

{{ footer }}