<% auction_started = auction.started? %> <% auction_complete = auction.complete %>
<%= f.field_container :title do %> <%= f.label :title, class: 'required' %> <%= f.field_hint :title %> <%= f.text_field :title, disable_on_complete(auction_complete, {class: 'fullwidth title', required: true}) %> <%= f.error_message_on :title %> <% end %>
<%= f.field_container :description do %> <%= f.label :description, class: 'required' %> <%= f.text_area :description, disable_on_complete(auction_complete, {class: 'fullwidth'}) %> <%= f.error_message_on :description %> <% end %>
<%= f.field_container :starting_price do %> <%= f.label :starting_price, class: 'required' %> <%= f.number_field :starting_price, disable_on_start(auction_started, { step: 0.01, min: 0 }) %> <%= f.error_message_on :starting_price %> <% end %>
<%= f.field_container :reserve_price do %> <%= f.label :reserve_price %> <%= f.field_hint :reserve_price %> <%= f.number_field :reserve_price, disable_on_start(auction_started, { step: 0.01, min: 0 }) %> <%= f.error_message_on :reserve_price %> <% end %>
<%= f.field_container :product_id do %> <%= f.label :product_id, class: 'required' %> <%= f.hidden_field :product_id, disable_on_complete(auction_complete, {}) %> <% end %>
<%= f.field_container :bid_increment do %> <%= f.label :bid_increment %> <%= f.field_hint :bid_increment %> <%= f.number_field :bid_increment, disable_on_start(auction_started, { step: 0.01, min: 0 }) %> <%= f.error_message_on :bid_increment %> <% end %>
<%= f.field_container :starting_datetime do %> <%= f.label :starting_datetime, Spree.t("starting_datetime") %> <%= f.field_hint :start %>
<%= f.datetime_select :starting_datetime, { default: 1.days.from_now, ampm: true, minute_step: 5}, disable_on_complete(auction_complete, { class: "custom-select" }) %> <%= f.error_message_on :starting_datetime %>
<% end %>
<%= f.field_container :planned_end_datetime do %> <%= f.label :planned_end_datetime, Spree.t("planned_end_datetime") %>
<%= f.datetime_select :planned_end_datetime, disable_on_complete(auction_complete,{ default: 7.days.from_now, ampm: true, minute_step: 5}), { class: "custom-select"} %> <%= f.error_message_on :planned_end_datetime %>
<% end %>
<% seconds_limit = 0..3600 %>
<%= f.field_container :countdown do %> <%= f.label :countdown, Spree.t("countdown_seconds") %> <%= f.field_hint :countdown %> <%= f.number_field :countdown, disable_on_complete(auction_complete, {in: seconds_limit}) %> <%= f.error_message_on :countdown %> <% end %>
<%= f.field_container :time_increment do %> <%= f.label :time_increment %> <%= f.field_hint :time_increment %> <%= f.number_field :time_increment, disable_on_complete(auction_complete, {in: seconds_limit}) %> <%= f.error_message_on :time_increment %> <% end %>
<% minutes_limit = 1..10080 %>
<%= f.field_container :checkout_time_minutes do %> <%= f.label :checkout_time_minutes%> <%= f.field_hint :checkout_time_minutes%> <%= f.number_field :checkout_time_minutes, disable_on_complete(auction_complete, {in: minutes_limit}) %> <%= f.error_message_on :checkout_time_minutes%> <% end %>
<%= f.field_container :current_price do %> <%= f.label :current_price %> <%= f.text_field :current_price, { readonly: true, disabled: true } %> <%= f.error_message_on :current_price %> <% end %>
<% if !@auction.complete && auction.started? %>
<%= f.field_container :current_end_datetime do %>

<%= render partial: 'spree/shared/ends_in', locals: { auction: @auction } %>

<% end %>
<% end %> <% if @auction.current_end_datetime %>
<%= f.field_container :current_end_datetime do %> <%= f.field_hint :end %>

<%= local_time @auction.current_end_datetime %>

<% end %>
<% end %>
<% if @auction.current_end_datetime %>
<%= f.field_container :current_end_datetime do %>

<%= local_time @auction.checkout_deadline %>

<% end %>
<% end %> <% if auction.won? && !auction.order_complete? %>
<%= f.field_container :current_end_datetime do %>

<%= render partial: 'spree/shared/checkout_in', locals: { auction: @auction } %>

<% end %>
<% end %>
<% if highest_bidder = auction.highest_bidder %>
<% end %> <% if @auction.title %>
<%= f.field_container :current_end_datetime do %>

<%= link_to polymorphic_url(@auction), @auction, target: "_blank" %>

<% end %>
<% end %>
<% if @auction.won?%>
<%= f.field_container :current_end_datetime do %>

<% order = auction.order %> <%= link_to order.number, edit_admin_order_path(order) %>

<% end %>
<% end %>