Sha256: e9ba03534891f539269380f43eea0d3dc814c80d69175c8dfec09e5fa930b2d4

Contents?: true

Size: 981 Bytes

Versions: 3

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

class SolidusAdmin::Orders::Show::Component < SolidusAdmin::BaseComponent
  include SolidusAdmin::Layout::PageHelpers

  def initialize(order:)
    @order = order
  end

  def form_id
    @form_id ||= "#{stimulus_id}--form-#{@order.id}"
  end

  def format_address(address)
    return unless address
    safe_join([
      address.name,
      tag.br,
      address.address1,
      tag.br,
      address.address2,
      address.city,
      address.zipcode,
      address.state&.name,
      tag.br,
      address.country.name,
      tag.br,
      address.phone,
    ], " ")
  end

  def turbo_frames
    %w[
      edit_order_email_modal
      edit_order_bill_address_modal
      edit_order_ship_address_modal
    ]
  end

  def customer_name(user)
    (
      user.default_user_bill_address ||
      user.default_user_ship_address ||
      user.user_addresses.where(default: true).first ||
      user.user_addresses.first
    )&.address&.name
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/components/solidus_admin/orders/show/component.rb
solidus_admin-0.3.1 app/components/solidus_admin/orders/show/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/orders/show/component.rb