diff --git a/app/controllers/concerns/turbo_stream_concern.rb b/app/controllers/concerns/turbo_stream_concern.rb index 8d1a8a0c8..b6aaa0110 100644 --- a/app/controllers/concerns/turbo_stream_concern.rb +++ b/app/controllers/concerns/turbo_stream_concern.rb @@ -37,8 +37,8 @@ def turbo_stream_display_error_modal(errors) turbo_stream_display_modal(partial: "common/error_modal", locals: { errors: }, status: :unprocessable_entity) end - def turbo_stream_display_custom_error_modal(errors) - turbo_stream_display_modal(partial: "common/custom_errors_modal", locals: { errors: }, + def turbo_stream_display_custom_error_modal(errors:, title:) + turbo_stream_display_modal(partial: "common/custom_errors_modal", locals: { errors:, title: }, status: :unprocessable_entity) end end diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 47772dc6d..8484ea5fe 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -24,10 +24,13 @@ def create # rubocop:disable Metrics/AbcSize # window.Turbo.renderStreamMessage. # Discussion ici : https://github.com/gip-inclusion/rdv-insertion/pull/2361#discussion_r1784538358 turbo_stream_html: turbo_stream.replace("remote_modal", partial: "common/custom_errors_modal", - locals: { errors: invite_user.errors }) + locals: { errors: invite_user.errors, + title: "Impossible d'inviter l'usager" }) }, status: :unprocessable_entity end - format.turbo_stream { turbo_stream_display_custom_error_modal(invite_user.errors) } + format.turbo_stream do + turbo_stream_display_custom_error_modal(errors: invite_user.errors, title: "Impossible d'inviter l'usager") + end end end end diff --git a/app/views/common/_custom_errors_modal.html.erb b/app/views/common/_custom_errors_modal.html.erb index 37b79bcbb..178b52490 100644 --- a/app/views/common/_custom_errors_modal.html.erb +++ b/app/views/common/_custom_errors_modal.html.erb @@ -3,7 +3,11 @@
<%= image_tag "illustrations/error-line.svg", alt: "Illustration d'un message d'erreur", class: "mb-3" %>
-

Impossible d'inviter l'usager

+ <% if local_assigns[:title] %> +

<%= local_assigns[:title] %>

+ <% else %> +

Oups! Une erreur est survenue 👷‍

+ <% end %>
<% errors.each_with_index do |error, index| %> <% if error.is_a?(TemplatedErrorPresenter) %>