<div id="domain_box" class="box wide">
  <h1><%= "New domain" if @domain.new_record? %> <%= @domain.domain %></h1>

  <%= form_with model: @domain do |f| %>
    <%= errors_for @domain %>

    <%= hidden_field_tag :new_domain, @domain.domain || params[:id] %>
    <div class="boxline">
      <%= f.label :selector, "Origin selector" %>
      <%= f.text_field :selector %>
      <div class="d"><p class="help">Regexp with captures, must consume whole string like: <kbd>\Ahttps?://github.com/+([^/]+).*\z</kbd></p></div>
    </div>

    <div class="boxline">
      <%= f.label :replacement, "Origin replacement" %>
      <%= f.text_field :replacement %>
      <div class="d"><p class="help"><kbd>github.com/\1</kbd></p></div>
    </div>

    <div class="boxline">
      <%= f.submit 'Save' %>
    </div>
  <% end %>

  <br><br><hr><br>

  <% if @domain.banned_at %>
    <label class="required">Status:</label>
    <span class="d">
      Banned
    </span>
    <br>

    <label class="required">Banned Reason:</label>
    <span class="d">
      <%= @domain.banned_reason %>
    </span>
    <br>

    <label class="required">Banned At:</label>
    <span class="d">
      <%= @domain.banned_at %>
    </span>
    <br>

    <label class="required">Banned by User:</label>
    <span class="d">
      <%= @domain.banned_by_user.username %>
    </span>
  <% end %>

  <%= form_with model: @domain, url: @domain.new_record? ? create_and_ban_domain_path(id: @domain.domain) : ban_domain_path(id: @domain.domain) do |f| %>
    <%= hidden_field_tag :new_domain, @domain.new_record? %>

    <div class="boxline">
      <%= f.label :banned_reason, "#{caption_of_button(@domain)} Reason:", class: 'required' %>
      <%= f.text_field :banned_reason, value: '' %>
    </div>

    <div class="boxline">
        <%= f.submit caption_of_button(@domain), class: 'deletion' %>
    </div>
  <% end %>
</div>
