Class: SolidusAdmin::Users::StoreCredits::Index::Component

Inherits:
BaseComponent
  • Object
show all
Includes:
Layout::PageHelpers
Defined in:
app/components/solidus_admin/users/store_credits/index/component.rb

Instance Method Summary collapse

Constructor Details

#initialize(user:, store_credits:) ⇒ Component

Returns a new instance of Component.



6
7
8
9
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 6

def initialize(user:, store_credits:)
  @user = user
  @store_credits = store_credits
end

Instance Method Details

#columnsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 53

def columns
  [
    {
      header: :credited,
      col: { class: "w-[12%]" },
      data: ->(store_credit) do
         :div, store_credit.display_amount.to_html, class: "text-sm"
      end
    },
    {
      header: :authorized,
      col: { class: "w-[13%]" },
      data: ->(store_credit) do
         :div, store_credit.display_amount_authorized.to_html, class: "text-sm"
      end
    },
    {
      header: :used,
      col: { class: "w-[9%]" },
      data: ->(store_credit) do
         :div, store_credit.display_amount_used.to_html, class: "text-sm"
      end
    },
    {
      header: :type,
      col: { class: "w-[13%]" },
      data: ->(store_credit) do
        component('ui/badge').new(name: store_credit.credit_type.name, color: :blue)
      end
    },
    {
      header: :created_by,
      col: { class: "w-[22%]" },
      data: ->(store_credit) do
         :div, store_credit.created_by_email, class: "font-semibold text-sm"
      end
    },
    {
      header: :issued_on,
      col: { class: "w-[16%]" },
      data: ->(store_credit) do
        I18n.l(store_credit.created_at.to_date)
      end
    },
    {
      header: :invalidated,
      col: { class: "w-[15%]" },
      data: ->(store_credit) do
        store_credit.invalidated? ? component('ui/badge').yes : component('ui/badge').no
      end
    },
  ]
end

#model_classObject



11
12
13
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 11

def model_class
  Spree::StoreCredit
end

#row_url(store_credit) ⇒ Object



49
50
51
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 49

def row_url(store_credit)
  spree.admin_user_store_credit_path(@user, store_credit)
end

#rowsObject



45
46
47
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 45

def rows
  @store_credits
end

#tabsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/solidus_admin/users/store_credits/index/component.rb', line 15

def tabs
  [
    {
      text: t('.account'),
      href: solidus_admin.user_path(@user),
      current: false,
    },
    {
      text: t('.addresses'),
      href: solidus_admin.addresses_user_path(@user),
      current: false,
    },
    {
      text: t('.order_history'),
      href: solidus_admin.orders_user_path(@user),
      current: false,
    },
    {
      text: t('.items'),
      href: spree.items_admin_user_path(@user),
      current: false,
    },
    {
      text: t('.store_credit'),
      href: solidus_admin.store_credits_user_path(@user),
      current: true,
    },
  ]
end