Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
GaelFerrand committed May 31, 2024
1 parent e991afe commit adf3263
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions back/src/forms/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ const getTransportersData = (bsdd: Bsdd) => ({
transporter3CompanyMail: bsdd.transporter3CompanyMail
});

const getIntermediariesData = (bsdd: ReturnType<typeof formToBsdd>) => ({
intermediary1CompanyName: bsdd.intermediaries?.[0]?.name ?? null,
intermediary1CompanySiret: bsdd.intermediaries?.[0]?.siret ?? null,
intermediary2CompanyName: bsdd.intermediaries?.[1]?.name ?? null,
intermediary2CompanySiret: bsdd.intermediaries?.[1]?.siret ?? null,
intermediary3CompanyName: bsdd.intermediaries?.[2]?.name ?? null,
intermediary3CompanySiret: bsdd.intermediaries?.[2]?.siret ?? null
});

export function getRegistryFields(
form: FormForElastic
): Pick<BsdElastic, RegistryFields> {
Expand Down Expand Up @@ -439,15 +448,6 @@ export function toAllWaste(

const { __typename, ...genericWaste } = toGenericWaste(bsdd);

const intermediariesInfo: Record<string, string | null> = {
intermediary1CompanyName: bsdd.intermediaries?.[0]?.name ?? null,
intermediary1CompanySiret: bsdd.intermediaries?.[0]?.siret ?? null,
intermediary2CompanyName: bsdd.intermediaries?.[1]?.name ?? null,
intermediary2CompanySiret: bsdd.intermediaries?.[1]?.siret ?? null,
intermediary3CompanyName: bsdd.intermediaries?.[2]?.name ?? null,
intermediary3CompanySiret: bsdd.intermediaries?.[2]?.siret ?? null
};

return {
// Make sure all possible keys are in the exported sheet so that no column is missing
...emptyAllWaste,
Expand Down Expand Up @@ -481,6 +481,6 @@ export function toAllWaste(
destinationCompanyMail: bsdd.destinationCompanyMail,
...getOperationData(bsdd),
...getFinalOperationsData(bsdd),
...intermediariesInfo
...getIntermediariesData(bsdd)
};
}

0 comments on commit adf3263

Please sign in to comment.