Skip to content

Commit

Permalink
fix rapport colum name and value / auto select all department in modal
Browse files Browse the repository at this point in the history
  • Loading branch information
achorein committed Jan 29, 2025
1 parent 1d8b674 commit 53670a4
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";

import { HiOutlineLightningBolt } from "react-icons/hi";

import { CohortDto, formatDepartement, Phase1Routes, region2department, RegionsMetropoleAndCorse, translate } from "snu-lib";
import { CohortDto, formatDepartement, Phase1Routes, region2department, RegionsMetropole, translate } from "snu-lib";
import { Button, CollapsableSelectSwitcher, Modal, SectionSwitcher } from "@snu/ds/admin";
import { useSetState } from "react-use";
import { useMutation, useQueryClient } from "@tanstack/react-query";
Expand All @@ -22,8 +22,8 @@ export default function AffectationCLESimulationMetropoleModal({ session, onClos
departements: Record<string, string[]>;
etranger: boolean;
}>({
departements: RegionsMetropoleAndCorse.reduce((acc, region) => {
acc[region] = region2department[region].filter((departement) => !session.eligibility?.zones || session.eligibility.zones.includes(departement));
departements: RegionsMetropole.reduce((acc, region) => {
acc[region] = region2department[region];
return acc;
}, {}),
etranger: true,
Expand Down Expand Up @@ -70,7 +70,7 @@ export default function AffectationCLESimulationMetropoleModal({ session, onClos
<div className="flex flex-col w-full gap-2.5">
<h2 className="text-lg leading-7 font-bold m-0">Découpage territorial</h2>
<div className="flex flex-col w-full">
{RegionsMetropoleAndCorse.map((region) => (
{RegionsMetropole.map((region) => (
<CollapsableSelectSwitcher
key={region}
title={region}
Expand Down
2 changes: 2 additions & 0 deletions apiv2/src/admin/AdminJob.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { referentMongoProviders } from "./infra/iam/provider/ReferentMongo.provi
import { ContactGateway } from "./infra/iam/Contact.gateway";
import { ContactProducer } from "@notification/infra/email/Contact.producer";
import { ValiderAffectationCLE } from "./core/sejours/phase1/affectation/ValiderAffectationCLE";
import { AdminTaskAffectationSelectorService } from "./infra/task/AdminTaskAffectationSelector.service";

@Module({
imports: [
Expand Down Expand Up @@ -107,6 +108,7 @@ import { ValiderAffectationCLE } from "./core/sejours/phase1/affectation/Valider
ValiderAffectationCLE,
...referentielUseCaseProvider,
...referentielServiceProvider,
AdminTaskAffectationSelectorService,
AdminTaskImportReferentielSelectorService,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ import { EtablissementModel } from "../../cle/etablissement/Etablissement.model"
import { ReferentModel } from "@admin/core/iam/Referent.model";

type JeuneRapport = {
"_id du volontaire": string;
"id du volontaire": string;
Cohort: string;
Statut: string;
"Statut de phase 1": string;
"_id du bus": string;
"id du bus": string;
"Nom du bus": string;
"_id du centre": string;
"id du centre": string;
"Nom du centre": string;
"Département du centre": string;
"Région du centre": string;
"_id classe": string;
"id classe": string;
"Nom de la classe": string;
"Nom de l'établissement": string;
"Département de l'établissement": string;
"Région de l'établissement": string;
dev_sessionPhase1Id: string;
dev_cohesionCenterId: string;
dev_pointDeRassemblementId: string;
dev_ligneId: string;
dev_status: string;
dev_statusPhase1: string;
sejourId: string;
classeCenterId: string;
pointDeRassemblementId: string;
jeuneLigneId: string;
};

type CentreRapport = {
_id: string;
id: string;
"Nom du centre": string;
"Département du centre": string;
"Région du centre": string;
Expand All @@ -47,9 +45,9 @@ type CentreRapport = {
};

type LigneBusRapport = {
_id: string;
id: string;
"Nom du bus": string;
"_id du centre": string;
"id du centre": string;
"Nom du centre": string;
"Département du centre": string;
"Région du centre": string;
Expand All @@ -62,13 +60,13 @@ type LigneBusRapport = {
};

type ErreurRapport = {
"_id classe": string;
"id classe": string;
"Nom de la classe": string;
"Nom de l'établissement": string;
"Département de l'établissement": string;
"Région de l'établissement": string;
"_id du centre": string;
"_id du bus": string;
"id du centre": string;
"id du bus": string;
Erreur: string;
"Nombre de volontaires": number;
"Capacité du bus ou de la session"?: number;
Expand All @@ -90,7 +88,7 @@ export const RAPPORT_SHEETS = {
VOLONTAIRES: "Volontaires",
CENTRES: "Centres",
BUS: "Bus",
ERREURS: "Bugs",
ERREURS: "Erreurs",
};

@Injectable()
Expand All @@ -107,7 +105,7 @@ export class SimulationAffectationCLEService {
placeOccupees: number;
placeRestantes: number;
}[],
centreList: {
sejourList: {
sejour: SejourModel;
placeOccupees: number;
placeRestantes: number;
Expand All @@ -129,7 +127,7 @@ export class SimulationAffectationCLEService {
const ligneBus = ligneDeBusList.find(
(ligneBus) => ligneBus.ligneDeBus.id === jeune.ligneDeBusId,
)!.ligneDeBus;
const sejour = centreList.find((centre) => centre.sejour.id === jeune.sejourId)!.sejour;
const sejour = sejourList.find((centre) => centre.sejour.id === jeune.sejourId)?.sejour;
const classe = classeList.find((classe) => classe.id === jeune.classeId)!;
const etablissement = etablissementList.find(
(etablissement) => etablissement.id === classe.etablissementId,
Expand All @@ -138,56 +136,55 @@ export class SimulationAffectationCLEService {
const referentClasse = referentsList.find((referent) => classe.referentClasseIds.includes(referent.id));

return {
"_id du volontaire": jeune.id,
"id du volontaire": jeune.id,
Nom: jeune.nom,
Prenom: jeune.prenom,
Email: jeune.email,
Cohort: jeune.sessionNom!,
Statut: jeune.statut,
"Statut de phase 1": "AFFECTED",
"_id du bus": ligneBus.id,
"Nom du bus": jeune.ligneDeBusId,
"_id du centre": jeune.centreId!,
"Nom du centre": sejour.centreNom!,
"Département du centre": sejour.departement!,
"Région du centre": sejour.region!,
"_id classe": jeune.classeId!,
"Statut de phase 1": jeune.statutPhase1,
"id du bus": ligneBus.id,
"Nom du bus": ligneBus.numeroLigne,
"id du centre": jeune.centreId!,
// "matricule du centre": centre?.,
"Nom du centre": sejour?.centreNom!,
"Département du centre": sejour?.departement!,
"Région du centre": sejour?.region!,
"id classe": jeune.classeId!,
"Nom de la classe": classe.nom!,
"Nom de l'établissement": etablissement?.nom,
"Département de l'établissement": etablissement?.departement,
"Région de l'établissement": etablissement?.region,
"Référent de classe Nom": referentClasse?.nomComplet,
"Référent de classe Email": referentClasse?.email,
dev_sessionPhase1Id: jeune.sejourId!,
dev_cohesionCenterId: classe.centreCohesionId!,
dev_pointDeRassemblementId: jeune.pointDeRassemblementId!,
dev_ligneId: jeune.ligneDeBusId!,
dev_status: jeune.statut,
dev_statusPhase1: "AFFECTED",
sejourId: jeune.sejourId!,
classeCenterId: classe.centreCohesionId!,
pointDeRassemblementId: jeune.pointDeRassemblementId!,
jeuneLigneId: jeune.ligneDeBusId!,
} as JeuneRapport;
});

const centreListRapport = centreList.map((centre) => {
const sejour = centre.sejour;
const centreListRapport = sejourList.map((info) => {
const sejour = info.sejour;
return {
_id: sejour.id,
id: sejour.id,
"Nom du centre": sejour.centreNom,
"Département du centre": sejour.departement,
"Région du centre": sejour.region,
"Places disponibles": sejour.placesTotal || 0,
"Places occupées": centre.placeOccupees,
"Places restantes": centre.placeRestantes,
"Places occupées": info.placeOccupees,
"Places restantes": info.placeRestantes,
} as CentreRapport;
});

const ligneBusRapport = ligneDeBusList.map((ligneBusResults) => {
const ligneDeBus = ligneBusResults.ligneDeBus;
const classe = classeList.find((classe) => classe.id === ligneBusResults.classeId)!;
const sejour = centreList.find((centre) => centre.sejour.id === ligneBusResults.sejourId)!.sejour;
const sejour = sejourList.find((centre) => centre.sejour.id === ligneBusResults.sejourId)!.sejour;
return {
_id: ligneDeBus.id,
id: ligneDeBus.id,
"Nom du bus": ligneDeBus.numeroLigne,
"_id du centre": classe.centreCohesionId,
"id du centre": classe.centreCohesionId,
"Nom du centre": sejour.centreNom,
"Département du centre": sejour.departement,
"Région du centre": sejour.region,
Expand Down Expand Up @@ -215,13 +212,13 @@ export class SimulationAffectationCLEService {
placesRestantes = sejour.placesRestantes;
}
return {
"_id classe": classe.id,
"id classe": classe.id,
"Nom de la classe": classe.nom,
"Nom de l'établissement": etablissement?.nom,
"Département de l'établissement": etablissement?.departement,
"Région de l'établissement": etablissement?.region,
"_id du centre": classe.centreCohesionId,
"_id du bus": ligneBus?.id,
"id du centre": classe.centreCohesionId,
"id du bus": ligneBus?.id,
"Nom du bus": ligneBus?.numeroLigne,
Erreur: erreur.message,
"Nombre de volontaires": erreur.jeunesNombre,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { ReferentGateway } from "@admin/core/iam/Referent.gateway";
type Resultats = {
jeunesList: JeuneModel[];
jeunesDejaAffectedList: JeuneModel[];
centreList: {
sejourList: {
sejour: SejourModel;
placeOccupees: number;
placeRestantes: number;
Expand Down Expand Up @@ -111,7 +111,7 @@ export class SimulationAffectationCLE implements UseCase<SimulationAffectationCL
const resultats: Resultats = {
jeunesList: [],
jeunesDejaAffectedList: [],
centreList: [],
sejourList: [],
ligneDeBusList: [],
classeErreurList: [],
};
Expand Down Expand Up @@ -214,7 +214,7 @@ export class SimulationAffectationCLE implements UseCase<SimulationAffectationCL
}

// Gestion place dans le centre
const resultatCentre = resultats.centreList.find((r) => r.sejour.id === sejour.id);
const resultatCentre = resultats.sejourList.find((r) => r.sejour.id === sejour.id);
placesRestantes = resultatCentre?.placeRestantes || sejour.placesRestantes || 0;
if (placesRestantes < jeunesList.length) {
resultats.classeErreurList.push({
Expand All @@ -227,7 +227,7 @@ export class SimulationAffectationCLE implements UseCase<SimulationAffectationCL
continue;
}
if (!resultatCentre) {
resultats.centreList.push({
resultats.sejourList.push({
sejour: sejour,
placeOccupees: (sejour.placesTotal || 0) - (sejour.placesRestantes || 0) + jeunesList.length,
placeRestantes: (sejour.placesRestantes || 0) - jeunesList.length,
Expand All @@ -253,7 +253,7 @@ export class SimulationAffectationCLE implements UseCase<SimulationAffectationCL
const rapportData = this.simulationAffectationCLEService.calculRapportAffectation(
resultats.jeunesList,
resultats.ligneDeBusList,
resultats.centreList,
resultats.sejourList,
resultats.classeErreurList,
classeList,
etablissementList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ describe("ValiderAffectationCLE", () => {
parseXLS: jest.fn().mockResolvedValue([
{
"_id du volontaire": "jeune1",
dev_ligneId: "65f9c8bb735e0e12a4213c18",
dev_sessionPhase1Id: "6597e6acb86afb08146e8f86",
dev_cohesionCenterId: "609bebb00c1cc9a888ae8fa8",
dev_pointDeRassemblementId: "6398797d3bc18708cc3981f6",
jeuneLigneId: "65f9c8bb735e0e12a4213c18",
sejourId: "6597e6acb86afb08146e8f86",
classeCenterId: "609bebb00c1cc9a888ae8fa8",
pointDeRassemblementId: "6398797d3bc18708cc3981f6",
},
]),
},
Expand Down
Loading

0 comments on commit 53670a4

Please sign in to comment.