Skip to content

Commit

Permalink
[#48] removing border, adding bug fix for disabling serch button, add…
Browse files Browse the repository at this point in the history
…ing navigate
  • Loading branch information
cfech committed Jun 30, 2023
1 parent d3ea7aa commit feeeeb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function App() {
<Box
sx={{
backgroundColor: "background.default",
padding: { xs: "0rem", sm: "2rem" },
padding: "0rem",
}}
>
<Navbar />
Expand Down
9 changes: 8 additions & 1 deletion src/components/homepageSearchBar/HomepageSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
useRepresentativeDataResponse,
useSetRepresentativeDataResponse,
} from "../../context/customHooks.ts";
import { useNavigate } from "react-router-dom";

const placeholders = [
"740 S. Magnolia Rd, Gastonia, NC 28052",
Expand Down Expand Up @@ -43,7 +44,12 @@ export const HomePageSearchBar: React.FC = () => {

// =================== React Hooks ===================

useEffect(() => {
console.log(searchBarValue);
}, [searchBarValue]);

const representativeDataResponse = useRepresentativeDataResponse();
const navigate = useNavigate();

// TODO - figure out what type this should be
const setRepresentativeDataResponse: any = useSetRepresentativeDataResponse();
Expand Down Expand Up @@ -91,6 +97,7 @@ export const HomePageSearchBar: React.FC = () => {
.then((res) => {
console.log(res);
setRepresentativeDataResponse(res.data);
navigate("/example");
})
.catch((err) => {
console.log(err);
Expand Down Expand Up @@ -140,7 +147,7 @@ export const HomePageSearchBar: React.FC = () => {
color="primary"
startIcon={<HowToVoteIcon />}
onClick={handleClick}
disabled={buttonIsDisabled || searchBarValue.length === 0}
disabled={buttonIsDisabled || searchBarValue.trim().length === 0}
>
Find my elections info!
</Button>
Expand Down
2 changes: 2 additions & 0 deletions src/context/customHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
SetRepresentativeDataResponseContext,
} from "./RepresentativeDataContext.tsx";

// This is a utility file for custom hooks

// ==================== Custom React Hooks ====================
// 1 custom hook per context in order to expose it to consumer component
export const useColorMode = () => {
Expand Down

0 comments on commit feeeeb3

Please sign in to comment.