<%= render partial: 'form_errors', locals: { what: @order } %>

Order #<%= @order.id %>

<%= render 'orders/commonshow' %> <% if @order.status == Order::PAID %> <%# This should be a POST to avoid CSRF, even though GET would suffice because nothing in POST body. order id determined by controller using url. %>

<%= form_for([:vendor, @order], method: 'post', url: { action: 'accept' }) do |f| %>

<%= f.submit 'Accept order', class: 'btn btn-primary form-button' %>
<% end %>

<%= link_to 'Decline order', '#decline', class: 'btn btn-warning' %>

<% elsif @order.allow_shipped? %> <%= form_for([:vendor, @order], method: 'post', url: { action: 'ship' }) do |f| %>
<%= f.submit 'Shipped', class: 'btn btn-primary form-button' %>
<% end %> <% if @order.status == Order::FINALIZED %>

Shipped button will set shipped date to current time.

<% end %> <% elsif @order.status == Order::REFUND_REQUESTED %> <%= form_for([:vendor, @order], method: 'post', url: { action: 'finalize_refund' }) do |f| %>
<%= f.submit 'Approve refund', class: 'btn btn-primary form-button' %>
<% end %> <% end %> <% if @order.allow_feedback_submission? && @order.feedbacks.find_by(placedby: current_user).nil? %><%# use find_by so it returns a feedback or nil. %> <%= link_to 'Submit feedback', new_feedback_path(order: @order.id), class: 'btn btn-primary form-button' %> <%end%> <% if @order.allow_vendor_archive? %> <%= link_to 'Archive', '#confirm_archive', class: 'btn btn-info form-button' %> <% end %> <% if @order.archived_by_vendor %> <%= link_to 'Unarchive', '#confirm_unarchive', class: 'btn btn-info form-button' %> <% end %> <% if @order.allow_vendor_delete? %> <%= link_to 'Delete', '#confirm_delete', class: 'btn btn-danger form-button' %> <% end %>