demarches-normaliennes/app/components/procedure/card/service_component.rb
2022-07-21 18:07:56 +02:00

28 lines
686 B
Ruby

class Procedure::Card::ServiceComponent < ApplicationComponent
def initialize(procedure:, administrateur:)
@procedure = procedure
@administrateur = administrateur
end
private
def service_link
if @procedure.service.present?
edit_admin_service_path(@procedure.service, procedure_id: @procedure.id)
elsif @administrateur.services.present?
admin_services_path(procedure_id: @procedure.id)
else
new_admin_service_path(procedure_id: @procedure.id)
end
end
def service_button_text
if @procedure.service.present?
'Modifier'
elsif @administrateur.services.present?
'Choisir'
else
'Remplir'
end
end
end