From 87982e4f40c8d7683cdf1629c6fb50ff6fbab44d Mon Sep 17 00:00:00 2001 From: jonat75 Date: Tue, 6 Feb 2024 18:11:11 +0100 Subject: [PATCH] fix: workforce on index consultation search (#2107) --- .../common/core-domain/domain/declaration/Company.ts | 11 ++++++++--- .../core-domain/mappers/declarationSearchResultMap.ts | 4 ++-- .../design-system/base/client/TileCompanyIndex.tsx | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/app/src/common/core-domain/domain/declaration/Company.ts b/packages/app/src/common/core-domain/domain/declaration/Company.ts index 7dc245f9c..eca5b7f39 100644 --- a/packages/app/src/common/core-domain/domain/declaration/Company.ts +++ b/packages/app/src/common/core-domain/domain/declaration/Company.ts @@ -22,9 +22,9 @@ export interface CompanyProps { range?: CompanyWorkforceRange; region?: Region; siren: Siren; - /** Total effectif */ total?: PositiveNumber; ues?: UES; + workforce?: { range: CompanyWorkforceRange; total: PositiveNumber }; } export class Company extends JsonEntity { @@ -122,8 +122,13 @@ export class Company extends JsonEntity { props.ues = UES.fromJson(json.ues); } - if (typeof json.total === "number") { - props.total = new PositiveNumber(json.total); + if (json.workforce) { + props.total = new PositiveNumber(json.workforce.total); + props.range = new CompanyWorkforceRange(json.workforce.range); + props.workforce = { + range: new CompanyWorkforceRange(json.workforce.range), + total: new PositiveNumber(json.workforce.total), + }; } if (json.range) { diff --git a/packages/app/src/common/core-domain/mappers/declarationSearchResultMap.ts b/packages/app/src/common/core-domain/mappers/declarationSearchResultMap.ts index 1de6190e9..fe9147bf3 100644 --- a/packages/app/src/common/core-domain/mappers/declarationSearchResultMap.ts +++ b/packages/app/src/common/core-domain/mappers/declarationSearchResultMap.ts @@ -64,8 +64,8 @@ export const declarationSearchResultMap: Mapper< } : void 0, workforce: { - range: value.entreprise.effectif?.tranche, - total: value.entreprise.effectif?.total, + range: value.entreprise.effectif?.tranche ?? "50:250", + total: value.entreprise.effectif?.total ?? 0, }, nafCode: value.entreprise.code_naf, }, diff --git a/packages/app/src/design-system/base/client/TileCompanyIndex.tsx b/packages/app/src/design-system/base/client/TileCompanyIndex.tsx index d90e4b664..de996beff 100644 --- a/packages/app/src/design-system/base/client/TileCompanyIndex.tsx +++ b/packages/app/src/design-system/base/client/TileCompanyIndex.tsx @@ -80,7 +80,7 @@ export const TileCompanyIndex = (dto: SearchDeclarationResultDTO) => {
- {mapRange(workforce?.range)} + {workforce?.total} {` Salariés${ workforce?.range === CompanyWorkforceRange.Enum.FROM_1000_TO_MORE ? " ou plus" : "" }`} @@ -177,7 +177,7 @@ export const TileCompanyIndex = (dto: SearchDeclarationResultDTO) => {
  • Écart taux d'augmentation :{" "} - {company[row.year].workforce?.range === CompanyWorkforceRange.Enum.FROM_251_TO_999 ? ( + {company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_251_TO_999 ? ( <> {row.notComputableReasonSalaryRaisesAndPromotions && ( @@ -203,7 +203,7 @@ export const TileCompanyIndex = (dto: SearchDeclarationResultDTO) => { )}
  • - {company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_251_TO_999 && ( + {company[row.year].workforce?.range !== CompanyWorkforceRange.Enum.FROM_50_TO_250 && (
  • Écart taux promotion : {row.notComputableReasonPromotions && (