Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#48 elections query context #50

Merged
merged 4 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .firebase/hosting.ZGlzdA.cache
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
index.html,1687738745527,016072d1a763c361890ca06a62a7509cec0382e92d1e8e12b7e0e5a53048f1ac
assets/index-8891e0f8.css,1687738745527,1a075d488a7b08e62a37a19d72261dc174ddbfe1f61c1342a2920099475124e3
vite.svg,1687738745365,d3bbbc44b3ea71906a72bf2ec1a4716903e2e3d9f85a5007205a65d1f12e2923
assets/index-12ee572c.js,1687738745527,d261caadfead5a996917ab86646080185c8b095760e73d8b2aa8c676d5173f50
favicon.png,1688159708032,f3c2237334cbc2f8708df1eceaaeac907fac4a7bf117fa24820c3f6f2f1527a8
vite.svg,1688159708032,d3bbbc44b3ea71906a72bf2ec1a4716903e2e3d9f85a5007205a65d1f12e2923
index.html,1688159708161,57754b7fb7c46b0206381ec771f8869b706661e6564aa2f21d651551cee35957
assets/index-8891e0f8.css,1688159708161,1a075d488a7b08e62a37a19d72261dc174ddbfe1f61c1342a2920099475124e3
assets/index-2acb8918.js,1688159708161,d383cc21fd468f50796218728cb2f99f00b299840e31bc209bbc7150448b9284
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Civics Central</title>
</head>
<body>
<div id="root"></div>
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import { WhyVote } from "./Pages/WhyVote/WhyVote.tsx";
import { Example } from "./Pages/Example/Example.tsx";
import { ContactUs } from "./Pages/ContactUs/ContactUs.tsx";
import { Box } from "@mui/material";
import { GlobalContext } from "./context/GlobalContext.tsx";
import { GlobalContextWrapper } from "./context/GlobalContextWrapper.tsx";
import { Footer } from "./components/footer/Footer.tsx";
import { CivicInfo } from "./Pages/CivicInfo/CivicInfo.tsx";

function App() {
return (
<GlobalContext>
<GlobalContextWrapper>
<Box
sx={{
backgroundColor: "background.default",
padding: { xs: "0rem", sm: "2rem" },
padding: "0rem",
}}
>
<Navbar />
Expand All @@ -29,11 +30,13 @@ function App() {
<Route path="/whyvote" element={<WhyVote />} />
<Route path="/example" element={<Example />} />
<Route path="/contactus" element={<ContactUs />} />
<Route path="/civicInformation" element={<CivicInfo />} />
<Route path="*" element={<Home />} />
</Routes>
</Box>
<Footer />
</Box>
</GlobalContext>
</GlobalContextWrapper>
);
}

Expand Down
18 changes: 18 additions & 0 deletions src/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export interface UserData {
};
}

// ================== Representatives Data =====================

export interface RepresentativeDataResponse {
normalizedInput: NormalizedAddressInput;
kind: string;
Expand Down Expand Up @@ -55,3 +57,19 @@ export interface Channel {
type: string;
id: string;
}

// ================== Representatives Data =====================

// ================== Available Elections Data =================
export interface AvailableElectionsDataResponse {
kind: string;
elections: Election[];
}

export interface Election {
id: string;
name: string;
electionDay: string;
ocdDivisionId: string;
}
// ================== Available Elections Data =================
40 changes: 40 additions & 0 deletions src/Pages/CivicInfo/CivicInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Box, Grid, Typography } from "@mui/material";
import {
useAvailableElectionsContext,
useRepresentativeDataContext,
} from "../../context/customHooks.ts";
import { useEffect } from "react";
import { AddressSearchBar } from "../../components/addressSearchBar/AddressSearchBar.tsx";

export const CivicInfo = () => {
const representativeData = useRepresentativeDataContext();
const availableElections = useAvailableElectionsContext();
useEffect(() => {
console.log({ representativeData });
console.log({ availableElections });
}, [representativeData, availableElections]);
return (
<Box>
<AddressSearchBar isHomePage={false} />

<Grid container>
<Grid item md={6} sx={{ border: "3px solid red", width: "100%" }}>
<Typography variant={"h3"}>Representative Data</Typography>
</Grid>
<Grid
item
md={3}
sx={{
border: "3px solid yellow",
width: "100%",
}}
>
<Typography variant={"h3"}>Upcoming Elections</Typography>
</Grid>
<Grid item md={3} xs sx={{ border: "3px solid green", width: "100%" }}>
<Typography variant={"h3"}>Election Info</Typography>
</Grid>
</Grid>
</Box>
);
};
4 changes: 2 additions & 2 deletions src/Pages/Example/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { UserData } from "../../Interfaces.ts";
import axios from "axios";
import { ExampleList } from "./exampleList/ExampleList.tsx";
import { ExampleSearchBar } from "./exampleSearchBar/ExampleSearchBar.tsx";
import { useRepresentativeDataResponse } from "../../context/customHooks.ts";
import { useRepresentativeDataContext } from "../../context/customHooks.ts";

export function Example() {
const [randomUsers, setRandomUsers] = useState<UserData[]>([]);
Expand All @@ -24,7 +24,7 @@ export function Example() {
const theme = useTheme();

// Pulling the representative data from react context
const representativeData = useRepresentativeDataResponse();
const representativeData = useRepresentativeDataContext();

// Check the console to view the theme object
useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/Pages/Home/Home.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { render, screen } from "@testing-library/react";
import { Home } from "./Home.tsx";
import { BrowserRouter } from "react-router-dom";

describe("App", () => {
it("renders headline", () => {
render(<Home />);
render(<Home />, { wrapper: BrowserRouter });

screen.debug();

Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Typography } from "@mui/material";
import { HomePageSearchBar } from "../../components/homepageSearchBar/HomepageSearchBar.tsx";
import { AddressSearchBar } from "../../components/addressSearchBar/AddressSearchBar.tsx";

export function Home() {
return (
Expand All @@ -17,7 +17,7 @@ export function Home() {
Enter your residential address and we'll take it from here!
</Typography>

<HomePageSearchBar />
<AddressSearchBar isHomePage={true} />
<Box
sx={{
display: "flex",
Expand Down
Loading