Class: Happenings::DetailComponent

Inherits:
CommonComponent show all
Defined in:
app/components/happenings/detail_component.rb

Instance Method Summary collapse

Methods inherited from CommonComponent

#icon, #icon_text, #level, #level_item, #pagy, #turbo_yield

Methods included from ApplicationHelper

#fas_icon, #icon, #icon_text, #l_date, #l_long, #l_time, #notifications, #notify, #notify_status, #t_enum

Constructor Details

#initialize(happening:, user: nil, editor: false) ⇒ DetailComponent

Returns a new instance of DetailComponent.



5
6
7
8
9
10
# File 'app/components/happenings/detail_component.rb', line 5

def initialize(happening:, user: nil, editor: false)
  super
  @happening = happening
  @user = user
  @editor = editor
end

Instance Method Details

#infoObject



12
13
14
15
16
17
18
19
20
# File 'app/components/happenings/detail_component.rb', line 12

def info
  ary = [
    [ t(".start_at"), l(@happening.start_at, format: :short) ],
    [ t(".max_tickets"), @happening.max_tickets ],
    [ t(".max_tickets_for_user"), @happening.max_tickets_for_user ],
    [ t(".available_tickets"), tag.span(@happening.tickets_available, id: "available_#{@happening.id}") ]
  ]
  level ary
end


22
23
24
# File 'app/components/happenings/detail_component.rb', line 22

def new_link
  @user.present? ? tickets_path(ticket: { happening_id: @happening.id }) : new_user_session_path
end