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

fix: add direct connection to bal db for deca #3910

Closed
wants to merge 6 commits into from
Closed
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
1,982 changes: 1,025 additions & 957 deletions .infra/vault/vault.yml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions server/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ program
return createJobAction(name)(options);
});

program
.command("hydrate:contrats-deca-raw")
.description("Manually trigger the creation of deca effectifs")
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("hydrate:contrats-deca-raw"));

export async function startCLI() {
await program.parseAsync(process.argv);
}
5 changes: 5 additions & 0 deletions server/src/common/mongodb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const getMongodbUri = (dbName: string = config.mongodb.dbName, withMainDb
}
return `${config.mongodb.uri}${dbName}?${config.mongodb.options}`;
};

export const getBALMongodbUri = (dbName: string) => {
return `${config.mongodb.uriBal}${dbName}?${config.mongodb.optionsBal}`;
};

/**
* @param {string} uri
* @returns client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ exports[`validation-schema > should create validation schema for effectifs > eff
"anyOf": [
{
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
{
"bsonType": "null",
Expand Down Expand Up @@ -403,7 +403,7 @@ exports[`validation-schema > should create validation schema for effectifs > eff
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -1022,7 +1022,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -1518,7 +1518,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -2425,7 +2425,7 @@ exports[`validation-schema > should create validation schema for effectifsArchiv
"anyOf": [
{
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
{
"bsonType": "null",
Expand Down Expand Up @@ -2639,7 +2639,7 @@ exports[`validation-schema > should create validation schema for effectifsArchiv
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -3258,7 +3258,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -3754,7 +3754,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -4710,7 +4710,7 @@ exports[`validation-schema > should create validation schema for effectifsDECA >
"anyOf": [
{
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
{
"bsonType": "null",
Expand Down Expand Up @@ -5258,7 +5258,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -5728,7 +5728,7 @@ Pour les jeunes résidents à l’étranger, il conviendra de mettre « 99 » su
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -8891,7 +8891,7 @@ exports[`validation-schema > should create validation schema for organismes > or
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -9892,7 +9892,7 @@ exports[`validation-schema > should create validation schema for organismes > or
},
"departement": {
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
"numero": {
"bsonType": "int",
Expand Down Expand Up @@ -10140,7 +10140,6 @@ exports[`validation-schema > should create validation schema for organismes > or
"siret": {
"bsonType": "string",
"description": "Siret du lieu de formation (optionnel)",
"pattern": "^[0-9]{14}$",
},
"uai": {
"bsonType": "string",
Expand Down Expand Up @@ -11036,7 +11035,7 @@ exports[`validation-schema > should create validation schema for voeuxAffelnet >
},
{
"bsonType": "string",
"pattern": "^[0-9]{2,3}$",
"pattern": "^(2A|2B|[0-9]{2,3})$",
},
],
},
Expand Down
4 changes: 4 additions & 0 deletions server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
options: env.get("MNA_TDB_MONGODB_OPTIONS").required().asString(),
decaDbName: env.get("MNA_TDB_DECA_DB_NAME").required().asString(),
decaDbCollection: env.get("MNA_TDB_DECA_COLLECTION_NAME").required().asString(),
uriBal: env.get("MNA_BAL_MONGODB_URI").required().asString(),

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/admin.routes.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/authentication.routes.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/dossierApprenantsV3.route.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/dossiersApprenantsV2.route.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/effectif.routes.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/impersonation.routes.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/indicateurs-deca.route.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/indicateurs-national.route.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/indicateurs.route.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ src/common/logger.ts:3:31

Check failure on line 18 in server/src/config.ts

View workflow job for this annotation

GitHub Actions / tests / Tests

tests/integration/http/misc.routes.test.ts

EnvVarError: env-var: "MNA_BAL_MONGODB_URI" is a required variable, but it was not set ❯ raiseError ../node_modules/env-var/lib/variable.js:47:11 ❯ Object.asString ../node_modules/env-var/lib/variable.js:64:11 ❯ src/config.ts:18:55 ❯ tests/integration/http/misc.routes.test.ts:3:31
dbNameBal: env.get("MNA_BAL_MONGODB_DB_NAME").required().asString(),
optionsBal: env.get("MNA_BAL_MONGODB_OPTIONS").asString(),
decaDbCollectionBal: env.get("MNA_BAL_DECA_COLLECTION_NAME").required().asString(),
},
auth: {
passwordHashRounds: 10000,
Expand Down
31 changes: 16 additions & 15 deletions server/src/jobs/hydrate/deca/hydrate-deca-raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { captureException } from "@sentry/node";
import { MongoClient, ObjectId, WithoutId } from "mongodb";
import { SOURCE_APPRENANT } from "shared/constants";
import { IEffectif, IOrganisme } from "shared/models";
import { IAirbyteRawBalDeca } from "shared/models/data/airbyteRawBalDeca.model";
import { IRawBalDeca } from "shared/models/data/airbyteRawBalDeca.model";
import { zApprenant } from "shared/models/data/effectifs/apprenant.part";
import { zContrat } from "shared/models/data/effectifs/contrat.part";
import { IEffectifDECA } from "shared/models/data/effectifsDECA.model";
Expand All @@ -16,12 +16,13 @@ import { checkIfEffectifExists } from "@/common/actions/engine/engine.actions";
import { getOrganismeByUAIAndSIRET } from "@/common/actions/organismes/organismes.actions";
import parentLogger from "@/common/logger";
import { effectifsDECADb, organismesDb } from "@/common/model/collections";
import { getMongodbUri } from "@/common/mongodb";
import { getBALMongodbUri } from "@/common/mongodb";
import { __dirname } from "@/common/utils/esmUtils";
import config from "@/config";

const logger = parentLogger.child({ module: "job:hydrate:contrats-deca-raw" });

const client = new MongoClient(getMongodbUri(config.mongodb.decaDbName, true));
const client = new MongoClient(getBALMongodbUri(config.mongodb.dbNameBal));

export async function hydrateDecaRaw() {
let count = { created: 0, updated: 0 };
Expand All @@ -32,14 +33,14 @@ export async function hydrateDecaRaw() {
await client.connect();

const query = {
"_airbyte_data.dispositif": "APPR",
"_airbyte_data.organisme_formation.uai_cfa": { $exists: true },
"_airbyte_data.organisme_formation.siret": { $exists: true },
"_airbyte_data.formation.date_debut_formation": { $exists: true },
"_airbyte_data.formation.date_fin_formation": { $exists: true },
dispositif: "APPR",
"organisme_formation.uai_cfa": { $exists: true },
"organisme_formation.siret": { $exists: true },
"formation.date_debut_formation": { $exists: true },
"formation.date_fin_formation": { $exists: true },
};

const cursor = client.db().collection<IAirbyteRawBalDeca>(config.mongodb.decaDbCollection).find(query);
const cursor = client.db().collection<IRawBalDeca>(config.mongodb.decaDbCollectionBal).find(query);

for await (const document of cursor) {
totalCount++;
Expand Down Expand Up @@ -67,7 +68,7 @@ export async function hydrateDecaRaw() {
}

async function updateEffectifDeca(
document: IAirbyteRawBalDeca,
document: IRawBalDeca,
count: { created: number; updated: number },
organismeIds: Set<string>
) {
Expand Down Expand Up @@ -114,8 +115,8 @@ async function updateOrganismesLastEffectifUpdate(organismeIds: Set<string>) {
}
}

async function transformDocument(document: IAirbyteRawBalDeca): Promise<WithoutId<IEffectifDECA>[]> {
const { formation } = document._airbyte_data;
async function transformDocument(document: IRawBalDeca): Promise<WithoutId<IEffectifDECA>[]> {
const { formation } = document;

const dateDebutFormation = formation?.date_debut_formation ? new Date(formation.date_debut_formation) : null;
const dateFinFormation = formation?.date_fin_formation ? new Date(formation.date_fin_formation) : null;
Expand Down Expand Up @@ -145,7 +146,7 @@ async function transformDocument(document: IAirbyteRawBalDeca): Promise<WithoutI
return effectifs;
}

async function createEffectif(document: IAirbyteRawBalDeca, anneeScolaire: string): Promise<WithoutId<IEffectifDECA>> {
async function createEffectif(document: IRawBalDeca, anneeScolaire: string): Promise<WithoutId<IEffectifDECA>> {
const {
alternant,
formation,
Expand All @@ -155,7 +156,7 @@ async function createEffectif(document: IAirbyteRawBalDeca, anneeScolaire: strin
date_fin_contrat,
date_effet_rupture,
type_contrat,
} = document._airbyte_data;
} = document;

const {
nom,
Expand Down Expand Up @@ -204,7 +205,7 @@ async function createEffectif(document: IAirbyteRawBalDeca, anneeScolaire: strin
}

const effectif: WithoutId<IEffectifDECA> = {
deca_raw_id: document._id,
deca_raw_id: new ObjectId(document._id),
apprenant: {
nom,
prenom,
Expand Down
5 changes: 3 additions & 2 deletions server/static/reseaux/referentiel-reseau-mfr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ Siret;UAI validée;Raison sociale;Enseigne;numero_declaration_activite;etat_admi
78151651300012;0861145C;MAISON FAMILIALE RURALE;;54860031786;actif;responsable_formateur;Rue de Montmorillon 86300 Chauvigny;Poitiers;Nouvelle-Aquitaine;Oui;mfr;mfr;;1;2021-12-17;0861145C;0861145C;;
30436842600017;0861131M;MAISON FAMILIALE SERVICES;;54860031486;actif;responsable_formateur;8 Rue Emilien Fillon 86160 Gençay;Poitiers;Nouvelle-Aquitaine;Oui;mfr;mfr;;2;2021-12-17;0861131M;0861131M;0861423E;
78641329400012;0851590S;MAISON FAMILIALE LA LOUISIERE;;52850122585;actif;responsable_formateur;Rue de Beaurepaire 85500 Les Herbiers;Nantes;Pays de la Loire;Oui;;mfr;;1;2021-12-17;0851590S;0851590S;;
78650966100041;;ASS CTRE FORM APPRENTIS MAIS FAM VEND;CFA MAISONS FAMILIALES DE VENDEE;;actif;inconnue;412 Avenue notre-dame 85440 Talmont-Saint-Hilaire;Nantes;Pays de la Loire;Non;;mfr;1;;2021-12-17;0851589R;0851589R;;
41355776000019;0851556E;MAISON FAMILIALE RURALE D'EDUCATION ET D'ORIENTATION DES SABLES D'OLONNE;;52850075285;actif;responsable_formateur;110 Rue du docteur schweitzer 85340 Les Sables-d'Olonne;Nantes;Pays de la Loire;Oui;mfr;mfr;;1;2021-12-17;0851556E;0851345A;0851556E;
34229971600015;0851403N;INST FORMATION ALTERN COMMERCES METIERS;;52850056285;actif;responsable_formateur;le plessis bergeret 85280 La Ferrière;Nantes;Pays de la Loire;Oui;mfr;mfr;;1;2021-12-17;0851403N;0851345A;0851403N;
78639247200019;0851309L;MAISON FAMILIALE RURALE EDUC ET ORIENT;;52850006985;actif;responsable_formateur;25 Avenue georges clémenceau 85110 Chantonnay;Nantes;Pays de la Loire;Oui;mfr;mfr;;1;2021-12-17;0851309L;0851309L;;
Expand Down Expand Up @@ -353,7 +352,6 @@ Siret;UAI validée;Raison sociale;Enseigne;numero_declaration_activite;etat_admi
78338935600016;0550958T;MAISON FAMIL RURALE EDUC ORIEN;;41550046955;actif;responsable_formateur;Damvillers;Nancy-Metz;Grand Est;Oui;mfr;mfr;;2;2021-12-17;0550958T;0550958T;;
78341511000015;0550892W;ASS MAISONS FAMILIALES VIGNEULLES HATTON;;41550010455;actif;responsable_formateur;Rue du Château des 4 Vents 55210 Vigneulles-lès-Hattonchâtel;Nancy-Metz;Grand Est;Oui;mfr;mfr;;1;2021-12-17;0550892W;0550892W;0551027T;
44893459600017;0741630V;MAISON FAMILIALE CHAMP MOLLIAZ;;82740232774;actif;responsable_formateur;261 Route de lossy 74380 Cranves-Sales;Grenoble;Auvergne-Rhône-Alpes;Oui;;mfr;1;1;2021-12-17;0741630V;0741630V;;
78045946700020;0520939N;MAISON FAMILIALE RURALE;;21520000652;actif;responsable_formateur;12 Rue du Baron de Beine 52000 Buxières-lès-Villiers;Reims;Grand Est;Oui;mfr;mfr;;;2021-12-17;0520939N;0520939N;;
30287992900016;0520901X;MAISON FAMILIALE RURALE EDUCATION ORIENT;;21520027552;actif;responsable_formateur;Rue Toupot de Beveaux 52270 Doulaincourt-Saucourt;Reims;Grand Est;Oui;mfr;mfr;;1;2021-12-17;0520901X;0520901X;;
30234347000019;0511733G;MAISON FAMILIALE RURALE EDUCATION ORIENT;;44510200651;actif;responsable_formateur;Auve;Reims;Grand Est;Oui;mfr;mfr;;1;2021-12-17;0511733G;0511733G;;
30286824500010;0511732F;MAISON FAMILIALE RURALE EDUCATION ORIENT;;21510123251;actif;responsable_formateur;66 Rue de la Croliere 51130 Blancs-Coteaux;Reims;Grand Est;Oui;mfr;mfr;1;1;2021-12-17;0511732F;0511732F;;
Expand Down Expand Up @@ -418,3 +416,6 @@ Siret;UAI validée;Raison sociale;Enseigne;numero_declaration_activite;etat_admi
30476321200020;0694458W;MAISON FAMILIALE RURALE VAL DE COISE;;82691183069;actif;responsable_formateur;291 CHS BEAUVOIR 69590 SAINT-SYMPHORIEN-SUR-COISE;Lyon;Auvergne-Rhône-Alpes;Oui;;mfr;;1;2021-12-24;0694458W;0692436Y;0694458W;
82906328800015;0694366W;MAISON FAMILIALE RURALE D'EDUCATION ET D'ORIENTATION DU CAMPUS DU BEAUJOLAIS;MFR CAMPUS DU MARTELET;84691632469;actif;responsable_formateur;92 RUE DEPAGNEUX 69400 LIMAS;Lyon;Auvergne-Rhône-Alpes;Oui;;mfr;;1;2021-12-25;0694366W;0692436Y;0694366W;
77833721200014;0251980S;MAISON FAMILIALE RURALE LA ROCHE DU TRESOR;;43250169225;actif;inconnue;1 RUE DU PRE 25510 PIERREFONTAINE-LES-VARANS;Besançon;Bourgogne-Franche-Comté;Oui;;mfr;1;;2021-12-26;0251500V;0251500V;0251980S;
39521351500012;0741525F;;;;;;;;;;;mfr;;;;;;;
84939883900027;0222053M;;;;;;;;;;;mfr;;;;;;;
79459078600016;0851589R;;;;;;;;;;;mfr;;;;;;;
13 changes: 3 additions & 10 deletions shared/models/data/airbyteRawBalDeca.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const zOrganismeFormation = z.object({
});

// Main schema for the airbyte data
const zAirbyteData = z.object({
_id: z.string(),
const zRawBalDeca = z.object({
_id: zObjectId,
no_contrat: z.string(),
type_contrat: z.string(),
alternant: zAlternant,
Expand All @@ -75,12 +75,5 @@ const zAirbyteData = z.object({
_ab_cdc_deleted_at: z.null().optional(),
});

const zAirbyteRawBalDeca = z.object({
_id: zObjectId.describe("Identifiant MongoDB de l'enregistrement"),
_airbyte_data: zAirbyteData,
_airbyte_data_hash: z.string(),
_airbyte_emitted_at: z.string().describe("Date à laquelle les données ont été émises").optional(),
});

// Define the type
export type IAirbyteRawBalDeca = z.infer<typeof zAirbyteRawBalDeca>;
export type IRawBalDeca = z.infer<typeof zRawBalDeca>;
1 change: 0 additions & 1 deletion shared/models/data/organismes.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ const zOrganisme = z
.string({
description: "Siret du lieu de formation (optionnel)",
})
.regex(SIRET_REGEX)
.optional(),
adresse: zAdresse.describe("Adresse du lieu de formation (optionnel)").optional(),
})
Expand Down
2 changes: 1 addition & 1 deletion shared/models/parts/adresseSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const zAdresse = zodOpenApi.object({
.optional(),
departement: zodOpenApi
.string()
.regex(/^[0-9]{2,3}$/)
.regex(/^(2A|2B|[0-9]{2,3})$/)
.openapi({ examples: ["01", "59"] })
.optional(),
region: zodOpenApi
Expand Down
21 changes: 12 additions & 9 deletions ui/modules/transmissions/ListeTransmissionsDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,34 @@ import TransmissionsErrorTab from "./TransmissionsErrorTab";
interface ListeTransmissionsDetailsProps {
organisme: Organisme;
date: string;
modePublique?: boolean;
}

const ListeTransmissionsDetails = (props: ListeTransmissionsDetailsProps) => {
const ListeTransmissionsDetails = ({ organisme, date, modePublique = false }: ListeTransmissionsDetailsProps) => {
const transmissionSuccessDetailCount = useRecoilValue(transmissionSuccessDetailsCountAtom);
const transmissionErrorsDetailCount = useRecoilValue(transmissionErrorsDetailsCountAtom);

const computeBackLinkUrl = () => {
return modePublique ? `/organismes/${organisme._id}/transmissions` : `/transmissions`;
};

return (
<SimplePage>
<Container maxW="xl" p="8">
<Heading as="h1" color="#465F9D" fontSize="beta" fontWeight="700" mb="4w">
Rapport du {formatDateNumericDayMonthYear(props.date)}
Rapport du {formatDateNumericDayMonthYear(date)}
</Heading>
<HStack mt={10} mb={10}>
<Link
href={`/transmissions`}
href={computeBackLinkUrl()}
color="action-high-blue-france"
borderBottom="1px"
_hover={{ textDecoration: "none" }}
>
<ArrowBackIcon mr={2} />
Retour au tableau des rapports
</Link>
Mes erreurs de transmissions du {formatDateNumericDayMonthYear(props.date)}
Mes erreurs de transmissions du {formatDateNumericDayMonthYear(date)}
</HStack>
<Tabs mt={8}>
<TabList>
Expand All @@ -46,7 +52,7 @@ const ListeTransmissionsDetails = (props: ListeTransmissionsDetailsProps) => {

<TabPanels>
<TabPanel px="0">
<TransmissionsErrorTab organisme={props.organisme} date={props.date} />
<TransmissionsErrorTab organisme={organisme} date={date} />
</TabPanel>
<TabPanel px="0">
<Box mt={10} mb={10}>
Expand All @@ -62,10 +68,7 @@ const ListeTransmissionsDetails = (props: ListeTransmissionsDetailsProps) => {
</Text>
</Box>

<TransmissionSuccessDetailsTable
organisme={props.organisme}
date={props.date}
></TransmissionSuccessDetailsTable>
<TransmissionSuccessDetailsTable organisme={organisme} date={date}></TransmissionSuccessDetailsTable>
</TabPanel>
</TabPanels>
</Tabs>
Expand Down
Loading