diff --git a/admin/app/components/solidus_admin/orders/index/component.html.erb b/admin/app/components/solidus_admin/orders/index/component.html.erb index 17d95a59fbd..19617576018 100644 --- a/admin/app/components/solidus_admin/orders/index/component.html.erb +++ b/admin/app/components/solidus_admin/orders/index/component.html.erb @@ -9,7 +9,7 @@ <%= render component("ui/button").new( tag: :a, text: t('.create_order'), - href: solidus_admin.new_order_path, + href: spree.new_admin_order_path, icon: "add-line", ) %> diff --git a/admin/app/components/solidus_admin/orders/new/component.html.erb b/admin/app/components/solidus_admin/orders/show/component.html.erb similarity index 68% rename from admin/app/components/solidus_admin/orders/new/component.html.erb rename to admin/app/components/solidus_admin/orders/show/component.html.erb index 37a13c33309..cd6f18142b9 100644 --- a/admin/app/components/solidus_admin/orders/new/component.html.erb +++ b/admin/app/components/solidus_admin/orders/show/component.html.erb @@ -1,11 +1,8 @@ <%= page do %> <%= page_header do %> - <%= page_header_back solidus_admin.orders_path %> - - <%= page_header_title t(".create_order") %> - + <%= page_header_back(solidus_admin.orders_path) %> + <%= page_header_title("Order #{@order.number}") %> <%= page_header_actions do %> - <%= render component("feedback").new %> <%= render component("ui/button").new(tag: :button, scheme: :secondary, text: t(".discard"), form: form_id) %> <%= render component("ui/button").new(tag: :button, text: t(".save"), form: form_id) %> <% end %> diff --git a/admin/app/components/solidus_admin/orders/new/component.js b/admin/app/components/solidus_admin/orders/show/component.js similarity index 100% rename from admin/app/components/solidus_admin/orders/new/component.js rename to admin/app/components/solidus_admin/orders/show/component.js diff --git a/admin/app/components/solidus_admin/orders/new/component.rb b/admin/app/components/solidus_admin/orders/show/component.rb similarity index 73% rename from admin/app/components/solidus_admin/orders/new/component.rb rename to admin/app/components/solidus_admin/orders/show/component.rb index 7d98d44eb30..b0187d09da8 100644 --- a/admin/app/components/solidus_admin/orders/new/component.rb +++ b/admin/app/components/solidus_admin/orders/show/component.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class SolidusAdmin::Orders::New::Component < SolidusAdmin::BaseComponent +class SolidusAdmin::Orders::Show::Component < SolidusAdmin::BaseComponent include SolidusAdmin::Layout::PageHelpers def initialize(order:) diff --git a/admin/app/components/solidus_admin/orders/new/component.yml b/admin/app/components/solidus_admin/orders/show/component.yml similarity index 83% rename from admin/app/components/solidus_admin/orders/new/component.yml rename to admin/app/components/solidus_admin/orders/show/component.yml index d78429ce878..8a31242febc 100644 --- a/admin/app/components/solidus_admin/orders/new/component.yml +++ b/admin/app/components/solidus_admin/orders/show/component.yml @@ -1,6 +1,5 @@ # Add your component translations here. # Use the translation in the example in your template with `t(".hello")`. en: - create_order: Create Order save: Save discard: Discard diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb index ac92068ed8a..de463f89d75 100644 --- a/admin/app/controllers/solidus_admin/orders_controller.rb +++ b/admin/app/controllers/solidus_admin/orders_controller.rb @@ -18,16 +18,19 @@ def index end end - def new - @order = Spree::Order.new( - created_by: current_solidus_admin_user, - frontend_viewable: false, - store_id: current_store.try(:id) - ) + def show + load_order respond_to do |format| - format.html { render component('orders/new').new(order: @order) } + format.html { render component('orders/show').new(order: @order) } end end + + private + + def load_order + @order = Spree::Order.find_by!(number: params[:id]) + authorize! action_name, @order + end end end diff --git a/admin/config/routes.rb b/admin/config/routes.rb index 1f1604c5710..0cc1c3329bc 100644 --- a/admin/config/routes.rb +++ b/admin/config/routes.rb @@ -13,5 +13,9 @@ put :activate end end - resources :orders, only: [:index, :new, :create] + resources :orders, only: [:index] do + member do + get :cart, to: "orders#show" + end + end end diff --git a/admin/spec/components/previews/solidus_admin/orders/new/component_preview.rb b/admin/spec/components/previews/solidus_admin/orders/new/component_preview.rb deleted file mode 100644 index f402a1f9838..00000000000 --- a/admin/spec/components/previews/solidus_admin/orders/new/component_preview.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# @component "orders/new" -class SolidusAdmin::Orders::New::ComponentPreview < ViewComponent::Preview - include SolidusAdmin::Preview - - def overview - render_with_template(locals: { order: Spree::Order.new }) - end -end diff --git a/admin/spec/components/previews/solidus_admin/orders/new/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/orders/new/component_preview/overview.html.erb deleted file mode 100644 index e0fcfa4d526..00000000000 --- a/admin/spec/components/previews/solidus_admin/orders/new/component_preview/overview.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
- <%= render current_component.new(order: order) %> -
diff --git a/admin/spec/components/solidus_admin/orders/new/component_spec.rb b/admin/spec/components/solidus_admin/orders/new/component_spec.rb deleted file mode 100644 index 6f61edbc87e..00000000000 --- a/admin/spec/components/solidus_admin/orders/new/component_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe SolidusAdmin::Orders::New::Component, type: :component do - it "renders the overview preview" do - render_preview(:overview) - end -end