|
1 | | -import { useEffect } from 'react'; |
| 1 | +import { useEffect, useState } from 'react'; |
2 | 2 | import { useRouter } from 'next/router'; |
3 | 3 | import { gtag } from 'common/utils/thirdParty/gtag'; |
4 | 4 | import Head from 'components/head'; |
5 | 5 | import HeroBanner from 'components/HeroBanner/HeroBanner'; |
6 | 6 | import Content from 'components/Content/Content'; |
7 | 7 | import { RegistrationForm } from 'components/Forms/RegistrationForm/RegistrationForm'; |
| 8 | +import Modal from 'components/Modal/Modal'; |
8 | 9 | import Link from 'next/link'; |
9 | 10 |
|
10 | 11 | const pageTitle = 'Join'; |
11 | 12 |
|
12 | 13 | const profileUpdateURL = '/join/form'; |
13 | 14 |
|
14 | 15 | export default function Join() { |
15 | | - const { prefetch, push } = useRouter(); |
| 16 | + const { prefetch, push, query } = useRouter(); |
| 17 | + const [isErrorModalOpen, setIsErrorModalOpen] = useState(false); |
16 | 18 |
|
17 | 19 | useEffect(() => { |
18 | 20 | prefetch(profileUpdateURL); |
19 | 21 | }, []); |
20 | 22 |
|
| 23 | + useEffect(() => { |
| 24 | + if (query.registrationError) { |
| 25 | + setIsErrorModalOpen(true); |
| 26 | + } |
| 27 | + }, [query.registrationError]); |
| 28 | + |
21 | 29 | const handleSuccess = () => { |
22 | 30 | gtag.conversionEvent({ adId: '9ZvVCOOFmrkBEK-Rnp4D', category: 'sign_up' }); |
23 | 31 | push(profileUpdateURL); |
@@ -50,6 +58,28 @@ export default function Join() { |
50 | 58 | </HeroBanner> |
51 | 59 |
|
52 | 60 | <Content theme="gray" columns={[<RegistrationForm key="form" onSuccess={handleSuccess} />]} /> |
| 61 | + |
| 62 | + <Modal |
| 63 | + isOpen={isErrorModalOpen} |
| 64 | + onRequestClose={() => setIsErrorModalOpen(false)} |
| 65 | + screenReaderLabel="Registration error" |
| 66 | + > |
| 67 | + <div className="space-y-4 text-center max-w-md"> |
| 68 | + <h2 className="text-xl font-bold">Registration Incomplete</h2> |
| 69 | + <p> |
| 70 | + It looks like we're missing information from the first step of registration. Please |
| 71 | + complete the form below to get started. |
| 72 | + </p> |
| 73 | + <p> |
| 74 | + If you've already completed this step and were unexpectedly redirected here, |
| 75 | + something may be wrong on our end. Please email us at{' '} |
| 76 | + <a href="mailto:staff@operationcode.org?subject=Registration Issue"> |
| 77 | + staff@operationcode.org |
| 78 | + </a>{' '} |
| 79 | + so we can help. |
| 80 | + </p> |
| 81 | + </div> |
| 82 | + </Modal> |
53 | 83 | </> |
54 | 84 | ); |
55 | 85 | } |
0 commit comments