Merge pull request #7571 from betagouv/usager/edit-siret-in-draft
feat: allows user to edit civility / siret from a dossier en brouillon
This commit is contained in:
commit
1c42d5f63c
14 changed files with 199 additions and 134 deletions
|
@ -32,7 +32,20 @@
|
|||
|
||||
.header-actions {
|
||||
margin-bottom: $default-spacer;
|
||||
text-align: right;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
column-gap: $default-spacer * 2;
|
||||
}
|
||||
}
|
||||
|
||||
.edit-identity-action {
|
||||
.dropdown-content {
|
||||
padding: $default-padding;
|
||||
min-width: 250px;
|
||||
}
|
||||
|
||||
.table {
|
||||
margin-bottom: $default-padding * 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Champs::SiretController < ApplicationController
|
|||
|
||||
begin
|
||||
etablissement = find_etablissement_with_siret
|
||||
rescue APIEntreprise::API::Error::RequestFailed, APIEntreprise::API::Error::BadGateway, APIEntreprise::API::Error::TimedOut, APIEntreprise::API::Error::ServiceUnavailable
|
||||
rescue APIEntreprise::API::Error::RequestFailed, APIEntreprise::API::Error::BadGateway, APIEntreprise::API::Error::TimedOut, APIEntreprise::API::Error::ServiceUnavailable, APIEntrepriseToken::TokenError
|
||||
# i18n-tasks-use t('errors.messages.siret_network_error')
|
||||
return siret_error(:network_error)
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ module Users
|
|||
sanitized_siret = siret_model.siret
|
||||
begin
|
||||
etablissement = APIEntrepriseService.create_etablissement(@dossier, sanitized_siret, current_user.id)
|
||||
rescue APIEntreprise::API::Error::RequestFailed, APIEntreprise::API::Error::BadGateway, APIEntreprise::API::Error::TimedOut, APIEntreprise::API::Error::ServiceUnavailable
|
||||
rescue APIEntreprise::API::Error::RequestFailed, APIEntreprise::API::Error::BadGateway, APIEntreprise::API::Error::TimedOut, APIEntreprise::API::Error::ServiceUnavailable, APIEntrepriseToken::TokenError
|
||||
return render_siret_error(t('errors.messages.siret_network_error'))
|
||||
end
|
||||
if etablissement.nil?
|
||||
|
|
|
@ -82,7 +82,10 @@ class APIEntreprise::API
|
|||
end
|
||||
|
||||
def self.call_with_siret(resource_name, siret_or_siren, procedure_id, user_id = nil)
|
||||
return if APIEntrepriseToken.new(token_for_procedure(procedure_id)).expired?
|
||||
if APIEntrepriseToken.new(token_for_procedure(procedure_id)).expired?
|
||||
raise APIEntrepriseToken::TokenError, I18n.t("api_entreprise.errors.token_expired")
|
||||
end
|
||||
|
||||
url = url(resource_name, siret_or_siren)
|
||||
params = params(siret_or_siren, procedure_id, user_id)
|
||||
|
||||
|
|
|
@ -13,3 +13,6 @@
|
|||
- elsif current_user.owns?(dossier)
|
||||
.header-actions
|
||||
= render partial: 'invites/dropdown', locals: { dossier: dossier }
|
||||
|
||||
- unless dossier.read_only?
|
||||
= render partial: 'users/dossiers/identity_dropdown', locals: { dossier: dossier }
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
%td.libelle SIRET :
|
||||
%td= etablissement.siret
|
||||
|
||||
- unless local_assigns[:short_identity]
|
||||
- if etablissement.siret != etablissement.entreprise.siret_siege_social
|
||||
%tr
|
||||
%td.libelle SIRET du siège social:
|
||||
|
@ -144,6 +145,7 @@
|
|||
%td.libelle Date de déclaration :
|
||||
%td= try_format_date(etablissement.association_date_declaration)
|
||||
|
||||
- unless local_assigns[:short_identity]
|
||||
%p
|
||||
= link_to "➡ Autres informations sur l’organisme sur « annuaire-entreprises.data.gouv.fr » (ex: fiche d’immatriculation RNCS)",
|
||||
annuaire_link(etablissement.siren),
|
||||
|
|
17
app/views/users/dossiers/_identity_dropdown.html.haml
Normal file
17
app/views/users/dossiers/_identity_dropdown.html.haml
Normal file
|
@ -0,0 +1,17 @@
|
|||
.dropdown.edit-identity-action{ data: { controller: 'menu-button', popover: 'true' } }
|
||||
%button.button.dropdown-button{ data: { menu_button_target: 'button' } }
|
||||
= t("views.shared.dossiers.demande.my_identity")
|
||||
|
||||
#edit-identity-content.dropdown-content.fade-in-down{ data: { menu_button_target: 'menu' } }
|
||||
- if dossier.procedure.for_individual
|
||||
= render partial: "shared/dossiers/identite_individual", locals: { individual: dossier.individual }
|
||||
|
||||
.center
|
||||
= link_to t('views.shared.dossiers.demande.edit_identity'), identite_dossier_path(dossier), class: 'button'
|
||||
|
||||
- elsif dossier.etablissement
|
||||
= render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement, short_identity: true, profile: "usager" }
|
||||
|
||||
.center
|
||||
= link_to t('views.shared.dossiers.demande.edit_siret'), siret_dossier_path(dossier), class: 'button'
|
||||
|
|
@ -2,3 +2,4 @@ en:
|
|||
api_entreprise:
|
||||
errors:
|
||||
missing_token: "the API Entreprise token cannot be blank"
|
||||
token_expired: "API Entreprise token has expired."
|
||||
|
|
|
@ -2,3 +2,4 @@ fr:
|
|||
api_entreprise:
|
||||
errors:
|
||||
missing_token: "le jeton API Entreprise ne peut être vide"
|
||||
token_expired: "Le jeton API Entreprise a expiré."
|
||||
|
|
|
@ -133,6 +133,7 @@ en:
|
|||
write_message_to_administration_placeholder: "Write your message to the administration here"
|
||||
demande:
|
||||
requester_identity: "Identity of the requester"
|
||||
my_identity: "My identity"
|
||||
form: "Form"
|
||||
edit_siret: "Edit SIRET"
|
||||
edit_identity: "Edit identity data"
|
||||
|
|
|
@ -128,6 +128,7 @@ fr:
|
|||
write_message_to_administration_placeholder: "Écrivez votre message à l’administration ici"
|
||||
demande:
|
||||
requester_identity: "Identité du demandeur"
|
||||
my_identity: "Mon identité"
|
||||
form: "Formulaire"
|
||||
edit_siret: "Modifier le SIRET"
|
||||
edit_identity: "Modifier l’identité"
|
||||
|
|
|
@ -271,7 +271,7 @@ describe Users::DossiersController, type: :controller do
|
|||
let(:api_etablissement_status) { 200 }
|
||||
let(:token_expired) { true }
|
||||
|
||||
it_behaves_like 'the request fails with an error', I18n.t('errors.messages.siret_unknown')
|
||||
it_behaves_like 'the request fails with an error', I18n.t('errors.messages.siret_network_error')
|
||||
end
|
||||
|
||||
context 'when all API informations available' do
|
||||
|
|
|
@ -267,7 +267,7 @@ describe APIEntreprise::API do
|
|||
end
|
||||
|
||||
it 'makes no call to api-entreprise' do
|
||||
subject
|
||||
expect { subject }.to raise_error(APIEntrepriseToken::TokenError)
|
||||
expect(WebMock).not_to have_requested(:get, /https:\/\/entreprise.api.gouv.fr\/v2\/entreprises\/#{siren}/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -52,4 +52,27 @@ describe 'dossiers/show/header.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "identity edit" do
|
||||
context "when the identity is individual" do
|
||||
let(:procedure) { create(:procedure, for_individual: true) }
|
||||
let(:dossier) { create(:dossier, :with_individual, state: "brouillon", procedure: procedure) }
|
||||
|
||||
it "display identity with an edit link" do
|
||||
expect(rendered).to have_text(/Nom\s+#{dossier.individual.nom}/)
|
||||
expect(rendered).to have_link("Modifier l’identité")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the identity is an enterprise" do
|
||||
let(:procedure) { create(:procedure, for_individual: false) }
|
||||
let(:dossier) { create(:dossier, :with_entreprise, state: "brouillon", procedure: procedure) }
|
||||
|
||||
it "display short identity with an edit siret link" do
|
||||
expect(rendered).to have_text(/Dénomination :\s+#{dossier.etablissement.entreprise_raison_sociale}/)
|
||||
expect(rendered).not_to have_text("Numéro de TVA")
|
||||
expect(rendered).to have_link("Modifier le SIRET")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue