Skip to content

Commit 0ea47f3

Browse files
committed
fix(api): update candidacy contestation logic to check for confirmed or pending decisions
- Refactored the contestation validation logic in createCandidacyContestationCaducite to ensure that a candidacy cannot be contested if it has a confirmed or pending contestation decision. - Updated error message to reflect the new validation criteria.
1 parent c5b46da commit 0ea47f3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/reva-api/modules/candidacy/candidacy-contestation-caducite/features/createCandidacyContestationCaducite.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@ export const createCandidacyContestationCaducite = async ({
2727
throw new Error("La candidature n'a pas été trouvée");
2828
}
2929

30-
const contestationPending = candidacy.candidacyContestationCaducite.find(
31-
(contestation) =>
32-
contestation.certificationAuthorityContestationDecision ===
33-
CertificationAuthorityContestationDecision.DECISION_PENDING,
34-
);
30+
const hasConfirmedOrPendingContestation =
31+
candidacy.candidacyContestationCaducite.find(
32+
(contestation) =>
33+
contestation.certificationAuthorityContestationDecision ===
34+
CertificationAuthorityContestationDecision.CADUCITE_CONFIRMED ||
35+
contestation.certificationAuthorityContestationDecision ===
36+
CertificationAuthorityContestationDecision.DECISION_PENDING,
37+
);
3538

36-
if (contestationPending) {
39+
if (hasConfirmedOrPendingContestation) {
3740
throw new Error(
38-
"Une contestation est déjà en cours pour cette candidature",
41+
"La caducité de la candidature a été confirmée ou est en attente de décision",
3942
);
4043
}
4144

0 commit comments

Comments
 (0)