{% from "components/icon.html" import Icon %}
{% from "components/text_input.html" import TextInput %}
{% from "components/multi_step_modal_form.html" import MultiStepModalForm %}

{% macro SimpleOptionsInput(field) %}
  <div class="usa-input">
    <fieldset data-ally-disabled="true" class="usa-input__choices">
      <legend>
        <div class="usa-input__title-inline">
          {{ field.label | striptags}}
        </div>
      </legend>
      {{ field() }}
    </fieldset>
  </div>
{% endmacro %}

{% set step_one %}
  <hr>
  <h1>Invite new portfolio member</h1>
  <div class='form-row'>
    <div class='form-col form-col--half'>
      {{ TextInput(member_form.user_data.first_name, validation='requiredField', optional=False) }}
    </div>
    <div class='form-col form-col--half'>
      {{ TextInput(member_form.user_data.last_name, validation='requiredField', optional=False) }}
    </div>
  </div>
  <div class='form-row'>
    <div class='form-col form-col--half'>
      {{ TextInput(member_form.user_data.email, validation='email', optional=False) }}
    </div>
    <div class='form-col form-col--half'>
      {{ TextInput(member_form.user_data.phone_number, validation='usPhone') }}
    </div>
  </div>
  <div class='form-row'>
    <div class='form-col form-col--half'>
      {{ TextInput(member_form.user_data.dod_id, validation='dodId', optional=False) }}
    </div>
    <div class='form-col form-col--half'>
    </div>
  </div>
  <div class='action-group'>
    <input
        type='button'
        v-on:click="next()"
        v-bind:disabled="!canSave"
        class='action-group__action usa-button usa-button-primary'
        value='Next'>
    <a class='action-group__action' v-on:click="closeModal('{{ new_port_mem }}')">Cancel</a>
  </div>
{% endset %}
{% set step_two %}
  <hr>
  <h1>Assign member permissions</h1>
  <a class='icon-link'>
    {{ Icon('info') }}
    {{ "portfolios.admin.permissions_info" | translate }}
  </a>
  {{ SimpleOptionsInput(member_form.permission_sets.perms_app_mgmt) }}
  {{ SimpleOptionsInput(member_form.permission_sets.perms_funding) }}
  {{ SimpleOptionsInput(member_form.permission_sets.perms_reporting) }}
  {{ SimpleOptionsInput(member_form.permission_sets.perms_portfolio_mgmt) }}
  <div class='action-group'>
    <input
      type="submit"
      class='action-group__action usa-button usa-button-primary'
      form="add-port-mem"
      value='Invite member'>
    <a class='action-group__action' v-on:click="closeModal('{{ new_port_mem }}')">Cancel</a>
  </div>
{% endset %}
{{ MultiStepModalForm(
    'add-port-mem',
    member_form,
    url_for("portfolios.invite_member", portfolio_id=portfolio.id),
    [step_one, step_two],
  ) }}
