2022-07-20 18:53:40 +02:00
|
|
|
class Procedure::Card::EmailsComponent < ApplicationComponent
|
2022-12-08 16:07:06 +01:00
|
|
|
CUSTOMIZABLE_COUNT = 5
|
|
|
|
|
2022-07-20 18:53:40 +02:00
|
|
|
def initialize(procedure:)
|
|
|
|
@procedure = procedure
|
|
|
|
end
|
2022-11-02 10:03:10 +01:00
|
|
|
|
2022-12-08 16:07:06 +01:00
|
|
|
def customized_progress
|
|
|
|
"#{customized_count} / #{CUSTOMIZABLE_COUNT}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def fully_customized?
|
|
|
|
customized_count == CUSTOMIZABLE_COUNT
|
|
|
|
end
|
|
|
|
|
2022-11-02 10:03:10 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def error_messages
|
|
|
|
[
|
|
|
|
@procedure.errors.messages_for(:initiated_mail),
|
|
|
|
@procedure.errors.messages_for(:received_mail),
|
|
|
|
@procedure.errors.messages_for(:closed_mail),
|
|
|
|
@procedure.errors.messages_for(:refused_mail),
|
|
|
|
@procedure.errors.messages_for(:without_continuation_mail)
|
|
|
|
].flatten.to_sentence
|
|
|
|
end
|
2022-12-08 16:07:06 +01:00
|
|
|
|
|
|
|
def customized_count
|
|
|
|
[
|
|
|
|
@procedure.initiated_mail,
|
|
|
|
@procedure.received_mail,
|
|
|
|
@procedure.closed_mail,
|
|
|
|
@procedure.refused_mail,
|
|
|
|
@procedure.without_continuation_mail
|
|
|
|
].map { |mail| mail&.updated_at }.compact.size
|
|
|
|
end
|
2022-07-20 18:53:40 +02:00
|
|
|
end
|