Class: SolidusAdmin::Products::Status::Component

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/solidus_admin/products/status/component.rb

Constant Summary collapse

COLORS =
{
  available: :green,
  discontinued: :red
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(product:) ⇒ Component

Returns a new instance of Component.

Parameters:

  • product (Spree::Product)


10
11
12
# File 'app/components/solidus_admin/products/status/component.rb', line 10

def initialize(product:)
  @product = product
end

Instance Method Details

#callObject



14
15
16
17
18
19
# File 'app/components/solidus_admin/products/status/component.rb', line 14

def call
  render component('ui/badge').new(
    name: t(".#{status}"),
    color: COLORS.fetch(status)
  )
end

#statusSymbol

Returns :available when the product is available :discontinued when the product is not available.

Returns:

  • (Symbol)

    :available when the product is available :discontinued when the product is not available



24
25
26
27
28
29
30
# File 'app/components/solidus_admin/products/status/component.rb', line 24

def status
  if @product.available?
    :available
  else
    :discontinued
  end
end