-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathHome.tsx
71 lines (64 loc) · 2.76 KB
/
Home.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { useEffect } from "react"
import {
Button,
Center,
Heading,
Text,
Icon,
Input,
ScaleFade,
OrderedList,
Divider,
ListItem,
Spinner,
InputGroup, // Some Chakra components that might be usefull
HStack,
VStack,
InputRightAddon,
} from "@chakra-ui/react"
import { Card } from '@components/design/Card'
import { searchSchoolDistricts, searchSchools, NCESDistrictFeatureAttributes, NCESSchoolFeatureAttributes } from "@utils/nces"
const Home: React.FC = () => {
const [searching, setSearching] = React.useState(false)
const [districtSearch, setDistrictSearch] = React.useState<NCESDistrictFeatureAttributes[]>([]);
const [schoolSearch, setSchoolSearch] = React.useState<NCESSchoolFeatureAttributes[]>([]);
const demo = async () => { // see console for api result examples
setSearching(true)
const demoDistrictSearch = await searchSchoolDistricts("Peninsula School District")
setDistrictSearch(demoDistrictSearch)
console.log("District example", demoDistrictSearch)
const demoSchoolSearch = await searchSchools("k", demoDistrictSearch[1].LEAID)
setSchoolSearch(demoSchoolSearch)
console.log("School Example", demoSchoolSearch)
setSearching(false)
}
useEffect(() => {
demo()
}, [])
return (
<Center padding="100px" height="90vh">
<ScaleFade initialScale={0.9} in={true}>
<Card variant="rounded" borderColor="blue">
<Heading>Ash's School Data Finder</Heading>
<Text>
How would you utilize React.useEffect with the searchSchoolDistricts and searchSchools functions? <br />
Using <a href="https://chakra-ui.com/docs/principles" target="_blank">Chakra-UI</a> or your favorite UI toolkit, build an interface that allows the user to: <br />
<OrderedList>
<ListItem>Search for a district</ListItem>
<ListItem>Search for a school within the district (or bypass district filter)</ListItem>
<ListItem>View all returned data in an organized way</ListItem>
</OrderedList>
</Text>
<Divider margin={4} />
<Text>
Check the console for example of returned data. <b>Happy coding!</b>< br />
{searching ? <Spinner /> : <></>}< br />
{districtSearch.length} Demo Districts<br />
{schoolSearch.length} Demo Schools<br />
</Text>
</Card>
</ScaleFade>
</Center>
);
};
export default Home