diff --git a/admin/app/components/solidus_admin/orders/cart/component.html.erb b/admin/app/components/solidus_admin/orders/cart/component.html.erb
index d77b2a63a2f..2bd82d5ed42 100644
--- a/admin/app/components/solidus_admin/orders/cart/component.html.erb
+++ b/admin/app/components/solidus_admin/orders/cart/component.html.erb
@@ -3,77 +3,84 @@
data-controller="<%= stimulus_id %>"
data-<%= stimulus_id %>-products-url-value="<%= solidus_admin.variants_for_order_path(@order) %>"
data-action="
- <%= component('ui/search_panel').stimulus_id %>:search-><%= stimulus_id %>#search
- <%= component('ui/search_panel').stimulus_id %>:submit-><%= stimulus_id %>#selectResult
+ <%= component('ui/forms/search').stimulus_id %>:search-><%= stimulus_id %>#search
+ <%= component('ui/forms/search').stimulus_id %>:submit-><%= stimulus_id %>#selectResult
"
>
- <%= render component('ui/search_panel').new(
- title: t('.title'),
- search_placeholder: t('.search_placeholder'),
- id: :order_cart,
- ) do |panel| %>
-
- <%# CUSTOMER %>
- <% if @order.user %>
-
-
<%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %>
+ <%= 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 %>
+
+
<%= t(".customer") %>
+ <% if @order.user %>
+
<%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %>
<%= link_to @order.user.email, spree.admin_user_path(@order.user) %>
-
<%= t(".orders_count", count: @order.user.orders.count) %>
-
- <% end %>
+
<%= t(".orders_count", count: @order.user.orders.complete.count) %>
+ <% else %>
+ <%= render component('orders/show/customer_search').new(order: @order) %>
+ <% end %>
+
- <%# EMAIL %>
- <% if @order.email %>
-
-
<%= t('.order_email') %>
-
<%= @order.email %>
+
+
<%= t('.order_email') %>
+
+ <% if @order.email? %>
+ <%= @order.email %>
+ <% else %>
+ <%= link_to(t(".add_email"), solidus_admin.order_customer_path(@order), class: "body-link") %>
+ <% end %>
- <% end %>
+
- <%# SHIPPING %>
<%= @order.class.human_attribute_name(:ship_address) %>
<% if @order.ship_address %>
<%= format_address @order.ship_address %>
<% else %>
- <%= t('.no_shipping_address') %>
+ <%= link_to t(".add_shipping"), solidus_admin.new_order_ship_address_path(@order), class: 'body-link' %>
<% end %>
- <%# BILLING %>
<%= @order.class.human_attribute_name(:bill_address) %>
- <% if @order.bill_address %>
- <% if @order.bill_address == @order.ship_address %>
- <%= t('.same_as_shipping') %>
- <% else %>
- <%= format_address @order.bill_address %>
- <% end %>
+ <% 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 %>
+ <%= t('.same_as_shipping') %>
<% else %>
- <%= t('.no_billing_address') %>
+ <%= format_address @order.bill_address %>
<% end %>
-
-
+ <% end %>
<% end %>
<% end %>
diff --git a/admin/app/components/solidus_admin/orders/show/component.rb b/admin/app/components/solidus_admin/orders/show/component.rb
index 36a672d06a0..ba9cf656f0b 100644
--- a/admin/app/components/solidus_admin/orders/show/component.rb
+++ b/admin/app/components/solidus_admin/orders/show/component.rb
@@ -29,27 +29,6 @@ def format_address(address)
], " ")
end
- def panel_title_with_more_links(title, links)
- tag.details(
- tag.summary(
- tag.span(
- safe_join([
- title,
- component("ui/button").new(
- icon: "more-line",
- scheme: :ghost,
- tag: :span,
- alt: t("spree.edit"),
- class: "cursor-pointer"
- ).render_in(self),
- ]),
- class: 'flex items-center justify-between text-black',
- )
- ) + tag.div(safe_join(links, " "), class: "body-small absolute border border-gray-100 mt-0.5 right-0 flex min-w-[10rem] flex-col p-2 rounded-sm shadow-lg bg-white z-10"),
- class: 'relative',
- )
- end
-
def customer_name(user)
(
user.default_user_bill_address ||
diff --git a/admin/app/components/solidus_admin/orders/show/component.yml b/admin/app/components/solidus_admin/orders/show/component.yml
index 55755957b02..fd3f57289c5 100644
--- a/admin/app/components/solidus_admin/orders/show/component.yml
+++ b/admin/app/components/solidus_admin/orders/show/component.yml
@@ -7,13 +7,14 @@ en:
customer: Customer
no_name: No name available
order_email: Order contact email
- no_billing_address: No billing address
- no_shipping_address: No shipping address
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:
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/component.html.erb b/admin/app/components/solidus_admin/orders/show/customer_search/component.html.erb
new file mode 100644
index 00000000000..e867f7dd7d2
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/component.html.erb
@@ -0,0 +1,14 @@
+
-customers-url-value="<%= solidus_admin.customers_for_order_path(@order) %>"
+ data-action="
+ <%= component('ui/forms/search').stimulus_id %>:search-><%= stimulus_id %>#search
+ <%= component('ui/forms/search').stimulus_id %>:submit-><%= stimulus_id %>#submit
+ "
+>
+ <%= render component("ui/forms/search").new(
+ placeholder: t(".placeholder"),
+ id: :order_customer
+ ) %>
+
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/component.js b/admin/app/components/solidus_admin/orders/show/customer_search/component.js
new file mode 100644
index 00000000000..68e6b65b05b
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/component.js
@@ -0,0 +1,14 @@
+import { Controller } from '@hotwired/stimulus'
+
+export default class extends Controller {
+ static values = { customersUrl: String }
+
+ async search({ detail: { query, controller } }) {
+ controller.resultsValue =
+ (await (await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)).text())
+ }
+
+ submit(event) {
+ event.detail.resultTarget.querySelector('form').submit()
+ }
+}
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/component.rb b/admin/app/components/solidus_admin/orders/show/customer_search/component.rb
new file mode 100644
index 00000000000..1e3b8c2e385
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/component.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::Orders::Show::CustomerSearch::Component < SolidusAdmin::BaseComponent
+ def initialize(order:)
+ @order = order
+ end
+end
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/component.yml b/admin/app/components/solidus_admin/orders/show/customer_search/component.yml
new file mode 100644
index 00000000000..7d25505767a
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/component.yml
@@ -0,0 +1,2 @@
+en:
+ placeholder: "Search customer"
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb b/admin/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb
new file mode 100644
index 00000000000..ebe5c4ef2dd
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb
@@ -0,0 +1,17 @@
+<%= render component('ui/forms/search/result').new do %>
+ <% if @customer %>
+ <%= form_for(@order, url: solidus_admin.order_path(@order), html: {
+ "data-controller": "readonly-when-submitting",
+ class: "flex items-center",
+ }) do |f| %>
+ <%= hidden_field_tag("#{f.object_name}[user_id]", @customer.id) %>
+
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/admin/app/components/solidus_admin/orders/show/customer_search/result/component.rb b/admin/app/components/solidus_admin/orders/show/customer_search/result/component.rb
new file mode 100644
index 00000000000..695255a3ff4
--- /dev/null
+++ b/admin/app/components/solidus_admin/orders/show/customer_search/result/component.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::Orders::Show::CustomerSearch::Result::Component < SolidusAdmin::BaseComponent
+ with_collection_parameter :customer
+
+ def initialize(order:, customer:)
+ @order = order
+ @customer = customer
+ @name = (customer.default_user_bill_address || customer.default_user_ship_address)&.address&.name if customer
+ end
+end
diff --git a/admin/app/components/solidus_admin/orders/show/email/component.html.erb b/admin/app/components/solidus_admin/orders/show/email/component.html.erb
index 5ade14b6bc4..9bdff03edc0 100644
--- a/admin/app/components/solidus_admin/orders/show/email/component.html.erb
+++ b/admin/app/components/solidus_admin/orders/show/email/component.html.erb
@@ -5,7 +5,7 @@
<%= render component("ui/forms/field").text_field(f, :email) %>
<% end %>
diff --git a/admin/app/components/solidus_admin/ui/forms/search/component.html.erb b/admin/app/components/solidus_admin/ui/forms/search/component.html.erb
new file mode 100644
index 00000000000..cb1ab64e292
--- /dev/null
+++ b/admin/app/components/solidus_admin/ui/forms/search/component.html.erb
@@ -0,0 +1,52 @@
+
-loading-text-value="<%= t('.loading') %>"
+ data-<%= stimulus_id %>-initial-text-value="<%= t('.initial') %>"
+ data-<%= stimulus_id %>-empty-text-value="<%= t('.empty') %>"
+>
+
+
+ <%= render component("ui/forms/search_field").new(
+ id: "#{stimulus_id}--search-field--#{@id}",
+ "data-action": "
+ #{stimulus_id}#search
+ #{stimulus_id}#showResults
+ ",
+ "data-#{stimulus_id}-target": "searchField",
+ **@attributes,
+ ) %>
+
+
+
+
+ -target="results"
+ >
+
+
+
+
diff --git a/admin/app/components/solidus_admin/ui/search_panel/component.js b/admin/app/components/solidus_admin/ui/forms/search/component.js
similarity index 100%
rename from admin/app/components/solidus_admin/ui/search_panel/component.js
rename to admin/app/components/solidus_admin/ui/forms/search/component.js
diff --git a/admin/app/components/solidus_admin/ui/forms/search/component.rb b/admin/app/components/solidus_admin/ui/forms/search/component.rb
new file mode 100644
index 00000000000..808d80b487c
--- /dev/null
+++ b/admin/app/components/solidus_admin/ui/forms/search/component.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::UI::Forms::Search::Component < SolidusAdmin::BaseComponent
+ def initialize(id: nil, **attributes)
+ @id = id
+ @attributes = attributes
+ end
+end
diff --git a/admin/app/components/solidus_admin/ui/search_panel/component.yml b/admin/app/components/solidus_admin/ui/forms/search/component.yml
similarity index 100%
rename from admin/app/components/solidus_admin/ui/search_panel/component.yml
rename to admin/app/components/solidus_admin/ui/forms/search/component.yml
diff --git a/admin/app/components/solidus_admin/ui/forms/search/result/component.rb b/admin/app/components/solidus_admin/ui/forms/search/result/component.rb
new file mode 100644
index 00000000000..08add6e78dd
--- /dev/null
+++ b/admin/app/components/solidus_admin/ui/forms/search/result/component.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class SolidusAdmin::UI::Forms::Search::Result::Component < SolidusAdmin::BaseComponent
+ def call
+ tag.div(
+ content,
+ class: "rounded p-2 hover:bg-gray-25 aria-selected:bg-gray-25 cursor-pointer",
+ "data-#{component('ui/forms/search').stimulus_id}-target": "result",
+ "data-action": "click->#{component('ui/forms/search').stimulus_id}#clickedResult",
+ )
+ end
+end
diff --git a/admin/app/components/solidus_admin/ui/modal/component.html.erb b/admin/app/components/solidus_admin/ui/modal/component.html.erb
index ec23a4cfb35..c9ce14bbf80 100644
--- a/admin/app/components/solidus_admin/ui/modal/component.html.erb
+++ b/admin/app/components/solidus_admin/ui/modal/component.html.erb
@@ -8,9 +8,9 @@
>
-
+
-
+
<%= @title %>
@@ -28,7 +28,7 @@
<% if actions? %>
-
diff --git a/admin/app/components/solidus_admin/ui/panel/component.rb b/admin/app/components/solidus_admin/ui/panel/component.rb
index ea009198589..2925ecebb15 100644
--- a/admin/app/components/solidus_admin/ui/panel/component.rb
+++ b/admin/app/components/solidus_admin/ui/panel/component.rb
@@ -10,6 +10,23 @@ class SolidusAdmin::UI::Panel::Component < SolidusAdmin::BaseComponent
)
}
+ renders_many :sections, ->(wide: false, high: false, **args, &block) do
+ tag.section(**args, class: "
+ border-gray-100 border-t w-full first-of-type:border-t-0
+ #{'px-6' unless wide}
+ #{'py-6' unless high}
+ #{args[:class]}
+ ", &block)
+ end
+
+ renders_many :menus, ->(name, url, **args) do
+ if args[:method]
+ button_to(name, url, **args, class: "p-2 hover:bg-gray-25 rounded-sm text-black #{args[:class]}")
+ else
+ link_to(name, url, **args, class: "p-2 hover:bg-gray-25 rounded-sm text-black #{args[:class]}")
+ end
+ end
+
# @param title [String] the title of the panel
# @param title_hint [String] the title hint of the panel
def initialize(title: nil, title_hint: nil)
diff --git a/admin/app/components/solidus_admin/ui/panel/component.yml b/admin/app/components/solidus_admin/ui/panel/component.yml
new file mode 100644
index 00000000000..fe3f3f93212
--- /dev/null
+++ b/admin/app/components/solidus_admin/ui/panel/component.yml
@@ -0,0 +1,2 @@
+en:
+ more: "More"
diff --git a/admin/app/components/solidus_admin/ui/search_panel/component.html.erb b/admin/app/components/solidus_admin/ui/search_panel/component.html.erb
deleted file mode 100644
index bb4403ca1ab..00000000000
--- a/admin/app/components/solidus_admin/ui/search_panel/component.html.erb
+++ /dev/null
@@ -1,58 +0,0 @@
-
-loading-text-value="<%= t('.loading') %>"
- data-<%= stimulus_id %>-initial-text-value="<%= t('.initial') %>"
- data-<%= stimulus_id %>-empty-text-value="<%= t('.empty') %>"
->
- <%= render component('ui/panel').new(**@panel_args) do |panel| %>
-
-
-
- <%= render component("ui/forms/search_field").new(
- id: "#{stimulus_id}--search-field--#{@id}",
- placeholder: @search_placeholder,
- "data-action": "
- #{stimulus_id}#search
- #{stimulus_id}#showResults
- ",
- "data-#{stimulus_id}-target": "searchField",
- ) %>
-
-
-
-
- -target="results"
- >
-
-
-
-
-
- <%= content %>
-
- <% end %>
-
diff --git a/admin/app/components/solidus_admin/ui/search_panel/component.rb b/admin/app/components/solidus_admin/ui/search_panel/component.rb
deleted file mode 100644
index b8f32ac5382..00000000000
--- a/admin/app/components/solidus_admin/ui/search_panel/component.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: true
-
-class SolidusAdmin::UI::SearchPanel::Component < SolidusAdmin::BaseComponent
- def initialize(search_placeholder: nil, id: nil, **panel_args)
- @search_placeholder = search_placeholder
- @panel_args = panel_args
- @id = id
- end
-end
diff --git a/admin/app/components/solidus_admin/ui/search_panel/result/component.rb b/admin/app/components/solidus_admin/ui/search_panel/result/component.rb
deleted file mode 100644
index 520bbbce5ed..00000000000
--- a/admin/app/components/solidus_admin/ui/search_panel/result/component.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-# frozen_string_literal: true
-
-class SolidusAdmin::UI::SearchPanel::Result::Component < SolidusAdmin::BaseComponent
- def call
- tag.div(
- content,
- class: "rounded p-2 hover:bg-gray-25 aria-selected:bg-gray-25 cursor-pointer",
- "data-#{component('ui/search_panel').stimulus_id}-target": "result",
- "data-action": "click->#{component('ui/search_panel').stimulus_id}#clickedResult",
- )
- end
-end
diff --git a/admin/app/controllers/solidus_admin/customers_controller.rb b/admin/app/controllers/solidus_admin/customers_controller.rb
index 9b7fbd5af09..07e34cd95b1 100644
--- a/admin/app/controllers/solidus_admin/customers_controller.rb
+++ b/admin/app/controllers/solidus_admin/customers_controller.rb
@@ -1,12 +1,22 @@
# frozen_string_literal: true
class SolidusAdmin::CustomersController < SolidusAdmin::BaseController
- before_action :load_order, only: :show
+ before_action :load_order, only: [:show, :destroy]
def show
render component('orders/show/email').new(order: @order)
end
+ def destroy
+ if @order.update(user: nil)
+ flash[:success] = t('.success')
+ else
+ flash[:error] = t('.error')
+ end
+
+ redirect_to order_path(@order), status: :see_other
+ end
+
private
def load_order
diff --git a/admin/app/controllers/solidus_admin/orders_controller.rb b/admin/app/controllers/solidus_admin/orders_controller.rb
index 71044becabc..8570029ffd8 100644
--- a/admin/app/controllers/solidus_admin/orders_controller.rb
+++ b/admin/app/controllers/solidus_admin/orders_controller.rb
@@ -74,6 +74,22 @@ def variants_for
end
end
+ def customers_for
+ load_order
+
+ @users = Spree.user_class
+ .where.not(id: @order.user_id)
+ .order(created_at: :desc, id: :desc)
+ .ransack(params[:q])
+ .result(distinct: true)
+ .includes(:default_user_bill_address, :default_user_ship_address)
+ .limit(10)
+
+ respond_to do |format|
+ format.html { render component('orders/show/customer_search/result').with_collection(@users, order: @order), layout: false }
+ end
+ end
+
private
def load_order
diff --git a/admin/config/locales/customers.en.yml b/admin/config/locales/customers.en.yml
new file mode 100644
index 00000000000..a3ac8df8832
--- /dev/null
+++ b/admin/config/locales/customers.en.yml
@@ -0,0 +1,7 @@
+en:
+ solidus_admin:
+ customers:
+ title: "Customers"
+ destroy:
+ success: "Customer was removed successfully"
+ error: "Customer could not be removed"
diff --git a/admin/config/locales/orders.en.yml b/admin/config/locales/orders.en.yml
index 798fb7ea183..f27376c9ab5 100644
--- a/admin/config/locales/orders.en.yml
+++ b/admin/config/locales/orders.en.yml
@@ -4,6 +4,7 @@ en:
title: "Orders"
update:
success: "Order was updated successfully"
+ error: "Order could not be updated"
addresses:
title: "Addresses"
update:
diff --git a/admin/config/routes.rb b/admin/config/routes.rb
index 9322532bd18..d0c3a997fa9 100644
--- a/admin/config/routes.rb
+++ b/admin/config/routes.rb
@@ -26,6 +26,7 @@
member do
get :variants_for
+ get :customers_for
end
end
end
diff --git a/admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview.rb b/admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview.rb
similarity index 50%
rename from admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview.rb
rename to admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview.rb
index cc3ab94a5dc..cf9aa0f02c4 100644
--- a/admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview.rb
+++ b/admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-# @component "ui/search_panel"
-class SolidusAdmin::UI::SearchPanel::ComponentPreview < ViewComponent::Preview
+# @component "ui/forms/search"
+class SolidusAdmin::UI::Forms::Search::ComponentPreview < ViewComponent::Preview
include SolidusAdmin::Preview
def overview
diff --git a/admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview/overview.html.erb
similarity index 87%
rename from admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview/overview.html.erb
rename to admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview/overview.html.erb
index 6699a39eaef..15ad99adbbb 100644
--- a/admin/spec/components/previews/solidus_admin/ui/search_panel/component_preview/overview.html.erb
+++ b/admin/spec/components/previews/solidus_admin/ui/forms/search/component_preview/overview.html.erb
@@ -9,7 +9,7 @@
})
window.addEventListener('<%= current_component.stimulus_id %>:search', (event) => {
const {controller, query} = event.detail
- const resultTemplate = `<%= render component('ui/search_panel/result').new.with_content("{{content}}") %>`
+ const resultTemplate = `<%= render component('ui/forms/search/result').new.with_content("{{content}}") %>`
setTimeout(() => {
controller.resultsValue = [
resultTemplate.replace('{{content}}', `Result 1 for ${query}`),
diff --git a/admin/spec/components/previews/solidus_admin/ui/panel/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/ui/panel/component_preview/overview.html.erb
index 36976757baf..cada7959486 100644
--- a/admin/spec/components/previews/solidus_admin/ui/panel/component_preview/overview.html.erb
+++ b/admin/spec/components/previews/solidus_admin/ui/panel/component_preview/overview.html.erb
@@ -1,4 +1,21 @@
+
+
+ Full
+
+
+ <%= render current_component.new(title: "SEO") do |panel| %>
+ <% panel.with_menu("Foo", "#foo") %>
+ <% panel.with_menu("Bar", "#bar") %>
+ <% panel.with_section do %><% end %>
+ <% panel.with_section do %><% end %>
+ <% panel.with_section do %><% end %>
+ <% panel.with_section do %><% end %>
+ <% panel.with_action(name: "Foo", href: "#foo") %>
+ <% end %>
+
+
+
Content only
@@ -61,3 +78,13 @@
<% panel.with_action(name: "Foo", href: "#foo") %>
<% end %>
+
+
+
+ With a menu
+
+
+ <%= render current_component.new(title: "SEO") do |panel| %>
+ <% panel.with_menu("Foo", "#foo") %>
+ <% end %>
+
diff --git a/admin/spec/components/solidus_admin/ui/search_panel/component_spec.rb b/admin/spec/components/solidus_admin/ui/forms/search/component_spec.rb
similarity index 62%
rename from admin/spec/components/solidus_admin/ui/search_panel/component_spec.rb
rename to admin/spec/components/solidus_admin/ui/forms/search/component_spec.rb
index 15209522472..e87a17f6290 100644
--- a/admin/spec/components/solidus_admin/ui/search_panel/component_spec.rb
+++ b/admin/spec/components/solidus_admin/ui/forms/search/component_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe SolidusAdmin::UI::SearchPanel::Component, type: :component do
+RSpec.describe SolidusAdmin::UI::Forms::Search::Component, type: :component do
it "renders the overview preview" do
render_preview(:overview)
end
diff --git a/admin/spec/features/order_spec.rb b/admin/spec/features/order_spec.rb
index c4243fa3e07..ccd5efffeeb 100644
--- a/admin/spec/features/order_spec.rb
+++ b/admin/spec/features/order_spec.rb
@@ -5,13 +5,28 @@
describe "Order", :js, type: :feature do
before { sign_in create(:admin_user, email: 'admin@example.com') }
+ it "allows detaching a customer from an order" do
+ order = create(:order, number: "R123456789", user: create(:user))
+
+ visit "/admin/orders/R123456789"
+
+ open_customer_menu
+ click_on "Remove customer"
+
+ expect(page).to have_content("Customer was removed successfully")
+ open_customer_menu
+ expect(page).not_to have_content("Remove customer")
+ expect(order.reload.user).to be_nil
+ expect(page).to be_axe_clean
+ end
+
it "allows changing the order email" do
create(:order, number: "R123456789", total: 19.99)
visit "/admin/orders/R123456789/edit"
expect(page).to have_content("Order R123456789")
- find("summary", text: "Customer").click
+ open_customer_menu
click_on "Edit order email"
within("dialog") do
fill_in "Customer Email", with: "a@b.c"
@@ -19,6 +34,7 @@
end
expect(page).to have_content("Order was updated successfully")
expect(page).to have_content("Order contact email a@b.c", normalize_ws: true)
+ expect(page).to be_axe_clean
end
context "in cart state" do
@@ -32,7 +48,7 @@
expect(page).to have_content("Order R123456789")
- search_field = find("[data-#{SolidusAdmin::UI::SearchPanel::Component.stimulus_id}-target='searchField']")
+ search_field = find("[data-#{SolidusAdmin::UI::Forms::Search::Component.stimulus_id}-target='searchField']")
search_field.set "another"
expect(page).not_to have_content("Just a product")
@@ -58,4 +74,10 @@
expect(page).to be_axe_clean
end
end
+
+ private
+
+ def open_customer_menu
+ find("summary[title='More']").click
+ end
end