|
| 1 | +import { apiFetch } from '@codeday/topo/utils'; |
| 2 | +import { TextInput as Input, Button, Box, Heading, Text, Divider, Grid } from '@codeday/topo/Atom'; |
| 3 | +import { Content } from '@codeday/topo/Molecule'; |
| 4 | +import Page from '../components/Page'; |
| 5 | +import { useState } from 'react'; |
| 6 | +import { VerifyQuery } from './verify.gql'; |
| 7 | +import { DateTime } from 'luxon'; |
| 8 | + |
| 9 | +export default function Verify() { |
| 10 | + const [givenName, setGivenName] = useState(); |
| 11 | + const [surname, setSurname] = useState(); |
| 12 | + const [isLoading, setIsLoading] = useState(false); |
| 13 | + const [results, setResults] = useState(null); |
| 14 | + |
| 15 | + return ( |
| 16 | + <Page slug="/verify" title="Verify"> |
| 17 | + <Content mt={-8}> |
| 18 | + <Heading as="h2" mb={8}>Verify</Heading> |
| 19 | + <Grid templateColumns="1fr 1fr" gap={4}> |
| 20 | + <Box> |
| 21 | + <Text display="block" fontSize="xs" fontWeight="bold">Given Name</Text> |
| 22 | + <Input onChange={(e) => setGivenName(e.target.value)} value={givenName} placeholder="Given Name" /> |
| 23 | + </Box> |
| 24 | + <Box> |
| 25 | + <Text display="block" fontSize="xs" fontWeight="bold">Surname</Text> |
| 26 | + <Input onChange={(e) => setSurname(e.target.value)} value={surname} placeholder="Surname" /> |
| 27 | + </Box> |
| 28 | + </Grid> |
| 29 | + <Button |
| 30 | + isLoading={isLoading} |
| 31 | + onClick={async () => { |
| 32 | + setIsLoading(true); |
| 33 | + try { |
| 34 | + const result = await apiFetch(VerifyQuery, { |
| 35 | + givenName, surname, |
| 36 | + }); |
| 37 | + setResults(result?.labs?.employmentRecords || []); |
| 38 | + } catch (ex) { |
| 39 | + console.error(ex); |
| 40 | + setResults([]); |
| 41 | + } |
| 42 | + setIsLoading(false); |
| 43 | + }} |
| 44 | + > |
| 45 | + Search |
| 46 | + </Button> |
| 47 | + {results !== null && ( |
| 48 | + <Box> |
| 49 | + <Divider mt={8} mb={8} /> |
| 50 | + {results.length === 0 ? ( |
| 51 | + <Text>No results found. Please email us at [email protected] to verify. </Text> |
| 52 | + ) : results.map((r) => ( |
| 53 | + <Box> |
| 54 | + <Text><strong>Title:</strong> {r.title}</Text> |
| 55 | + <Text><strong>Start:</strong> {DateTime.fromISO(r.start).toLocaleString(DateTime.DATE_FULL)}</Text> |
| 56 | + <Text><strong>End:</strong> {DateTime.fromISO(r.end).toLocaleString(DateTime.DATE_FULL)}</Text> |
| 57 | + <Text><strong>Supervisor: </strong> Tyler Menezes ( [email protected], 888-607-7763 ext 5001) </Text> |
| 58 | + <Text><strong>Mentor{r.mentors.length > 0 ? 's': ''}:</strong> {r.mentors.join(', ')}</Text> |
| 59 | + <Text><strong>Eligible for rehire?</strong> {r.eligibleForRehire ? 'yes' : 'no'}</Text> |
| 60 | + </Box> |
| 61 | + ))} |
| 62 | + </Box> |
| 63 | + )} |
| 64 | + </Content> |
| 65 | + </Page> |
| 66 | + ); |
| 67 | +} |
| 68 | + |
0 commit comments