Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 3395 front back #4476

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions admin/src/scenes/centersV2/list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ModalRattacherCentre from "./components/ModalRattacherCentre";
import { ExportComponent, Filters, ResultTable, Save, SelectedFilters } from "../../components/filters-system-v2";
import { getCohortGroups } from "@/services/cohort.service";
import { getDefaultCohort } from "@/utils/session";
import { title } from "process";

export default function List() {
const user = useSelector((state) => state.Auth.user);
Expand Down Expand Up @@ -80,6 +81,7 @@ const ListSession = ({ firstSession }) => {
const [size, setSize] = useState(10);
const filterArray = [
{ title: "Cohorte", name: "cohort", missingLabel: "Non renseignée", sort: (e) => orderCohort(e) },
{ title: "Matricule", name: "codeCentre", missingLabel: "Non renseigné" },
{ title: "Région", name: "region", missingLabel: "Non renseignée", defaultValue: user.role === ROLES.REFERENT_REGION ? [user.region] : [] },
{
title: "Département",
Expand All @@ -100,7 +102,6 @@ const ListSession = ({ firstSession }) => {
translate,
},
];
if (user.role === ROLES.ADMIN) filterArray.push({ title: "Code", name: "code", missingLabel: "Non renseignée" });

if (!firstSession) return <div></div>;
return (
Expand Down Expand Up @@ -141,7 +142,7 @@ const ListSession = ({ firstSession }) => {
const hasSanitaryContactEmail = Boolean(data?.sanitaryContactEmail).toString();
return {
"Id centre": center?._id?.toString(),
"Code du centre": center?.code2022,
Matricule: center?.matricule,
"Nom du centre": center?.name,
"Désignation du centre": center?.centerDesignation,
"Id de la session": data?._id?.toString(),
Expand Down Expand Up @@ -223,6 +224,7 @@ const ListCenter = ({ firstSession }) => {
});
const [size, setSize] = useState(10);
const filterArray = [
{ title: "Matricule", name: "matricule", missingLabel: "Non renseigné" },
{ title: "Cohorte", name: "cohorts", missingLabel: "Non renseignée", sort: (e) => orderCohort(e) },
{
title: "Région",
Expand Down Expand Up @@ -250,7 +252,6 @@ const ListCenter = ({ firstSession }) => {
translate: (e) => translateDomainCenter(e),
},
];
if (user.role === ROLES.ADMIN) filterArray.push({ title: "Code", name: "code2022", missingLabel: "Non renseignée" });

const history = useHistory();

Expand Down Expand Up @@ -281,7 +282,7 @@ const ListCenter = ({ firstSession }) => {
return all?.map((data) => {
return {
Id: data._id.toString(),
"Code du centre": data?.code2022,
Matricule: data?.matricule,
Nom: data?.name,
"Désignation du centre": data?.centerDesignation,
"Cohorte(s)": data?.cohorts
Expand Down
2 changes: 2 additions & 0 deletions admin/src/scenes/classe/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export function exportExcelSheet(classes: ClasseExport[], type: typeExport) {
studentNotAutorized: c.studentNotAutorized,
studentWithdrawn: c.studentWithdrawn,
centerId: c.cohesionCenterId,
centerMatricule: c.cohesionCenter?.matricule,
centerName: c.cohesionCenter ? `${c.cohesionCenter?.name}, ${c.cohesionCenter?.address}, ${c.cohesionCenter?.zip} ${c.cohesionCenter?.city}` : "",
centerDepartment: c.cohesionCenter?.department,
centerRegion: c.cohesionCenter?.region,
Expand Down Expand Up @@ -373,6 +374,7 @@ export function exportExcelSheet(classes: ClasseExport[], type: typeExport) {
"Nombre d'élèves non autorisés",
"Nombre d'élèves désistés",
"ID centre",
"Matricule du centre",
"Désignation du centre",
"Département du centre",
"Région du centre",
Expand Down
6 changes: 4 additions & 2 deletions admin/src/scenes/plan-transport/ligne-bus/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function List() {
translate: (e) => getDepartmentNumber(e) + " - " + e,
},
{ title: "Ville", name: "pointDeRassemblements.city", parentGroup: "Points de rassemblement", missingLabel: "Non renseigné" },
{ title: "Code", name: "pointDeRassemblements.code", parentGroup: "Points de rassemblement", missingLabel: "Non renseigné" },
{ title: "Matricule", name: "pointDeRassemblements.matricule", parentGroup: "Points de rassemblement", missingLabel: "Non renseigné" },
{ title: "Nom", name: "centerName", parentGroup: "Centre", missingLabel: "Non renseigné" },
{ title: "Région", name: "centerRegion", parentGroup: "Centre", missingLabel: "Non renseigné" },
{
Expand All @@ -90,7 +90,7 @@ export default function List() {
missingLabel: "Non renseigné",
translate: (e) => getDepartmentNumber(e) + " - " + e,
},
{ title: "Code", name: "centerCode", parentGroup: "Centre", missingLabel: "Non renseigné" },
{ title: "Matricule", name: "centerCode", parentGroup: "Centre", missingLabel: "Non renseigné" },
{
title: "Modification demandée",

Expand Down Expand Up @@ -369,6 +369,7 @@ const returnSelect = (cohort, selectedFilters, user) => {
pdrs[`N° DE DEPARTEMENT PDR ${num}`] = pdr?.department ? getDepartmentNumber(pdr.department) : "";
pdrs[`REGION DU PDR ${num}`] = pdr?.region || "";
pdrs[`ID PDR ${num}`] = pdr?.meetingPointId || "";
pdrs[`MATRICULE DU PDR ${num}`] = pdr?.matricule || "";
pdrs[`TYPE DE TRANSPORT PDR ${num}`] = pdr?.transportType || "";
pdrs[`NOM + ADRESSE DU PDR ${num}`] = pdr?.name ? pdr.name + " / " + pdr.address : "";
pdrs[`HEURE ALLER ARRIVÉE AU PDR ${num}`] = pdr?.busArrivalHour || "";
Expand All @@ -385,6 +386,7 @@ const returnSelect = (cohort, selectedFilters, user) => {
"N° DU DEPARTEMENT DU CENTRE": getDepartmentNumber(data.centerDepartment),
"REGION DU CENTRE": data.centerRegion,
"ID CENTRE": data.centerId,
"MATRICULE DU CENTRE": data.centerCode,
"NOM + ADRESSE DU CENTRE": data.centerName + " / " + data.centerAddress,
"HEURE D'ARRIVEE AU CENTRE": getZonedDate(data.centerArrivalTime),
"HEURE DE DÉPART DU CENTRE": getZonedDate(data.centerDepartureTime),
Expand Down
7 changes: 4 additions & 3 deletions admin/src/scenes/plan-transport/util.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ export async function exportLigneBus(cohort) {
"Téléphone représentant légal 2": formatPhoneE164(young.parent2Phone, young.parent2PhoneZone || getPhoneZoneByDepartment(young.department)),

"ID centre": center._id,
"Code centre (2022)": center.code2022,
"Matricule du centre)": center.matricule,
"Nom du centre": center.name,
"Adresse du centre": center.address,
"Ville du centre": center.city,
"Département du centre": center.department,
"Région du centre": center.region,

"Id du point de rassemblement": young.meetingPointId,
"Matricule du point de rassemblement": meetingPoint.matricule,
"Nom du point de rassemblement": meetingPoint.name,
"Adresse point de rassemblement": meetingPoint.address,
"Ville du point de rassemblement": meetingPoint.city,
Expand Down Expand Up @@ -343,7 +344,7 @@ export async function exportConvoyeur(cohort) {
const matchingCenter = centers.find((c) => c._id === currentLigneBus.centerId);

if (matchingCenter) {
currentLigneBus.centerCode = matchingCenter.code2022;
currentLigneBus.centerCode = matchingCenter.matricule;
currentLigneBus.centerDepartment = matchingCenter.department;
}
}
Expand Down Expand Up @@ -410,7 +411,7 @@ export async function exportConvoyeur(cohort) {

const dataItem = {
"Bus n˚": item.busId,
"Code centre (2022)": item.centerCode,
"Matricule Centre": item.centerCode,
Département: item.centerDepartment,
...team,
};
Expand Down
3 changes: 2 additions & 1 deletion admin/src/scenes/pointDeRassemblement/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useSelector } from "react-redux";
import { useHistory, useParams, useLocation } from "react-router-dom";
import { PointDeRassemblementType, ROLES, canCreateMeetingPoint, getDepartmentNumber } from "snu-lib";
import BusSvg from "../../assets/icons/Bus";
import Calendar from "../../assets/icons/Calendar";
import ExternalLink from "../../assets/icons/ExternalLink";
import Menu from "../../assets/icons/Menu";
import Breadcrumbs from "../../components/Breadcrumbs";
Expand Down Expand Up @@ -104,6 +103,7 @@ const ListPoints = ({ user }) => {
const [paramData, setParamData] = React.useState({ page: 0 });
const [size, setSize] = useState(10);
const filterArray = [
{ title: "Matricule", name: "matricule", missingLabel: "Non renseigné" },
{ title: "Cohorte", name: "cohorts", missingLabel: "Non renseignée", sort: (e) => orderCohort(e) },
{ title: "Région", name: "region", missingLabel: "Non renseignée", defaultValue: user.role === ROLES.REFERENT_REGION ? [user.region] : [] },
{
Expand Down Expand Up @@ -145,6 +145,7 @@ const ListPoints = ({ user }) => {
// @ts-ignore
Identifiant: item._id.toString(),
Code: item.code,
Matricule: item.matricule,
Cohortes: item?.cohorts.map((e) => e).join(", "),
Nom: item.name,
Adresse: item.address,
Expand Down
5 changes: 2 additions & 3 deletions admin/src/scenes/volontaires/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const getFilterArray = (user, bus, session, classes, etablissements) => {
if (item === "N/A" || !session.length) return item;
const res = session.find((option) => option._id.toString() === item);
if (!res) return "N/A - Supprimé";
return (res?.codeCentre || "N/A") + " - " + res?.cohesionCenterId;
return res?.codeCentre;
},
},
{
Expand Down Expand Up @@ -476,8 +476,7 @@ export async function transformVolontaires(data, values) {
},
phase1Affectation: {
"ID centre": center._id || "",
// "Code centre (2021)": center.code || "",
"Code centre (2022)": center.code2022 || "",
"Matricule centre": center.matricule || "",
"Nom du centre": center.name || "",
"Ville du centre": center.city || "",
"Département du centre": center.department || "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@ function getNewImportPlanTransportFixture() {
"DATE DE TRANSPORT ALLER": "12/06/2022",
"DATE DE TRANSPORT RETOUR": "03/07/2022",
"N° DE DEPARTEMENT PDR 1": "18",
"ID PDR 1": "63da1f2547841408c58e533d",
"MATRICULE PDR 1": "MATRICULE_PDR_1",
"TYPE DE TRANSPORT PDR 1": "Bus",
"NOM + ADRESSE DU PDR 1": "PARKING A L'ENTREE DU PARC DES EXPOSITIONS - RUE DES JARS (RUE BARBUSSE) - 17000 LA ROCHELLE",
"HEURE ALLER ARRIVÉE AU PDR 1": "12:00",
"HEURE DEPART DU PDR 1": "12:30",
"HEURE DE RETOUR ARRIVÉE AU PDR 1": "17:30",
"N° DE DEPARTEMENT PDR 2": null,
"ID PDR 2": null,
"MATRICULE PDR 2": null,
"TYPE DE TRANSPORT PDR 2": null,
"NOM + ADRESSE DU PDR 2": null,
"HEURE ALLER ARRIVÉE AU PDR 2": null,
"HEURE DEPART DU PDR 2": null,
"HEURE DE RETOUR ARRIVÉE AU PDR 2": null,
"N° DE DEPARTEMENT PDR 3": null,
"ID PDR 3": null,
"MATRICULE PDR 3": null,
"TYPE DE TRANSPORT PDR 3": null,
"NOM + ADRESSE DU PDR 3": null,
"HEURE ALLER ARRIVÉE AU PDR 3": null,
"HEURE DEPART DU PDR 3": null,
"HEURE DE RETOUR ARRIVÉE AU PDR 3": null,
"N° DU DEPARTEMENT DU CENTRE": "12",
"ID CENTRE": "63c919d5700cce08ce846633",
"MATRICULE CENTRE": "MATRICULE_CENTRE_1",
"NOM + ADRESSE DU CENTRE": "LYCEE PROFESSIONNEL DU BATIMENT ET METIERS DE LA SECURITE - CHARDEUIL - 24420 COULAURES",
"HEURE D'ARRIVEE AU CENTRE": "17:00",
"HEURE DE DÉPART DU CENTRE": "11:30",
Expand All @@ -46,28 +46,28 @@ function getNewImportPlanTransportFixture() {
"DATE DE TRANSPORT ALLER": "12/06/2023",
"DATE DE TRANSPORT RETOUR": "03/07/2023",
"N° DE DEPARTEMENT PDR 1": "19",
"ID PDR 1": "63ce916d95bf6308d789bea9",
"MATRICULE PDR 1": "MATRICULE_PDR_2",
"TYPE DE TRANSPORT PDR 1": "Bus",
"NOM + ADRESSE DU PDR 1": "PARKING A L'ENTREE DU PARC DES EXPOSITIONS - RUE DES JARS (RUE BARBUSSE) - 17000 LA ROCHELLE",
"HEURE ALLER ARRIVÉE AU PDR 1": "12:00",
"HEURE DEPART DU PDR 1": "12:30",
"HEURE DE RETOUR ARRIVÉE AU PDR 1": "17:30",
"N° DE DEPARTEMENT PDR 2": "18",
"ID PDR 2": "63ce91e495bf6308d789c96b",
"MATRICULE PDR 2": "MATRICULE_PDR_3",
"TYPE DE TRANSPORT PDR 2": "Bus",
"NOM + ADRESSE DU PDR 2": "PARKING A L'ENTREE DU PARC DES EXPOSITIONS - RUE DES JARS (RUE BARBUSSE) - 17000 LA ROCHELLE",
"HEURE ALLER ARRIVÉE AU PDR 2": "12:00",
"HEURE DEPART DU PDR 2": "12:30",
"HEURE DE RETOUR ARRIVÉE AU PDR 2": "17:30",
"N° DE DEPARTEMENT PDR 3": null,
"ID PDR 3": null,
"MATRICULE PDR 3": null,
"TYPE DE TRANSPORT PDR 3": null,
"NOM + ADRESSE DU PDR 3": null,
"HEURE ALLER ARRIVÉE AU PDR 3": null,
"HEURE DEPART DU PDR 3": null,
"HEURE DE RETOUR ARRIVÉE AU PDR 3": null,
"N° DU DEPARTEMENT DU CENTRE": "12",
"ID CENTRE": "63c919d5700cce08ce846633",
"MATRICULE CENTRE": "MATRICULE_CENTRE_2",
"NOM + ADRESSE DU CENTRE": "LYCEE PROFESSIONNEL DU BATIMENT ET METIERS DE LA SECURITE - CHARDEUIL - 24420 COULAURES",
"HEURE D'ARRIVEE AU CENTRE": "17:00",
"HEURE DE DÉPART DU CENTRE": "11:30",
Expand Down
22 changes: 11 additions & 11 deletions api/src/__tests__/helpers/PlanDeTransport/planDeTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import { createCohesionCenterWithSession } from "../cohesionCenter";
import { createPointDeRassemblementHelper } from "./pointDeRassemblement";

async function initPlanTransport(planTransport) {
const ids = planTransport.lines.reduce(
const matricules = planTransport.lines.reduce(
(acc, line) => {
const { "ID CENTRE": centreId, "ID PDR 1": pdr1Id, "ID PDR 2": pdr2Id, "ID PDR 3": pdr3Id } = line;
if (centreId) acc.centreIds[centreId] = centreId;
if (pdr1Id) acc.pdrIds[pdr1Id] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 1"]] };
if (pdr2Id) acc.pdrIds[pdr2Id] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 2"]] };
if (pdr3Id) acc.pdrIds[pdr3Id] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 3"]] };
const { "MATRICULE CENTRE": centreMatricule, "MATRICULE PDR 1": pdr1Matricule, "MATRICULE PDR 2": pdr2Matricule, "MATRICULE PDR 3": pdr3Matricule } = line;
if (centreMatricule) acc.centreMatricules[centreMatricule] = centreMatricule;
if (pdr1Matricule) acc.pdrMatricules[pdr1Matricule] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 1"]] };
if (pdr2Matricule) acc.pdrMatricules[pdr2Matricule] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 2"]] };
if (pdr3Matricule) acc.pdrMatricules[pdr3Matricule] = { department: departmentLookUp[line["N° DE DEPARTEMENT PDR 3"]] };
return acc;
},
{ centreIds: {}, pdrIds: {} },
{ centreMatricules: {}, pdrMatricules: {} },
);
for (const centreId of Object.keys(ids.centreIds)) {
for (const centreMatricule of Object.keys(matricules.centreMatricules)) {
await createCohesionCenterWithSession(
getNewCohesionCenterFixture({ _id: centreId, cohorts: [planTransport.cohort] }),
getNewCohesionCenterFixture({ cohorts: [planTransport.cohort], matricule: centreMatricule }),
getNewSessionPhase1Fixture({ cohort: planTransport.cohort }),
);
}
for (const pdrId of Object.keys(ids.pdrIds)) {
await createPointDeRassemblementHelper(getNewPointDeRassemblementFixture({ _id: pdrId, department: ids.pdrIds[pdrId].department }));
for (const pdrMatricule of Object.keys(matricules.pdrMatricules)) {
await createPointDeRassemblementHelper(getNewPointDeRassemblementFixture({ department: matricules.pdrMatricules[pdrMatricule].department, matricule: pdrMatricule }));
}
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/cohesionCenter/cohesionCenterController.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ router.put("/:id/session-phase1", passport.authenticate("referent", { session: f
placesLeft: value.placesTotal,
department: center.department,
region: center.region,
codeCentre: center.code2022,
codeCentre: center.matricule,
nameCentre: center.name,
cityCentre: center.city,
zipCentre: center.zip,
Expand Down
12 changes: 6 additions & 6 deletions api/src/controllers/elasticsearch/cohesioncenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ router.post("/:action(search|export)", passport.authenticate(["referent"], { ses
// Configuration
const { user, body } = req;

const searchFields = ["name", "city", "zip", "code2022", "typology", "domain"];
const filterFields = ["department.keyword", "region.keyword", "cohorts.keyword", "code2022.keyword", "typology.keyword", "domain.keyword"];
const searchFields = ["name", "city", "zip", "matricule", "typology", "domain"];
const filterFields = ["department.keyword", "region.keyword", "cohorts.keyword", "matricule.keyword", "typology.keyword", "domain.keyword"];
const sortFields = [];
// Authorization
if (!canSearchInElasticSearch(req.user, "cohesioncenter")) return res.status(403).send({ ok: false, code: ERRORS.OPERATION_UNAUTHORIZED });
Expand Down Expand Up @@ -62,7 +62,7 @@ router.post("/:action(search|export)", passport.authenticate(["referent"], { ses
router.post("/not-in-cohort/:cohort", passport.authenticate(["referent"], { session: false, failWithError: true }), async (req, res) => {
try {
// Configuration
const searchFields = ["name", "city", "zip", "code2022", "typology", "domain", "centerDesignation"];
const searchFields = ["name", "city", "zip", "matricule", "typology", "domain", "centerDesignation"];

// Authorization
if (!canSearchInElasticSearch(req.user, "cohesioncenter")) return res.status(403).send({ ok: false, code: ERRORS.OPERATION_UNAUTHORIZED });
Expand Down Expand Up @@ -92,9 +92,9 @@ router.post("/not-in-cohort/:cohort", passport.authenticate(["referent"], { sess
router.post("/presence/:action(search|export)", passport.authenticate(["referent"], { session: false, failWithError: true }), async (req, res) => {
try {
// Configuration
const searchFields = ["name", "city", "zip", "code2022"];
const filterFields = ["department.keyword", "region.keyword", "cohorts.keyword", "code2022.keyword", "academy.keyword", "status.keyword", "statusPhase1.keyword"];
const filterFieldsCenter = ["department.keyword", "region.keyword", "cohorts.keyword", "code2022.keyword", "academy.keyword"];
const searchFields = ["name", "city", "zip", "matricule"];
const filterFields = ["department.keyword", "region.keyword", "cohorts.keyword", "matricule.keyword", "academy.keyword", "status.keyword", "statusPhase1.keyword"];
const filterFieldsCenter = ["department.keyword", "region.keyword", "cohorts.keyword", "matricule.keyword", "academy.keyword"];
const sortFields = [];

// Authorization
Expand Down
2 changes: 1 addition & 1 deletion api/src/controllers/elasticsearch/pointderassemblement.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ router.post("/:action(search|export)", passport.authenticate(["referent"], { ses
// Configuration
const { user, body } = req;
const searchFields = ["name", "address", "particularitesAcces", "region", "department", "code", "city", "zip", "matricule"];
const filterFields = ["cohorts.keyword", "region.keyword", "department.keyword"];
const filterFields = ["cohorts.keyword", "region.keyword", "department.keyword", "matricule.keyword"];
const sortFields = [];

// Body params validation
Expand Down
2 changes: 1 addition & 1 deletion api/src/controllers/elasticsearch/sessionphase1.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ router.post("/:action(search|export)", passport.authenticate(["referent"], { ses
"department.keyword",
"region.keyword",
"cohort.keyword",
"code.keyword",
"placesLeft",
"codeCentre.keyword",
"hasTimeSchedule.keyword",
"typology.keyword",
"domain.keyword",
Expand Down
Loading
Loading