2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-20 18:53:40 +02:00
|
|
|
class Procedure::Card::EmailsComponent < ApplicationComponent
|
2023-11-08 14:41:22 +01:00
|
|
|
CUSTOMIZABLE_COUNT = 6
|
2022-12-08 16:07:06 +01:00
|
|
|
|
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,
|
2023-11-08 14:41:22 +01:00
|
|
|
@procedure.without_continuation_mail,
|
|
|
|
@procedure.re_instructed_mail
|
2022-12-08 16:07:06 +01:00
|
|
|
].map { |mail| mail&.updated_at }.compact.size
|
|
|
|
end
|
2022-07-20 18:53:40 +02:00
|
|
|
end
|