From 4771c45bce3de89e08dba42f1786e931c8922377 Mon Sep 17 00:00:00 2001 From: mfo Date: Tue, 25 Jun 2024 14:36:41 +0200 Subject: [PATCH] clean(InvitationWithTypoComponent): simplier interface --- app/components/procedure/invitation_with_typo_component.rb | 3 +-- .../invitation_with_typo_component.html.haml | 4 ++-- app/views/administrateurs/experts_procedures/index.html.haml | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/components/procedure/invitation_with_typo_component.rb b/app/components/procedure/invitation_with_typo_component.rb index bec642cfa..53062a975 100644 --- a/app/components/procedure/invitation_with_typo_component.rb +++ b/app/components/procedure/invitation_with_typo_component.rb @@ -1,8 +1,7 @@ class Procedure::InvitationWithTypoComponent < ApplicationComponent - def initialize(maybe_typo:, url:, params:, title:) + def initialize(maybe_typo:, url:, title:) @maybe_typo = maybe_typo @url = url - @params = params @title = title end diff --git a/app/components/procedure/invitation_with_typo_component/invitation_with_typo_component.html.haml b/app/components/procedure/invitation_with_typo_component/invitation_with_typo_component.html.haml index 12fdcc1dd..c114f78da 100644 --- a/app/components/procedure/invitation_with_typo_component/invitation_with_typo_component.html.haml +++ b/app/components/procedure/invitation_with_typo_component/invitation_with_typo_component.html.haml @@ -5,6 +5,6 @@ - maybe_typos.each do |(actual_email, suggested_email)| %li = "Je confirme " - = button_to "#{actual_email}", @url, method: :POST, params: @params.call(actual_email), class: 'fr-btn fr-btn--tertiary fr-btn--sm', form: {class: 'inline'} + = button_to "#{actual_email}", @url, method: :POST, params: { maybe_typo: actual_email }, class: 'fr-btn fr-btn--tertiary fr-btn--sm', form: {class: 'inline'} = " ou " - = button_to "#{suggested_email}", @url, method: :POST, params: @params.call(suggested_email), class: 'fr-btn fr-btn--tertiary fr-btn--sm', form: {class: 'inline'} + = button_to "#{suggested_email}", @url, method: :POST, params: { maybe_typo: suggested_email }, class: 'fr-btn fr-btn--tertiary fr-btn--sm', form: {class: 'inline'} diff --git a/app/views/administrateurs/experts_procedures/index.html.haml b/app/views/administrateurs/experts_procedures/index.html.haml index daad54134..2ca4c4af4 100644 --- a/app/views/administrateurs/experts_procedures/index.html.haml +++ b/app/views/administrateurs/experts_procedures/index.html.haml @@ -58,7 +58,7 @@ - if @procedure.experts_require_administrateur_invitation? .card - = render Procedure::InvitationWithTypoComponent.new(maybe_typo: @maybe_typo, url: admin_procedure_experts_path(@procedure), params: ->(email) { { maybe_typo: email } }, title: "Avant d'ajouter l'email à la liste d'expert prédéfinie, veuillez confirmer" ) + = render Procedure::InvitationWithTypoComponent.new(maybe_typo: @maybe_typo, url: admin_procedure_experts_path(@procedure), title: "Avant d'ajouter l'email à la liste d'expert prédéfinie, veuillez confirmer" ) = form_for :experts_procedure, url: admin_procedure_experts_path(@procedure), html: { class: 'form' } do |f|