From 616f7b4fd8c2d2ac88d556cdace6cda523292fdd Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sun, 23 Aug 2026 17:48:04 +0300 Subject: [PATCH] adjsut resubmit --- app/controllers/start_form_resubmit_controller.rb | 10 ++++++---- app/views/start_form/email_verification.html.erb | 6 +++++- app/views/start_form/show.html.erb | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/controllers/start_form_resubmit_controller.rb b/app/controllers/start_form_resubmit_controller.rb index 52d060b4..5631b38d 100644 --- a/app/controllers/start_form_resubmit_controller.rb +++ b/app/controllers/start_form_resubmit_controller.rb @@ -86,10 +86,12 @@ class StartFormResubmitController < ApplicationController rescue Submitters::StartForm::NotSaved render 'start_form/show', status: :unprocessable_content rescue Submitters::UnableToSendCode, Submitters::InvalidOtp => e - redirect_to start_form_path(@template.slug, params: submitter_params.merge(email_verification: true)), - alert: e.message + flash.now[:alert] = e.message + + render 'start_form/email_verification' rescue RateLimit::LimitApproached - redirect_to start_form_path(@template.slug, params: submitter_params.merge(email_verification: true)), - alert: I18n.t(:too_many_attempts) + flash.now[:alert] = I18n.t(:too_many_attempts) + + render 'start_form/email_verification' end end diff --git a/app/views/start_form/email_verification.html.erb b/app/views/start_form/email_verification.html.erb index a0e3cce9..e03e0f42 100644 --- a/app/views/start_form/email_verification.html.erb +++ b/app/views/start_form/email_verification.html.erb @@ -49,6 +49,10 @@ <%= f.button button_title(title: t('submit')), class: 'base-button' %> <% end %> - <%= button_to t(:re_send_email), start_form_email_2fa_send_index_path, params: { slug: @template.slug, resend: true, submitter: { name: params[:name] || params.dig(:submitter, :name), email: params[:email] || params.dig(:submitter, :email), phone: params[:phone] || params.dig(:submitter, :phone) } }.compact, method: :post, id: 'resend_code', class: 'hidden' %> + <% if @resubmit_submitter %> + <%= button_to t(:re_send_email), resubmit_form_path, params: { resubmit: @resubmit_submitter.slug }, method: :put, id: 'resend_code', class: 'hidden' %> + <% else %> + <%= button_to t(:re_send_email), start_form_email_2fa_send_index_path, params: { slug: @template.slug, resend: true, submitter: { name: params[:name] || params.dig(:submitter, :name), email: params[:email] || params.dig(:submitter, :email), phone: params[:phone] || params.dig(:submitter, :phone) } }.compact, method: :post, id: 'resend_code', class: 'hidden' %> + <% end %> diff --git a/app/views/start_form/show.html.erb b/app/views/start_form/show.html.erb index 7cc1c18e..dbfc65ca 100644 --- a/app/views/start_form/show.html.erb +++ b/app/views/start_form/show.html.erb @@ -28,7 +28,8 @@ <% if !@template.archived_at? && !@template.account.archived_at? %> - <%= form_for @submitter, url: start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put, html: { class: 'space-y-4' } do |f| %> + <%= form_for @submitter, url: @resubmit_submitter ? resubmit_form_path : start_form_path(@template.slug), data: { turbo_frame: :_top }, method: :put, html: { class: 'space-y-4' } do |f| %> + <%= hidden_field_tag :resubmit, @resubmit_submitter.slug if @resubmit_submitter %> <% if @error_message %>
<%= svg_icon('info_circle', class: 'stroke-current shrink-0 h-6 w-6 mt-1') %>