{% extends 'layout.html.twig' %}
{% block title %}{{'设置帐号'|trans}} - {{ parent() }}{% endblock %}
{% set hideSetupHint = true %}
{% do script(['libs/jquery-validation.js','app/js/settings/setup/index.js'])%}

{% block content %}
<div class="row row-6">
  <div class="col-md-6 col-md-offset-3">

    <div class="panel panel-default panel-page">
      <div class="panel-heading"><h2>{{'设置帐号'|trans}}</h2></div>

      {% set emailArr = app.user.email|split('@') %}
      {% if not app.user.setup or emailArr[1] == 'edusoho.net' %}
        <form id="setup-form" class="form-vertical" method="post" action="{{ path('settings_setup') }}">

          <div class="alert alert-warning"> {{'为了帐号的安全以及更好的使用体验，请设置以下信息。'|trans}} </div>

          <div class="form-group">
            <label class="control-label" for="setup-email-field">{{'Email地址'|trans}}</label>
            <div class="controls">
              <input class="form-control" id="setup-email-field" type="text" name="email" value="" data-url="{{ path('register_email_check') }}" />
            </div>
          </div>

          <div class="form-group">
            <label class="control-label" for="setup-nickname-field">{{'用户名'|trans}}</label>
            <div class="controls">
              <input class="form-control" id="setup-nickname-field" type="text" name="nickname" value="{{ app.user.nickname }}" data-url="{{ path('settings_setup_check_nickname') }}" />
              <div class="help-block">{{'用户名一旦保存，就不能再修改了'|trans}}</div>
            </div>
          </div>

          <div class="form-group">
            <div class="controls">
              <button type="button" class="btn btn-fat btn-primary btn-large js-submit-setup-form" data-loading-text="{{'正在保存'|trans}}..." data-goto="{{ path('homepage') }}">{{'保存'|trans}}</button>
            </div>
          </div>

          <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
        </form>
      {% else %}
        <div class="alert alert-danger">
          <p>{{'该帐号已经设置过Email地址和用户名，不能再次设置！'|trans}}</p>
          <p><a href="{{ path('homepage') }}" class="btn btn-primary">{{'返回首页'|trans}}</a></p>
        </div>
      {% endif %}

    </div>

  </div>
</div>
{% endblock %}