Skip to content

Commit

Permalink
feat(candidate): do not show the candidacy dropout page if the CANDID…
Browse files Browse the repository at this point in the history
…ACY_DROP_OUT_CANDIDATE_CONFIRMATION feature is active and the dropout has not been confirmed by the candidate
  • Loading branch information
agarbe committed Dec 23, 2024
1 parent e9a396a commit d056d63
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ context("Accompagnement Autonome Timeline", () => {
"AUTONOME";
cy.intercept("POST", "/api/graphql", (req) => {
stubQuery(req, "candidate_getCandidateWithCandidacy", candidate);
stubQuery(req, "activeFeaturesForConnectedUser", "features.json");
});
});
cy.intercept("POST", "/api/graphql", (req) => {
Expand All @@ -29,6 +30,7 @@ context("Accompagnement Autonome Timeline", () => {
cy.login();
cy.wait("@candidate_login");
cy.wait("@candidate_getCandidateWithCandidacy");
cy.wait("@activeFeaturesForConnectedUser");

cy.get('[data-test="autonome-project-timeline"]').should("exist");
});
Expand Down
18 changes: 17 additions & 1 deletion packages/reva-candidate/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,29 @@ import { ProjectTimeline } from "@/components/legacy/organisms/ProjectTimeline/P
import { useCandidacy } from "@/components/candidacy/candidacy.context";
import { useRouter } from "next/navigation";
import { CandidacyBanner } from "./_components/CandidacyBanner";
import { useFeatureFlipping } from "@/components/feature-flipping/featureFlipping";

export default function Home() {
const { candidate, candidacy } = useCandidacy();
const router = useRouter();
const { isFeatureActive, status } = useFeatureFlipping();

const candidateDropOutConfirmationFeatureActive = isFeatureActive(
"CANDIDACY_DROP_OUT_CANDIDATE_CONFIRMATION",
);

if (status !== "INITIALIZED") {
return null;
}

if (candidacy?.candidacyDropOut) {
router.push("/candidacy-dropout");
if (candidateDropOutConfirmationFeatureActive) {
if (candidacy.candidacyDropOut.dropOutConfirmedByCandidate) {
router.push("/candidacy-dropout");
}
} else {
router.push("/candidacy-dropout");
}
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const GET_CANDIDATE_WITH_CANDIDACY = graphql(`
isCaduque
candidacyDropOut {
createdAt
dropOutConfirmedByCandidate
}
candidacyStatuses {
id
Expand Down

0 comments on commit d056d63

Please sign in to comment.