- type = impersonation ? "impersonation" : "personal access"

%h5.prepend-top-0
  Add a #{type} Token
%p.profile-settings-content
  Pick a name for the application, and we'll give you a unique #{type} Token.

= form_for token, url: path, method: :post, html: { class: 'js-requires-input' } do |f|

  = form_errors(token)

  .form-group
    = f.label :name, class: 'label-light'
    = f.text_field :name, class: "form-control", required: true

  .form-group
    = f.label :expires_at, class: 'label-light'
    = f.text_field :expires_at, class: "datepicker form-control"

  .form-group
    = f.label :scopes, class: 'label-light'
    = render 'shared/tokens/scopes_form', prefix: 'personal_access_token', token: token, scopes: scopes

  .prepend-top-default
    = f.submit "Create #{type} token", class: "btn btn-create"

:javascript
  var $dateField = $('.datepicker');
  var date = $dateField.val();

  new Pikaday({
    field: $dateField.get(0),
    theme: 'gitlab-theme animate-picker',
    format: 'yyyy-mm-dd',
    minDate: new Date(),
    container: $dateField.parent().get(0),
    onSelect: function(dateText) {
      $dateField.val(dateFormat(new Date(dateText), 'yyyy-mm-dd'));
    }
  });