Skip to content

Commit

Permalink
feat(api): prevent funding request from api when flag is activated
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricss committed Dec 12, 2024
1 parent 3116dd3 commit 7157a4e
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { applyBusinessValidationRules } from "../validation";
import { createBatchFromFundingRequestUnifvae } from "./fundingRequestBatch";
import { updateCandidacyStatus } from "../../../candidacy/features/updateCandidacyStatus";
import { isFundingRequestEnabledForCertification } from "../../../candidacy-menu/features/isFundingRequestEnabledForCertification";
import { isFeatureActiveForUser } from "../../../feature-flipping/feature-flipping.features";

export const createFundingRequestUnifvae = async ({
candidacyId,
Expand All @@ -22,6 +23,13 @@ export const createFundingRequestUnifvae = async ({
userEmail?: string;
userRoles: KeyCloakUserRole[];
}) => {
const fundingRequestDisabled = await isFeatureActiveForUser({
feature: "FUNDING_REQUEST_DISABLED",
});
if (fundingRequestDisabled) {
throw new Error("La demande de prise en charge est désactivée");
}

const candidacy = await prismaClient.candidacy.findUnique({
where: { id: candidacyId },
select: {
Expand Down

0 comments on commit 7157a4e

Please sign in to comment.