From d39490018d5f8c05e13cdfc894812cf034f5286b Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:51:12 +0300 Subject: [PATCH 1/7] Refractored shared pageheader --- .gitignore | 2 + .../{Air/AirHeader.js => PageHeader/index.js} | 6 +-- src/pages/[type].js | 6 +-- src/pages/air/index.js | 4 +- src/pages/water/index.js | 47 +++++++++++++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) rename src/components/{Air/AirHeader.js => PageHeader/index.js} (88%) create mode 100644 src/pages/water/index.js diff --git a/.gitignore b/.gitignore index aae5c203..ef715b15 100644 --- a/.gitignore +++ b/.gitignore @@ -331,3 +331,5 @@ $RECYCLE.BIN/ .now # End of Custom + +.yarn \ No newline at end of file diff --git a/src/components/Air/AirHeader.js b/src/components/PageHeader/index.js similarity index 88% rename from src/components/Air/AirHeader.js rename to src/components/PageHeader/index.js index b4ac8beb..68e560db 100644 --- a/src/components/Air/AirHeader.js +++ b/src/components/PageHeader/index.js @@ -16,7 +16,7 @@ const useStyles = makeStyles((theme) => ({ }, })); -function AirHeader({ handleSearch, ...props }) { +function PageHeader({ handleSearch, ...props }) { const classes = useStyles(props); return ( @@ -33,8 +33,8 @@ function AirHeader({ handleSearch, ...props }) { ); } -AirHeader.propTypes = { +PageHeader.propTypes = { handleSearch: PropTypes.func.isRequired, }; -export default AirHeader; +export default PageHeader; diff --git a/src/pages/[type].js b/src/pages/[type].js index cddbc479..477e144f 100644 --- a/src/pages/[type].js +++ b/src/pages/[type].js @@ -22,11 +22,7 @@ SensorTypeHome.propTypes = { export async function getStaticPaths() { return { - paths: [ - { params: { type: "radiation" } }, - { params: { type: "sound" } }, - { params: { type: "water" } }, - ], + paths: [{ params: { type: "radiation" } }, { params: { type: "sound" } }], fallback: false, }; } diff --git a/src/pages/air/index.js b/src/pages/air/index.js index 3068b6df..991a0aa7 100644 --- a/src/pages/air/index.js +++ b/src/pages/air/index.js @@ -2,13 +2,13 @@ import { useRouter } from "next/router"; import React from "react"; import Stories from "@/sensorsafrica/components/About/Stories"; -import AirHeader from "@/sensorsafrica/components/Air/AirHeader"; import IndoorOutdoor from "@/sensorsafrica/components/Air/IndoorOutdoor"; import Issues from "@/sensorsafrica/components/Air/Issues"; import DocumentHead from "@/sensorsafrica/components/DocumentHead"; import { URLS } from "@/sensorsafrica/components/DocumentHead/PageHeads"; import Footer from "@/sensorsafrica/components/Footer"; import Navbar from "@/sensorsafrica/components/Header/Navbar"; +import PageHeader from "@/sensorsafrica/components/PageHeader"; import PartnerLogos from "@/sensorsafrica/components/PartnerLogos"; import Showcase from "@/sensorsafrica/components/Showcase"; import Support from "@/sensorsafrica/components/Support"; @@ -30,7 +30,7 @@ function AirHome() { <> - + diff --git a/src/pages/water/index.js b/src/pages/water/index.js new file mode 100644 index 00000000..069a9ff8 --- /dev/null +++ b/src/pages/water/index.js @@ -0,0 +1,47 @@ +import { useRouter } from "next/router"; +import React from "react"; + +import Stories from "@/sensorsafrica/components/About/Stories"; +import IndoorOutdoor from "@/sensorsafrica/components/Air/IndoorOutdoor"; +import Issues from "@/sensorsafrica/components/Air/Issues"; +import DocumentHead from "@/sensorsafrica/components/DocumentHead"; +import { URLS } from "@/sensorsafrica/components/DocumentHead/PageHeads"; +import Footer from "@/sensorsafrica/components/Footer"; +import Navbar from "@/sensorsafrica/components/Header/Navbar"; +import PageHeader from "@/sensorsafrica/components/PageHeader"; +import PartnerLogos from "@/sensorsafrica/components/PartnerLogos"; +import Showcase from "@/sensorsafrica/components/Showcase"; +import Support from "@/sensorsafrica/components/Support"; +import About from "@/sensorsafrica/pages/air/about"; +import Data from "@/sensorsafrica/pages/air/data"; +import HealthAndClimateImpacts from "@/sensorsafrica/pages/air/health-and-climate-impact"; +import HowSensorsWork from "@/sensorsafrica/pages/air/how-sensors-work"; +import JoinNetwork from "@/sensorsafrica/pages/air/join-network"; + +const CITY_PATHNAME = "/water/city"; + +function AirHome() { + const router = useRouter(); + const handleSearch = (city) => { + router.push(`${CITY_PATHNAME}/${city.value}`); + }; + + return ( + <> + + + + + + + + + +