From 25c20e779ce373cccaf8aeea2de5cb1a6001deb3 Mon Sep 17 00:00:00 2001 From: bowenzhu1 Date: Mon, 28 Aug 2023 06:02:07 -0400 Subject: [PATCH] change review form to allow return to dashboard --- .../src/components/dashboard/StatusModal.tsx | 3 +- .../src/components/intake/ReviewCaseForm.tsx | 71 +++++++------------ frontend/src/components/pages/IntakePage.tsx | 12 +++- frontend/src/contexts/IntakeValueContext.tsx | 8 +++ 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/frontend/src/components/dashboard/StatusModal.tsx b/frontend/src/components/dashboard/StatusModal.tsx index c0b0a11cf..5cec75f60 100644 --- a/frontend/src/components/dashboard/StatusModal.tsx +++ b/frontend/src/components/dashboard/StatusModal.tsx @@ -52,6 +52,7 @@ const StatusModal = ({ const { setStep, + setIsReviewOnly, setReferralDetails, setCourtDetails, setProgramDetails, @@ -89,7 +90,7 @@ const StatusModal = ({ setReferralDetails(mockReferralDetails); setCourtDetails(mockCourtDetails); setProgramDetails(mockProgramDetails); - + setIsReviewOnly(true); goToIntake(); } return ( diff --git a/frontend/src/components/intake/ReviewCaseForm.tsx b/frontend/src/components/intake/ReviewCaseForm.tsx index 64cc72f84..81419c46e 100644 --- a/frontend/src/components/intake/ReviewCaseForm.tsx +++ b/frontend/src/components/intake/ReviewCaseForm.tsx @@ -18,6 +18,8 @@ type ReviewFormProps = { nextStep: () => void; setStep: React.Dispatch>; setReviewHeader: React.Dispatch>; + isReviewOnly: boolean; + setIsReviewOnly: React.Dispatch>; }; const ReviewForm = ({ @@ -30,11 +32,30 @@ const ReviewForm = ({ nextStep, setStep, setReviewHeader, + isReviewOnly, + setIsReviewOnly, }: ReviewFormProps): React.ReactElement => { const onNextStep = () => { nextStep(); // TODO: Add functionality for nextStep (Currently we pass in empty nextStep() prop) }; + const editSectionButton = (targetStep: IntakeSteps): React.ReactElement => { + return ( + + ); + }; + return ( <> @@ -42,17 +63,7 @@ const ReviewForm = ({ Case referral - + {editSectionButton(IntakeSteps.CASE_REFERRAL)}; Court information - + {editSectionButton(IntakeSteps.COURT_INFORMATION)}; Individual details - + {editSectionButton(IntakeSteps.INDIVIDUAL_DETAILS)}; @@ -118,17 +109,7 @@ const ReviewForm = ({ Program details - + {editSectionButton(IntakeSteps.PROGRAM_DETAILS)}; true} // TODO: validate form registrationLoading={false} nextStepCallBack={onNextStep} diff --git a/frontend/src/components/pages/IntakePage.tsx b/frontend/src/components/pages/IntakePage.tsx index 8e6a65ac3..c46946b8d 100644 --- a/frontend/src/components/pages/IntakePage.tsx +++ b/frontend/src/components/pages/IntakePage.tsx @@ -38,6 +38,7 @@ const Intake = (): React.ReactElement => { } = useDisclosure(); const { step, setStep } = useStepValueContext(); + const { isReviewOnly, setIsReviewOnly } = useStepValueContext(); const [reviewHeader, setReviewHeader] = useState(false); const { referralDetails, setReferralDetails } = useStepValueContext(); const { courtDetails, setCourtDetails } = useStepValueContext(); @@ -52,7 +53,14 @@ const Intake = (): React.ReactElement => { const [allProviders, setAllProviders] = useState([]); const [selectedIndexChild, setSelectedIndexChild] = useState(-1); - const nextStep = () => setStep(step + 1); + const nextStep = () => { + if (isReviewOnly) { + setIsReviewOnly(false); + history.push("/"); + } else { + setStep(step + 1); + } + }; const renderDetailsForm = () => { switch (step) { @@ -116,6 +124,8 @@ const Intake = (): React.ReactElement => { nextStep={nextStep} setStep={setStep} setReviewHeader={setReviewHeader} + isReviewOnly={isReviewOnly} + setIsReviewOnly={setIsReviewOnly} /> ); diff --git a/frontend/src/contexts/IntakeValueContext.tsx b/frontend/src/contexts/IntakeValueContext.tsx index 75036d884..a7039f512 100644 --- a/frontend/src/contexts/IntakeValueContext.tsx +++ b/frontend/src/contexts/IntakeValueContext.tsx @@ -16,6 +16,8 @@ interface IntakeValueProviderProps { interface IntakeStepContext { step: number; setStep: React.Dispatch>; + isReviewOnly: boolean; + setIsReviewOnly: React.Dispatch>; referralDetails: ReferralDetails; setReferralDetails: React.Dispatch>; courtDetails: CourtDetails; @@ -27,6 +29,8 @@ interface IntakeStepContext { const StepValueContext = createContext({ step: 0, setStep: () => {}, + isReviewOnly: false, + setIsReviewOnly: () => {}, referralDetails: DEFAULT_REFFERAL_DETAILS, setReferralDetails: () => {}, courtDetails: DEFAULT_COURT_DETAILS, @@ -44,6 +48,7 @@ export const IntakeValueProvider: React.FC = ({ }: IntakeValueProviderProps) => { const location = useLocation(); + const [isReviewOnly, setIsReviewOnly] = useState(false); const [referralDetails, setReferralDetails] = useState( DEFAULT_REFFERAL_DETAILS, ); @@ -59,6 +64,7 @@ export const IntakeValueProvider: React.FC = ({ useEffect(() => { if (step !== reviewCaseDetailsStep) { setStep(0); + setIsReviewOnly(false); setReferralDetails(DEFAULT_REFFERAL_DETAILS); setCourtDetails(DEFAULT_COURT_DETAILS); setProgramDetails(DEFAULT_PROGRAM_DETAILS); @@ -69,6 +75,8 @@ export const IntakeValueProvider: React.FC = ({ const intakeValues = { step, setStep, + isReviewOnly, + setIsReviewOnly, referralDetails, setReferralDetails, courtDetails,