diff --git a/packages/app/src/api/core-domain/useCases/SaveDeclaration.ts b/packages/app/src/api/core-domain/useCases/SaveDeclaration.ts
index ed64bb4d9..818574d83 100644
--- a/packages/app/src/api/core-domain/useCases/SaveDeclaration.ts
+++ b/packages/app/src/api/core-domain/useCases/SaveDeclaration.ts
@@ -58,15 +58,24 @@ export class SaveDeclaration implements UseCase {
phone: dto.declarant?.téléphone,
},
company: {
- address: company.address,
- city: company.city,
- countryCode: company.countryCode?.getValue(),
- county: company.county?.getValue(),
- nafCode: company.nafCode?.getValue(),
- name: company.name,
- postalCode: company.postalCode?.getValue(),
- region: company.region?.getValue(),
- siren: company.siren?.getValue(),
+ address: override ? dto.entreprise?.entrepriseDéclarante?.adresse : company.address,
+ city: override ? dto.entreprise?.entrepriseDéclarante?.commune : company.city,
+ countryCode: override ? dto.entreprise?.entrepriseDéclarante?.codePays : company.countryCode?.getValue(),
+ county: override ? dto.entreprise?.entrepriseDéclarante?.département : company.county?.getValue(),
+ nafCode:
+ override && dto.entreprise?.entrepriseDéclarante?.codeNaf
+ ? dto.entreprise?.entrepriseDéclarante?.codeNaf
+ : company.nafCode?.getValue(),
+ name:
+ override && dto?.entreprise?.entrepriseDéclarante?.raisonSociale
+ ? dto.entreprise.entrepriseDéclarante.raisonSociale
+ : company.name,
+ postalCode: override ? dto.entreprise?.entrepriseDéclarante?.codePostal : company.postalCode?.getValue(),
+ region: override ? dto.entreprise?.entrepriseDéclarante?.région : company.region?.getValue(),
+ siren:
+ override && dto.entreprise?.entrepriseDéclarante?.siren
+ ? dto.entreprise?.entrepriseDéclarante?.siren
+ : company.siren?.getValue(),
range: dto.entreprise?.tranche,
total:
dto["periode-reference"]?.périodeSuffisante === "oui" ? dto["periode-reference"].effectifTotal : undefined,
diff --git a/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/RecapDeclaration.tsx b/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/RecapDeclaration.tsx
index 946a3a6e7..df887abe8 100644
--- a/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/RecapDeclaration.tsx
+++ b/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/RecapDeclaration.tsx
@@ -10,10 +10,10 @@ import { type CompanyDTO } from "@common/core-domain/dtos/CompanyDTO";
import { type DeclarationDTO } from "@common/core-domain/dtos/DeclarationDTO";
import { formatIsoToFr } from "@common/utils/date";
import { BigNote, Box, RecapCard, RecapCardCompany } from "@design-system";
-import { useDeclarationFormManager } from "@services/apiClient/useDeclarationFormManager";
+import { useRouter } from "next/navigation";
-import { saveDeclaration } from "../../actions";
import { funnelStaticConfig } from "../../declarationFunnelConfiguration";
+import { updateCompanyInfos } from "./actions";
import { RecapCardIndicator } from "./RecapCardIndicator";
import { RecapCardPublication } from "./RecapCardPublication";
@@ -21,8 +21,7 @@ type Props = { displayTitle?: string; déclaration: DeclarationDTO; edit?: boole
export const RecapDeclaration = ({ déclaration, edit, displayTitle }: Props) => {
const entreprise = déclaration.entreprise?.entrepriseDéclarante;
-
- const { saveFormData } = useDeclarationFormManager();
+ const router = useRouter();
const company: CompanyDTO = {
name: entreprise?.raisonSociale || "",
address: entreprise?.adresse,
@@ -62,8 +61,17 @@ export const RecapDeclaration = ({ déclaration, edit, displayTitle }: Props) =>
},
},
};
- await saveDeclaration(newFormData);
- //saveFormData(newFormData);
+ const isEditingSiren = data.siren != déclaration.entreprise?.entrepriseDéclarante?.siren;
+
+ await updateCompanyInfos(
+ newFormData,
+ isEditingSiren ? déclaration.entreprise?.entrepriseDéclarante?.siren : void 0,
+ );
+
+ if (isEditingSiren) {
+ router.push(`/index-egapro/declaration/${data.siren}/${déclaration.commencer?.annéeIndicateurs}`);
+ }
+ router.refresh();
};
return (
diff --git a/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/actions.ts b/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/actions.ts
new file mode 100644
index 000000000..1dd42bbc5
--- /dev/null
+++ b/packages/app/src/app/(default)/index-egapro/declaration/[siren]/[year]/actions.ts
@@ -0,0 +1,46 @@
+"use server";
+import { entrepriseService } from "@api/core-domain/infra/services";
+import { declarationRepo } from "@api/core-domain/repo";
+import { SaveDeclaration } from "@api/core-domain/useCases/SaveDeclaration";
+import { assertServerSession } from "@api/utils/auth";
+import { DeclarationSpecificationError } from "@common/core-domain/domain/specification/DeclarationSpecification";
+import { Siren } from "@common/core-domain/domain/valueObjects/Siren";
+import { type CreateDeclarationDTO } from "@common/core-domain/dtos/DeclarationDTO";
+import { ValidationError } from "@common/shared-domain";
+import { PositiveNumber } from "@common/shared-domain/domain/valueObjects";
+import { type ServerActionResponse } from "@common/utils/next";
+
+export async function updateCompanyInfos(
+ declaration: CreateDeclarationDTO,
+ oldSiren: string | undefined,
+): Promise
- Pour terminer la procédure, cliquez sur “Valider et transmettre les résultats” ci-dessous. Vous recevrez un
+ Pour terminer la procédure, cliquez sur “Valider et transmettre les résultats” ci-dessous. Vous aprecevrez un
accusé de réception.