simply deal with multiple agent_connect_information by taking the last used

This commit is contained in:
simon lehericey 2024-03-19 15:24:53 +01:00
parent ca17524559
commit df0298ac42
3 changed files with 7 additions and 3 deletions

View file

@ -56,7 +56,7 @@ class RecoveriesController < ApplicationController
private private
def nature_params = params[:nature] def nature_params = params[:nature]
def siret = current_instructeur.agent_connect_information.siret def siret = current_instructeur.last_agent_connect_information.siret
def previous_email = params[:previous_email] def previous_email = params[:previous_email]
def procedure_ids = params[:procedure_ids].map(&:to_i) def procedure_ids = params[:procedure_ids].map(&:to_i)
@ -70,7 +70,7 @@ class RecoveriesController < ApplicationController
end end
def ensure_agent_connect_is_used def ensure_agent_connect_is_used
if current_instructeur&.agent_connect_information.nil? if current_instructeur&.last_agent_connect_information.nil?
redirect_to support_recovery_path(error: :must_use_agent_connect) redirect_to support_recovery_path(error: :must_use_agent_connect)
end end
end end

View file

@ -298,6 +298,10 @@ class Instructeur < ApplicationRecord
.update_all(claimant_id: id) .update_all(claimant_id: id)
end end
def last_agent_connect_information
agent_connect_information.order(updated_at: :desc).first
end
private private
def annotations_hash(demande, annotations_privees, avis, messagerie) def annotations_hash(demande, annotations_privees, avis, messagerie)

View file

@ -5,7 +5,7 @@
%h2 Identification du propriétaire des dossiers %h2 Identification du propriétaire des dossiers
%p Votre organisation est « #{@structure_name} » identifiée par le SIRET #{current_instructeur.agent_connect_information.siret} %p Votre organisation est « #{@structure_name} » identifiée par le SIRET #{current_instructeur.last_agent_connect_information.siret}
= form_with do |f| = form_with do |f|
.fr-input-group .fr-input-group
%label.fr-label{ for: "email" } %label.fr-label{ for: "email" }