|
1 | | -import { print } from 'graphql'; |
2 | | -import { apiFetch } from '@codeday/topo/utils'; |
3 | | -import { useState, useEffect } from 'react'; |
4 | | -import { useRouter } from 'next/router'; |
5 | | -import LinkedInTag from 'react-linkedin-insight'; |
6 | | -import Box from '@codeday/topo/Atom/Box'; |
7 | | -import Content from '@codeday/topo/Molecule/Content'; |
8 | | -import Image from '@codeday/topo/Atom/Image'; |
9 | | -import CognitoForm from '@codeday/topo/Molecule/CognitoForm'; |
10 | | -import Text, { Heading } from '@codeday/topo/Atom/Text'; |
11 | | -import { useAnalytics } from '@codeday/topo/utils'; |
| 1 | +import { useEffect } from 'react'; |
12 | 2 | import Page from '../../components/Page'; |
13 | | -import { useProgramDates } from '../../providers'; |
14 | | -import { ApplyQuery } from './apply.gql'; |
15 | | -import { DateTime } from 'luxon'; |
16 | 3 |
|
17 | 4 | export default function MentorApplyPage () { |
18 | | - const { goal } = useAnalytics(); |
19 | | - const [hasStarted, setHasStarted] = useState(false); |
20 | | - const { query, isReady } = useRouter(); |
21 | | - const { mentorApplicationWarningAt, mentorApplicationEndsAt } = useProgramDates(); |
22 | | - useEffect(() => typeof window !== 'undefined' && LinkedInTag.init('1831116', null, false), typeof window); |
| 5 | + useEffect(() => { |
| 6 | + if (typeof window === 'undefined') return; |
| 7 | + window.location = 'https://www.codeday.org/volunteer/labs/mentor/go?return=labs&returnto=mentor%2Fshare%3Fapplied'; |
| 8 | + }, [typeof window]); |
23 | 9 |
|
24 | 10 | return ( |
25 | 11 | <Page slug="/mentor/apply" title="Sign Up to Mentor"> |
26 | | - <Content> |
27 | | - <Image |
28 | | - width="100%" |
29 | | - maxHeight="300px" |
30 | | - borderRadius="md" |
31 | | - marginBottom={4} |
32 | | - src="https://img.codeday.org/w=1024;h=300;fit=crop;crop=faces,edges/w/v/wvs5jzy36vt5hw1y71pnn7hsfupbh2v9ew3v7fc4z9otg265zzejg9iq97an9aszfa.jpg" |
33 | | - /> |
34 | | - <Heading as="h2" size="xl" marginBottom={3}>Sign Up to Mentor</Heading> |
35 | | - {mentorApplicationEndsAt < DateTime.local() ? ( |
36 | | - <> |
37 | | - <Text>The mentor application is now closed. Check back for a future cycle of CodeDay Labs.</Text> |
38 | | - </> |
39 | | - ) : ( |
40 | | - <> |
41 | | - {mentorApplicationWarningAt < DateTime.local() && ( |
42 | | - <Box bg="orange.50" borderColor="orange.200" borderWidth={2} borderRadius={2} p={4} mb={4} color="orange.800"> |
43 | | - <Heading as="h3" fontSize="lg" mb={4}>CodeDay Labs starts soon!</Heading> |
44 | | - <Text> |
45 | | - It's not too late to become a mentor, but we'll need to complete an onboarding call to discuss your project |
46 | | - quickly. Please keep a close eye on your email after submitting. |
47 | | - </Text> |
48 | | - </Box> |
49 | | - )} |
50 | | - {isReady && ( |
51 | | - <CognitoForm |
52 | | - formId="57" |
53 | | - prefill={{ Referrer: query.r || '' }} |
54 | | - onFirstPageChange={() => { goal('VA6TNIKN'); setHasStarted(true); }} |
55 | | - onSubmit={() => { |
56 | | - goal('FQKVLN2E'); |
57 | | - LinkedInTag.track('4864865'); |
58 | | - window.location = '/mentor/share?applied'; |
59 | | - }} |
60 | | - /> |
61 | | - )} |
62 | | - </> |
63 | | - )} |
64 | | - </Content> |
65 | 12 | </Page> |
66 | 13 | ); |
67 | 14 | }; |
68 | | - |
69 | | -export async function getStaticProps() { |
70 | | - const data = await apiFetch(print(ApplyQuery)); |
71 | | - |
72 | | - return { |
73 | | - props: { |
74 | | - query: data || {}, |
75 | | - random: Math.random(), |
76 | | - }, |
77 | | - revalidate: 240, |
78 | | - }; |
79 | | -} |
80 | | - |
0 commit comments