feat(sva): instructeurs dashboard sva/svr colonnes with multiple use cases

This commit is contained in:
Colin Darie 2023-06-07 19:11:37 +02:00
parent e43eea7fcf
commit f1504e9724
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
11 changed files with 83 additions and 16 deletions

View file

@ -0,0 +1,46 @@
# frozen_string_literal: true
class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
attr_reader :object
def initialize(projection_or_dossier:, decision:)
@object = projection_or_dossier
@decision = decision.to_sym
end
def render?
[:en_construction, :en_instruction].include? object.state.to_sym
end
def without_date?
object.sva_svr_decision_on.nil?
end
def classes
class_names(
'fr-badge fr-badge--sm': true,
'fr-badge--warning': soon?,
'fr-badge--info': !soon?
)
end
def soon?
object.sva_svr_decision_on < 7.days.from_now.to_date
end
def pending_correction?
object.pending_correction?
end
def days_count
(object.sva_svr_decision_on - Date.current).to_i
end
def sva?
@decision == :sva
end
def svr?
@decision == :svr
end
end

View file

@ -0,0 +1,10 @@
---
en:
no_sva: Submitted before SVA
no_svr: Submitted before SVR
in_days:
zero: Today
one: Tomorrow
other: in %{count} days
remaining_days_after_correction:
other: "%{count} d. after correction"

View file

@ -0,0 +1,10 @@
---
fr:
no_sva: Déposé avant SVA
no_svr: Déposé avant SVR
in_days:
zero: Aujourdhui
one: Demain
other: dans %{count} jours
remaining_days_after_correction:
other: "%{count} j. après correction"

View file

@ -0,0 +1,10 @@
- if without_date?
%span.fr-badge.fr-badge--sm
= t(sva? ? '.no_sva' : '.no_svr')
- else
%span{ class: classes }
- if pending_correction?
= t('.remaining_days_after_correction', count: days_count)
- else
= t('.in_days', count: days_count)