<%= form_tag({ controller: 'user', action: 'set_avatar' },
  class: 'image-crop js-image-crop',
  level: :member,
  style: "width: #{@post.get_sample_width}px; height:#{@post.get_sample_height}px",
) do %>
  <%= image_tag(@post.sample_url, class: 'image-crop__image js-image-crop--image') %>

  <%= hidden_field_tag 'post_id', @params[:id] %>
  <% if @params[:user_id] %>
    <%= hidden_field_tag 'user_id', @params[:user_id] %>
  <% end %>
  <%
    if @user.has_avatar? && @post == @user.avatar_post
      options = {
        left: @user.avatar_left,
        right: @user.avatar_right,
        top: @user.avatar_top,
        bottom: @user.avatar_bottom,
      }
    else
      options = { left: 0, right: 0, top: 0, bottom: 0 }
    end
  %>
  <% options.each do |field, value| %>
    <%= hidden_field_tag field, value %>
  <% end %>

  <div class="image-crop-preview js-image-crop--preview-container">
    <div
      class="image-crop-preview__frame"
      style="
        width: <%= CONFIG['avatar_max_width'] %>px;
        height: <%= CONFIG['avatar_max_height'] %>px
      "
    >
      <div class="image-crop-preview__preview js-image-crop--preview"></div>
    </div>

    <%= submit_tag t(:user_set_avatar) %>
  </div>
<% end %>
