Skip to content

Commit

Permalink
Render order address form
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerdema committed Oct 26, 2023
1 parent 15fc696 commit 7ba63f5
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
46 changes: 46 additions & 0 deletions admin/app/components/solidus_admin/orders/show/component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,56 @@
<% end %>
<% end %>

<%= form_for @order, url: solidus_admin.order_customer_path(@order), html: { id: form_id } do |f| %>
<%= page_with_sidebar do %>
<%= page_with_sidebar_main do %>

<%= render component('orders/cart').new(order: @order) %>

<%= render component('ui/panel').new(title: t(".customer_information")) do %>
<div class="flex flex-wrap gap-4 pb-4">
<%= render component("ui/forms/field").text_field(f, :email) %>

<div class="w-full flex items-center mb-4 border-b pb-4">
<%= render component('ui/forms/checkbox').new(
name: "#{f.object_name}[guest_checkout]",
checked: f.object.guest_token,
) %>
<%= label_tag nil, 'Guest checkout', class: "ml-2 text-sm text-gray-700" %>
</div>

<h2 class="text-xl mb-4 font-semibold"><%= t(".shipping_address") %></h2>
<div class="flex flex-wrap gap-4 border-b pb-4">
<%= f.fields_for :ship_address do |ba_form| %>
<%= render component("ui/forms/field").text_field(ba_form, :name) %>
<%= render component("ui/forms/field").text_field(ba_form, :address1) %>
<%= render component("ui/forms/field").text_field(ba_form, :address2) %>
<div class="flex w-full space-x-4">
<%= render component("ui/forms/field").text_field(ba_form, :city, class: "flex-1") %>
<%= render component("ui/forms/field").text_field(ba_form, :zipcode, class: "flex-1") %>
</div>
<%= render component("ui/forms/field").select(ba_form, :country, Spree::Country.all.map { |c| [c.name, c.id] }) %>
<%= render component("ui/forms/field").select(ba_form, :state, Spree::State.all.map { |s| [s.name, s.id] }) %>
<%= render component("ui/forms/field").text_field(ba_form, :phone) %>
<% end %>
</div>

<h2 class="text-xl mb-4 mt-4 font-semibold"><%= t(".billing_address") %></h2>
<div class="flex flex-wrap gap-4">
<%= f.fields_for :bill_address do |ba_form| %>
<%= render component("ui/forms/field").text_field(ba_form, :name) %>
<%= render component("ui/forms/field").text_field(ba_form, :address1) %>
<%= render component("ui/forms/field").text_field(ba_form, :address2) %>
<div class="flex w-full space-x-4">
<%= render component("ui/forms/field").text_field(ba_form, :city, class: "flex-1") %>
<%= render component("ui/forms/field").text_field(ba_form, :zipcode, class: "flex-1") %>
</div>
<%= render component("ui/forms/field").select(ba_form, :country, Spree::Country.all.map { |c| [c.name, c.id] }) %>
<%= render component("ui/forms/field").select(ba_form, :state, Spree::State.all.map { |s| [s.name, s.id] }) %>
<%= render component("ui/forms/field").text_field(ba_form, :phone) %>
<% end %>
</div>
</div>
<% end %>
<% end %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SolidusAdmin::Orders::Show::Component < SolidusAdmin::BaseComponent
include SolidusAdmin::Layout::PageHelpers

def initialize(order:)
@order = order
@order = Spree::Order.complete.last #order
end

def form_id
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 @@ -4,3 +4,6 @@ en:
save: Save
discard: Discard
title: "Order %{number}"
customer_information: Create a new customer
shipping_address: Shipping Address
billing_address: Billing Address

0 comments on commit 7ba63f5

Please sign in to comment.