diff --git a/packages/reva-api/modules/candidacy-menu/features/getActiveCandidacyMenu.ts b/packages/reva-api/modules/candidacy-menu/features/getActiveCandidacyMenu.ts index 3f1128017..22e736175 100644 --- a/packages/reva-api/modules/candidacy-menu/features/getActiveCandidacyMenu.ts +++ b/packages/reva-api/modules/candidacy-menu/features/getActiveCandidacyMenu.ts @@ -7,6 +7,8 @@ import { import { CandidacyForMenu } from "./getCandidacyForMenu"; import { menuUrlBuilder } from "./getMenuUrlBuilder"; import { isCandidacyStatusEqualOrAboveGivenStatus } from "./isCandidacyStatusEqualOrAboveGivenStatus"; +import { getCertificationById } from "../../referential/features/getCertificationById"; +import { isFundingRequestEnabledForCertification } from "./isFundingRequestEnabledForCertification"; export const getActiveCandidacyMenu = async ({ candidacy, @@ -119,12 +121,27 @@ export const getActiveCandidacyMenu = async ({ : undefined; }; - const getFundingRequestMenuEntry = (): CandidacyMenuEntry | undefined => { + const getFundingRequestMenuEntry = async (): Promise< + CandidacyMenuEntry | undefined + > => { //pas de page de demande de financemnt si le financement de la candidature est "hors plateforme" if (candidacy.financeModule === "hors_plateforme") { return; } + const certification = await getCertificationById({ + certificationId: candidacy.certificationId, + }); + + if ( + !certification || + !isFundingRequestEnabledForCertification({ + certificationRncpId: certification.rncpId, + }) + ) { + return; + } + let menuEntryStatus: CandidacyMenuEntryStatus = "INACTIVE"; if (candidacy.financeModule === "unireva") { @@ -264,7 +281,7 @@ export const getActiveCandidacyMenu = async ({ feasibilityFormat: candidacy.feasibilityFormat, isCandidateSummaryComplete, }), - getFundingRequestMenuEntry(), + await getFundingRequestMenuEntry(), getDossierDeValidationMenuEntry(), await getPaymentRequestMenuEntry(), getJuryMenuEntry(), diff --git a/packages/reva-api/modules/candidacy-menu/features/getDroppedOutCandidacyMenu.ts b/packages/reva-api/modules/candidacy-menu/features/getDroppedOutCandidacyMenu.ts index 85c2260db..2e4d32b2b 100644 --- a/packages/reva-api/modules/candidacy-menu/features/getDroppedOutCandidacyMenu.ts +++ b/packages/reva-api/modules/candidacy-menu/features/getDroppedOutCandidacyMenu.ts @@ -8,6 +8,8 @@ import { CandidacyForMenu } from "./getCandidacyForMenu"; import { menuUrlBuilder } from "./getMenuUrlBuilder"; import { isCandidacyStatusEqualOrAboveGivenStatus } from "./isCandidacyStatusEqualOrAboveGivenStatus"; import { format } from "date-fns"; +import { getCertificationById } from "../../referential/features/getCertificationById"; +import { isFundingRequestEnabledForCertification } from "./isFundingRequestEnabledForCertification"; export const getDroppedOutCandidacyMenu = async ({ candidacy, @@ -41,6 +43,19 @@ export const getDroppedOutCandidacyMenu = async ({ return undefined; } + const certification = await getCertificationById({ + certificationId: candidacy.certificationId, + }); + + if ( + !certification || + !isFundingRequestEnabledForCertification({ + certificationRncpId: certification.rncpId, + }) + ) { + return; + } + const editableStatus: CandidacyStatusStep[] = [ "DOSSIER_FAISABILITE_RECEVABLE", "DOSSIER_FAISABILITE_NON_RECEVABLE", diff --git a/packages/reva-api/modules/candidacy-menu/features/isFundingRequestEnabledForCertification.ts b/packages/reva-api/modules/candidacy-menu/features/isFundingRequestEnabledForCertification.ts new file mode 100644 index 000000000..44be60024 --- /dev/null +++ b/packages/reva-api/modules/candidacy-menu/features/isFundingRequestEnabledForCertification.ts @@ -0,0 +1,47 @@ +const rncpIdsOfCertificationsWithFundingRequestEnabled = [ + "36805", + "37795", + "34691", + "37780", + "34690", + "37792", + "34692", + "35830", + "35832", + "492", + "4503", + "34826", + "35028", + "37676", + "34825", + "37679", + "34827", + "36004", + "36938", + "37231", + "12296", + "12301", + "36836", + "37274", + "37715", + "35506", + "35993", + "35513", + "37675", + "34824", + "38565", + "28048", + "38390", + "25085", + "36788", + "13905", +]; + +export const isFundingRequestEnabledForCertification = ({ + certificationRncpId, +}: { + certificationRncpId: string; +}) => + rncpIdsOfCertificationsWithFundingRequestEnabled.includes( + certificationRncpId, + );