Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ux(fix): make custom errors modal title dynamic #2464

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/concerns/turbo_stream_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/views/common/_custom_errors_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<div class="text-center mb-3">
<%= image_tag "illustrations/error-line.svg", alt: "Illustration d'un message d'erreur", class: "mb-3" %>
</div>
<h4 class="text-center"><b>Impossible d'inviter l'usager</b></h4>
<% if local_assigns[:title] %>
<h4 class="text-center"><b><%= local_assigns[:title] %></b></h4>
<% else %>
<h4 class="text-center"><b>Oups! Une erreur est survenue 👷‍</b></h4>
<% end %>
<div class="p-3">
<% errors.each_with_index do |error, index| %>
<% if error.is_a?(TemplatedErrorPresenter) %>
Expand Down