Sha256: 93e9ec619e6706e2cf6fa15235b383bccfeb16dd502953882b1852efe2f73cd0

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

class SolidusAdmin::Users::Edit::Component < SolidusAdmin::BaseComponent
  include SolidusAdmin::Layout::PageHelpers

  def initialize(user:)
    @user = user
  end

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

  def tabs
    [
      {
        text: t('.account'),
        href: solidus_admin.user_path(@user),
        current: action_name == "edit",
      },
      {
        text: t('.addresses'),
        href: solidus_admin.addresses_user_path(@user),
        current: action_name == "addresses",
      },
      {
        text: t('.order_history'),
        href: solidus_admin.orders_user_path(@user),
        current: action_name == "orders",
      },
      {
        text: t('.items'),
        href: spree.items_admin_user_path(@user),
        # @todo: update this "current" logic once folded into new admin
        current: action_name != "edit",
      },
      {
        text: t('.store_credit'),
        href: spree.admin_user_store_credits_path(@user),
        # @todo: update this "current" logic once folded into new admin
        current: action_name != "edit",
      },
    ]
  end

  def role_options
    Spree::Role.all.map do |role|
      { label: role.name, id: role.id }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/components/solidus_admin/users/edit/component.rb
solidus_admin-0.3.1 app/components/solidus_admin/users/edit/component.rb
solidus_admin-0.3.0 app/components/solidus_admin/users/edit/component.rb