Skip to content

Commit

Permalink
VKT(Frontend): OPHVKTKEH-205 viewing payment fail or done steps witho…
Browse files Browse the repository at this point in the history
…ut existing enrollment blocked
  • Loading branch information
mikhuttu committed Aug 16, 2023
1 parent c768ee6 commit b3f4e54
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router';

import { Authenticate } from 'components/publicEnrollment/steps/Authenticate';
import { Done } from 'components/publicEnrollment/steps/Done';
import { FillContactDetails } from 'components/publicEnrollment/steps/FillContactDetails';
import { PaymentFail } from 'components/publicEnrollment/steps/PaymentFail';
import { PaymentSuccess } from 'components/publicEnrollment/steps/PaymentSuccess';
import { Preview } from 'components/publicEnrollment/steps/Preview';
import { SelectExam } from 'components/publicEnrollment/steps/SelectExam';
import { AppRoutes } from 'enums/app';
import { PublicEnrollmentFormStep } from 'enums/publicEnrollment';
import { PublicEnrollment } from 'interfaces/publicEnrollment';
import { PublicExamEvent } from 'interfaces/publicExamEvent';
Expand All @@ -26,6 +30,14 @@ export const PublicEnrollmentStepContents = ({
showValidation: boolean;
examEvent: PublicExamEvent;
}) => {
const navigate = useNavigate();

useEffect(() => {
if (activeStep >= PublicEnrollmentFormStep.Payment && !enrollment.id) {
navigate(AppRoutes.PublicHomePage);
}
}, [activeStep, enrollment.id, navigate]);

switch (activeStep) {
case PublicEnrollmentFormStep.Authenticate:
return <Authenticate examEvent={examEvent} />;
Expand Down

0 comments on commit b3f4e54

Please sign in to comment.