Skip to content

Commit

Permalink
Reorganize the orders/show customer sidebar
Browse files Browse the repository at this point in the history
Remove the title so that "Customer" will only refer to Spree::User.
  • Loading branch information
elia committed Nov 10, 2023
1 parent fa98eee commit 1fb1f98
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 32 deletions.
67 changes: 35 additions & 32 deletions admin/app/components/solidus_admin/orders/show/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,53 +14,56 @@
<% end %>

<%= page_with_sidebar_aside do %>
<%= render component('ui/panel').new(title: t(".customer")) do |panel| %>
<%= render component('ui/panel').new do |panel| %>
<% panel.with_menu t(".edit_email"), solidus_admin.order_customer_path(@order) %>
<% panel.with_menu t(".edit_shipping"), solidus_admin.new_order_ship_address_path(@order) %>
<% panel.with_menu t(".edit_billing"), solidus_admin.new_order_bill_address_path(@order) %>
<% panel.with_menu t(".remove_customer"), solidus_admin.order_customer_path(@order), method: :delete, class: "text-red-500" if @order.user %>

<% panel.with_section(class: 'flex flex-col gap-6') do %>
<%# CUSTOMER %>
<% if @order.user %>
<div class="flex flex-col gap-2">
<div class="body-small-bold"><%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %></div>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= t(".customer") %></span>
<% if @order.user %>
<div class="body-small"><%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %></div>
<div class="body-small body-link"><%= link_to @order.user.email, spree.admin_user_path(@order.user) %></div>
<div class="body-small text-gray-500"><%= t(".orders_count", count: @order.user.orders.complete.count) %></div>
</div>
<% end %>
<% end %>
</div>

<%# EMAIL %>
<% if @order.email %>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= t('.order_email') %></span>
<div class="body-small"><%= @order.email %></div>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= t('.order_email') %></span>
<div class="body-small">
<% if @order.email? %>
<%= @order.email %>
<% else %>
<%= link_to(t(".add_email"), solidus_admin.order_customer_path(@order), class: "body-link") %>
<% end %>
</div>
<% end %>
</div>

<%# SHIPPING %>
<% if @order.ship_address %>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= @order.class.human_attribute_name(:ship_address) %></span>
<div class="body-small">
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= @order.class.human_attribute_name(:ship_address) %></span>
<div class="body-small">
<% if @order.ship_address %>
<%= format_address @order.ship_address %>
</div>
<% else %>
<%= link_to t(".add_shipping"), solidus_admin.new_order_ship_address_path(@order), class: 'body-link' %>
<% end %>
</div>
<% end %>
</div>

<%# BILLING %>
<% if @order.bill_address %>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= @order.class.human_attribute_name(:bill_address) %></span>
<div class="body-small">
<% if @order.bill_address == @order.ship_address %>
<span class="text-gray-500"><%= t('.same_as_shipping') %></span>
<% else %>
<%= format_address @order.bill_address %>
<% end %>
</div>
<div class="flex flex-col gap-2">
<span class="body-small-bold"><%= @order.class.human_attribute_name(:bill_address) %></span>
<div class="body-small">
<% if @order.bill_address.blank? %>
<%= link_to t(".add_billing"), solidus_admin.new_order_bill_address_path(@order), class: 'body-link' %>
<% elsif @order.bill_address == @order.ship_address %>
<span class="text-gray-500"><%= t('.same_as_shipping') %></span>
<% else %>
<%= format_address @order.bill_address %>
<% end %>
</div>
<% end %>
</div>

<% end %>
<% end %>
Expand Down
3 changes: 3 additions & 0 deletions admin/app/components/solidus_admin/orders/show/component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ en:
same_as_shipping: Same as shipping address

edit_email: "Edit order email"
add_email: "Add order email"
edit_shipping: "Edit shipping address"
add_shipping: "Add shipping address"
edit_billing: "Edit billing address"
add_billing: "Add billing address"
remove_customer: "Remove customer"

orders_count:
Expand Down

0 comments on commit 1fb1f98

Please sign in to comment.