Skip to content

Commit

Permalink
feat(api): funding request link in candidacy menu is no displayed if …
Browse files Browse the repository at this point in the history
…the candidacy certification is not in the allowed list
  • Loading branch information
agarbe committed Sep 2, 2024
1 parent a329d07 commit 1fe2381
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -264,7 +281,7 @@ export const getActiveCandidacyMenu = async ({
feasibilityFormat: candidacy.feasibilityFormat,
isCandidateSummaryComplete,
}),
getFundingRequestMenuEntry(),
await getFundingRequestMenuEntry(),
getDossierDeValidationMenuEntry(),
await getPaymentRequestMenuEntry(),
getJuryMenuEntry(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
);

0 comments on commit 1fe2381

Please sign in to comment.