diff --git a/app/components/procedure/card/emails_component.rb b/app/components/procedure/card/emails_component.rb index e773ceb66..60d5dd31b 100644 --- a/app/components/procedure/card/emails_component.rb +++ b/app/components/procedure/card/emails_component.rb @@ -1,8 +1,18 @@ class Procedure::Card::EmailsComponent < ApplicationComponent + CUSTOMIZABLE_COUNT = 5 + def initialize(procedure:) @procedure = procedure end + def customized_progress + "#{customized_count} / #{CUSTOMIZABLE_COUNT}" + end + + def fully_customized? + customized_count == CUSTOMIZABLE_COUNT + end + private def error_messages @@ -14,4 +24,14 @@ class Procedure::Card::EmailsComponent < ApplicationComponent @procedure.errors.messages_for(:without_continuation_mail) ].flatten.to_sentence end + + 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 end diff --git a/app/components/procedure/card/emails_component/emails_component.html.haml b/app/components/procedure/card/emails_component/emails_component.html.haml index a81399470..5918224ba 100644 --- a/app/components/procedure/card/emails_component/emails_component.html.haml +++ b/app/components/procedure/card/emails_component/emails_component.html.haml @@ -5,10 +5,16 @@ - if error_messages.present? %span.icon.refuse %p.fr-tile-status-error À modifier + - elsif fully_customized? + %span.icon.accept + %p.fr-tile-status-todo Validé - else %span.icon.clock %p.fr-tile-status-todo À configurer %div - %h3.fr-h6.fr-mt-10v= t('.title') + .line-count.fr-my-1w + %p.fr-tag= customized_progress + + %h3.fr-h6= t('.title') %p.fr-tile-subtitle Notifications automatiques %p.fr-btn.fr-btn--tertiary= t('views.shared.actions.edit')