Sha256: 166e0c5164fa2ba79385038cc5361d76b5534e5bb616850643255bf2dbfb0c3a
Contents?: true
Size: 685 Bytes
Versions: 2
Compression:
Stored size: 685 Bytes
Contents
# frozen_string_literal: true class SolidusAdmin::Products::Status::Component < SolidusAdmin::BaseComponent STATUSES = { available: :green, discontinued: :yellow, deleted: :red, unavailable: :yellow }.freeze def self.from_product(product) status = if product.deleted? :deleted elsif product.discontinued? :discontinued elsif product.available? :available else :unavailable end new(status: status) end def initialize(status:) @status = status end def call render component('ui/badge').new( name: t(".#{@status}"), color: STATUSES.fetch(@status) ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_admin-0.3.1 | app/components/solidus_admin/products/status/component.rb |
solidus_admin-0.3.0 | app/components/solidus_admin/products/status/component.rb |