Skip to content

Commit

Permalink
feat: clean company address on declaration to avoid double informatio…
Browse files Browse the repository at this point in the history
…ns (#1827)
  • Loading branch information
jonat75 authored Nov 13, 2023
1 parent 7ce2634 commit 3147d4e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { type CompanyDTO } from "@common/core-domain/dtos/CompanyDTO";
import { type Entreprise } from "@common/core-domain/dtos/DeclarationDTO";
import { ClientOnly } from "@components/utils/ClientOnly";
import { FormLayout, RecapCardCompany } from "@design-system";
import { useDeclarationFormManager } from "@services/apiClient/useDeclarationFormManager";
Expand All @@ -12,8 +13,15 @@ export const InformationEntreprise = () => {

if (!entrepriseDéclarante) return null;

const cleanAddress = (entrepriseDéclarante: Entreprise) => {
let address = entrepriseDéclarante.adresse;
if (entrepriseDéclarante.commune) address = address.replace(entrepriseDéclarante.commune, "");
if (entrepriseDéclarante.codePostal) address = address.replace(entrepriseDéclarante.codePostal, "");
return address;
};

const company: CompanyDTO = {
address: entrepriseDéclarante?.adresse,
address: cleanAddress(entrepriseDéclarante),
city: entrepriseDéclarante?.commune || "",
countryIsoCode: entrepriseDéclarante?.codePays,
nafCode: entrepriseDéclarante.codeNaf,
Expand Down

0 comments on commit 3147d4e

Please sign in to comment.