{% include 'header.twig' %}

<div class="container">
  <div class="row">
    <div class="col-md-8 col-md-offset-2">

      {% if errorText %}
        <div class="alert alert-dismissible alert-danger">
          <button type="button" class="close" data-dismiss="alert">&times;</button>
          {{ errorText }}
        </div>
      {% endif %}
      {% if successText %}
        <div class="alert alert-dismissible alert-success">
          <button type="button" class="close" data-dismiss="alert">&times;</button>
          {{ successText }}
        </div>
      {% endif %}

    {% if verify %}
      <div class="well">
        <form method="post" action="/verify/mail">

          <div class="form-group">
            <label for="username" class="control-label">{{ lang['verify.email'] }}</label>
            <input type="text" class="form-control"  placeholder="{{ user['email'] }}" disabled>
          </div>

            <div class="form-group">
              <div class="g-recaptcha" data-sitekey="{{ captchaKey }}"></div>
            </div>

            <button type="submit" class="btn btn-primary click">{{ lang['verify.submit'] }}</button>
            <span class="pull-right pull-right-middle"><a href="#" data-toggle="modal" data-target="#editAccount">{{ lang['verify.edit'] }}</a></span>
        </form>
      </div>

      <div id="editAccount" class="modal fade" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">{{ lang['verify.edit.title'] }}</h4>
            </div>
            <div class="modal-body">
              <form method="post" action="/verify/edit">
                <div class="form-group">
                  <label for="username" class="control-label">{{ lang['verify.email'] }}</label>
                  <input type="text" name="email" class="form-control"  value="{{ user['email'] }}">
                </div>
            </div>
            <div class="modal-footer">
              <button type="submit" class="btn btn-primary">{{ lang['verify.edit.submit'] }}</button></form>
              <button type="button" class="btn btn-default" data-dismiss="modal">{{ lang['verify.edit.close'] }}</button>
            </div>
          </div>
        </div>
      </div>       
    {% else %}
      <div class="well">
        <form method="post" action="/verify/sms">

          <div class="form-group">
            <label for="username" class="control-label">{{ lang['verify.telephone'] }}</label>
            <input type="text" class="form-control"  placeholder="{{ user['telephone'] }}" disabled>
          </div>

            <div class="form-group">
              <div class="g-recaptcha" data-sitekey="{{ captchaKey }}"></div>
            </div>

            <button type="submit" class="btn btn-primary click">{{ lang['verify.submit'] }}</button>
            <span class="pull-right pull-right-middle"><a href="#" data-toggle="modal" data-target="#editAccount">{{ lang['verify.edit'] }}</a></span>
        </form>
      </div>

      <div id="editAccount" class="modal fade" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <h4 class="modal-title">{{ lang['verify.edit.title'] }}</h4>
            </div>
            <div class="modal-body">
              <form method="post" action="/verify/edit">
                <div class="form-group">
                  <label for="username" class="control-label">{{ lang['verify.telephone'] }}</label>
                  <input type="text" name="telephone" class="form-control"  value="{{ user['telephone'] }}">
                </div>
            </div>
            <div class="modal-footer">
              <button type="submit" class="btn btn-primary">{{ lang['verify.edit.submit'] }}</button></form>
              <button type="button" class="btn btn-default" data-dismiss="modal">{{ lang['verify.edit.close'] }}</button>
            </div>
          </div>
        </div>
      </div>     
      
    {% endif %}
    </div>
  </div>
</div>

{% for lang in site['languages'] %}
  {% if lang['active'] %}
    <script src="https://www.google.com/recaptcha/api.js?hl={{ lang['code'] }}"></script>
  {% endif %}
{% endfor %}

{% include 'footer.twig' %}
