Skip to content

Commit 8e6f495

Browse files
committed
Add verify page
1 parent 509c9a4 commit 8e6f495

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

src/pages/dash/mm/[token]/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default function MentorDashboard() {
9595
<Button as="a" fontSize="sm" href={`/dash/mm/${query.token}/students`} target="_blank" mb={8} mr={4}>
9696
All Students &raquo;
9797
</Button>
98-
<Button as="a" fontSize="sm" href={`/dash/mm/${query.token}/status`} target="_blank" mb={8}>
98+
<Button as="a" fontSize="sm" href={`/dash/mm/${query.token}/status`} target="_blank" mb={8} mr={4}>
9999
Student Reflections &raquo;
100100
</Button>
101101
<Button as="a" fontSize="sm" href={`/dash/mm/${query.token}/mentor-surveys`} target="_blank" mb={8}>

src/pages/verify.gql

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
query VerifyQuery ($givenName: String!, $surname: String!) {
2+
labs {
3+
employmentRecords(givenName: $givenName, surname: $surname) {
4+
start
5+
end
6+
eligibleForRehire
7+
title
8+
mentors
9+
}
10+
}
11+
}

src/pages/verify.js

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)