From 99c6753a0c8061f478c5370425f669b7fc716129 Mon Sep 17 00:00:00 2001 From: Mike Dial Date: Mon, 6 Nov 2023 11:09:06 -0500 Subject: [PATCH] Abstract per kevin --- .../ui/src/pages/form/medicaid-form.tsx | 181 ++++++++++-------- 1 file changed, 98 insertions(+), 83 deletions(-) diff --git a/src/services/ui/src/pages/form/medicaid-form.tsx b/src/services/ui/src/pages/form/medicaid-form.tsx index 0717438c04..618b3d6166 100644 --- a/src/services/ui/src/pages/form/medicaid-form.tsx +++ b/src/services/ui/src/pages/form/medicaid-form.tsx @@ -109,7 +109,6 @@ export const MedicaidForm = () => { }); const { data: user } = useGetUser(); stateCodes = getUserStateCodes(user?.user); - const navigate = useNavigate(); const handleSubmit: SubmitHandler = async (data) => { const uploadKeys = Object.keys(data.attachments) as UploadKeys[]; @@ -179,62 +178,11 @@ export const MedicaidForm = () => { body: dataToSubmit, }); console.log(submissionResponse); - setModalChildren( -
-
-
Submission Success!
-

- {data.id} was successfully submitted. -
- Please be aware that it may take up to a minute for your - submission to show in the Dashboard. -

-
- navigate(ROUTES.DASHBOARD)} - > - Go to Dashboard - -
- ); + setModalChildren(); } catch (err) { console.log(err); setModalChildren( -
-
-
Submission Error:
-

- An error occurred during submission. -
- You may close this window and try again, however, this likely - requires support. -
-
- Please contact the{" "} - - helpdesk - {" "} - . You may include the following in your support request:
-
-

    -
  • SPA ID: {data.id}
  • -
  • Timestamp: {Date.now()}
  • -
-

-
- setModalIsOpen(false)} - > - Close - -
+ ); } finally { setModalIsOpen(true); @@ -446,35 +394,9 @@ export const MedicaidForm = () => { showModal={cancelModalIsOpen} // eslint-disable-next-line react/no-children-prop children={ -
-
-
- Are you sure you want to cancel? -
-

- If you leave this page, you will lose your progress on - this form. -

-
-
- navigate(ROUTES.DASHBOARD)} - > - Yes - -
- setCancelModalIsOpen(false)} - > - No, Return to Form - -
-
-
+ } /> @@ -483,3 +405,96 @@ export const MedicaidForm = () => { ); }; +type SuccessModalProps = { id: string }; +const SuccessModalContent = ({ id }: SuccessModalProps) => { + const navigate = useNavigate(); + return ( +
+
+
Submission Success!
+

+ {id} was successfully submitted. +
+ Please be aware that it may take up to a minute for your submission to + show in the Dashboard. +

+
+ navigate(ROUTES.DASHBOARD)} + > + Go to Dashboard + +
+ ); +}; +type ErrorModalProps = { id: string; setModalIsOpen: (open: boolean) => void }; +const ErrorModalContent = ({ id, setModalIsOpen }: ErrorModalProps) => { + return ( +
+
+
Submission Error:
+

+ An error occurred during submission. +
+ You may close this window and try again, however, this likely requires + support. +
+
+ Please contact the{" "} + + helpdesk + {" "} + . You may include the following in your support request:
+
+

    +
  • SPA ID: {id}
  • +
  • Timestamp: {Date.now()}
  • +
+

+
+ setModalIsOpen(false)} + > + Close + +
+ ); +}; + +type CancelModalProps = { setCancelModalIsOpen: (open: boolean) => void }; +const CancelModalContent = ({ setCancelModalIsOpen }: CancelModalProps) => { + const navigate = useNavigate(); + return ( +
+
+
Are you sure you want to cancel?
+

If you leave this page, you will lose your progress on this form.

+
+
+ navigate(ROUTES.DASHBOARD)} + > + Yes + +
+ setCancelModalIsOpen(false)} + > + No, Return to Form + +
+
+
+ ); +};