From 9c4be8dd617866305df4c207e87f60333b8b59d5 Mon Sep 17 00:00:00 2001
From: Arpan Laha
Date: Wed, 19 Aug 2020 21:38:59 +0000
Subject: [PATCH 1/2] move google analytics into _app and change all pages to
function components
---
pages/_app.jsx | 77 +++++++++-------------
pages/about.jsx | 42 +++++-------
pages/apply/index.jsx | 117 ++++++++++++++-------------------
pages/apply/nonprofits.jsx | 80 +++++++++-------------
pages/apply/students.jsx | 79 +++++++++-------------
pages/design.jsx | 15 ++---
pages/index.jsx | 45 +++++--------
pages/projects/[projectId].jsx | 8 +--
pages/projects/index.jsx | 9 +--
9 files changed, 184 insertions(+), 288 deletions(-)
diff --git a/pages/_app.jsx b/pages/_app.jsx
index a9767f4..f5351be 100644
--- a/pages/_app.jsx
+++ b/pages/_app.jsx
@@ -1,51 +1,34 @@
-import React from "react";
-import App from "next/app";
-import ErrorMessage from "../components/errorMessage";
+import React, { useEffect } from "react";
import { PageTransition } from "next-page-transitions";
+import { initializeGA, logPage } from "../components/Analytics";
-export default class MyApp extends App {
- constructor(props) {
- super(props);
- this.state = { hasError: false };
- }
+export default function MyApp({ Component, pageProps }) {
+ useEffect(() => {
+ initializeGA();
+ logPage();
+ }, []);
- componentDidCatch(error, errorInfo) {
- console.error("Page Error Boundary: ", error);
- // This is needed to render errors correctly in development / production
- super.componentDidCatch(error, errorInfo);
- }
-
- render() {
- const { Component, pageProps } = this.props;
- return (
-
-
- {this.state.hasError ? (
-
- ) : (
-
- )}
-
-
-
- );
- }
+ return (
+
+ );
}
diff --git a/pages/about.jsx b/pages/about.jsx
index e17763e..e000ea6 100644
--- a/pages/about.jsx
+++ b/pages/about.jsx
@@ -6,31 +6,21 @@ import Head from "../components/head";
import Nav from "../components/nav";
import Footer from "../components/footer";
import Team from "../components/about/team";
-import { initializeGA, logPage } from "../components/Analytics";
-class AboutPage extends React.Component {
- componentDidMount() {
- initializeGA();
- logPage();
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
- );
- }
+export default function AboutPage() {
+ return (
+
+
+
+
+
+
+
+
+
+ );
}
-
-export default AboutPage;
diff --git a/pages/apply/index.jsx b/pages/apply/index.jsx
index 7b4776a..0141385 100644
--- a/pages/apply/index.jsx
+++ b/pages/apply/index.jsx
@@ -1,76 +1,61 @@
-import React, { Component } from "react";
+import React from "react";
import GradientBanner from "../../components/gradientBanner";
import ActionButton from "../../components/actionButton";
import Head from "../../components/head";
import Nav from "../../components/nav";
import { Container, Row, Col } from "reactstrap";
import Footer from "../../components/footer";
-import { initializeGA, logPage } from "../../components/Analytics";
-class ApplyPage extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
+export default function ApplyPage() {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
- componentDidMount() {
- initializeGA();
- logPage();
- }
+
+
+
+
Students
+
+ Want to apply your skills to benefit the community? Learn
+ how you can build software products that has potential to
+ impact lives alongside a team of motivated and talented
+ peers.
+
+
+
+
- render() {
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Students
-
- Want to apply your skills to benefit the community? Learn
- how you can build software products that has potential to
- impact lives alongside a team of motivated and talented
- peers.
-
-
-
-
-
-
-
-
Nonprofits
-
- Have a core need that your nonprofit wants solved? Learn
- more about our services and how your organization can
- partner with us to support your organization's goals and
- mission.
-
-
-
-
-
-
-
-
-
- >
- );
- }
+
+
+
Nonprofits
+
+ Have a core need that your nonprofit wants solved? Learn
+ more about our services and how your organization can
+ partner with us to support your organization's goals and
+ mission.
+
+
+
+
+
+
+
+
+
+ >
+ );
}
-
-export default ApplyPage;
diff --git a/pages/apply/nonprofits.jsx b/pages/apply/nonprofits.jsx
index 9ba842f..3e288b4 100644
--- a/pages/apply/nonprofits.jsx
+++ b/pages/apply/nonprofits.jsx
@@ -1,4 +1,4 @@
-import React, { Component } from "react";
+import React from "react";
import Faq from "../../components/faq";
import GradientBanner from "../../components/gradientBanner";
import ServicesDetail from "../../components/apply/nonprofit/servicesDetail";
@@ -10,52 +10,36 @@ import Nav from "../../components/nav";
import data from "../../data/ngoApplyData";
import Footer from "../../components/footer";
-import { initializeGA, logPage } from "../../components/Analytics";
-
// TODO: ADD `closed` prop to ApplicationProcess to add text about applications being closed!
-class NonProfits extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
-
- componentDidMount() {
- initializeGA();
- logPage();
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
- );
- }
+export default function NonprofitsApply() {
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
}
-
-export default NonProfits;
diff --git a/pages/apply/students.jsx b/pages/apply/students.jsx
index af6b383..0f4436a 100644
--- a/pages/apply/students.jsx
+++ b/pages/apply/students.jsx
@@ -1,4 +1,4 @@
-import React, { Component } from "react";
+import React from "react";
import ApplicationProcess from "../../components/apply/applicationProcess";
import Quote from "../../components/quote";
import Faq from "../../components/faq";
@@ -7,51 +7,36 @@ import Head from "../../components/head";
import Nav from "../../components/nav";
import Footer from "../../components/footer";
import data from "../../data/studentApplyData";
-import { initializeGA, logPage } from "../../components/Analytics";
-class Students extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
-
- componentDidMount() {
- initializeGA();
- logPage();
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
- );
- }
+export default function StudentsApply() {
+ return (
+
+
+
+
+
+
+
+
+
+ );
}
-
-export default Students;
diff --git a/pages/design.jsx b/pages/design.jsx
index b56f33f..fd00be4 100644
--- a/pages/design.jsx
+++ b/pages/design.jsx
@@ -1,12 +1,9 @@
-import React from "react";
+import React, { useEffect } from "react";
-class Design extends React.Component {
- componentDidMount() {
+export default function Design() {
+ useEffect(() => {
window.location.href = "https://bridge-ui.now.sh";
- }
- render() {
- return <>>;
- }
-}
+ }, []);
-export default Design;
+ return <>>;
+}
diff --git a/pages/index.jsx b/pages/index.jsx
index 7ef963f..d24a96c 100644
--- a/pages/index.jsx
+++ b/pages/index.jsx
@@ -9,35 +9,20 @@ import { ToastContainer } from "react-toastify";
import Head from "../components/head";
import Nav from "../components/nav";
import Footer from "../components/footer";
-import { initializeGA, logPage } from "../components/Analytics";
-class Home extends React.Component {
- componentDidMount() {
- // need to open it once component is mounted bc of "document not found errors"
- // toast( , {
- // className: "announcement",
- // bodyClassName: "announcement-body"
- // });
- initializeGA();
- logPage();
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+export default function Home() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
}
-
-export default Home;
diff --git a/pages/projects/[projectId].jsx b/pages/projects/[projectId].jsx
index 373ce17..0734b20 100644
--- a/pages/projects/[projectId].jsx
+++ b/pages/projects/[projectId].jsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from "react";
+import React from "react";
import { useRouter } from "next/router";
import Head from "../../components/head";
import Nav from "../../components/nav";
@@ -6,18 +6,12 @@ import SpecificProjectPage from "../../components/projects/specificProjectPage";
import ErrorMessage from "../../components/errorMessage";
import Footer from "../../components/footer";
import projectData from "../../data/projectData";
-import { initializeGA, logPage } from "../../components/Analytics";
export default function Projects() {
const {
query: { projectId },
} = useRouter();
- useEffect(() => {
- initializeGA();
- logPage();
- }, []);
-
// return project List (regular project Page) if not query (just /projets)
// else its something like this /project?name=lwb
diff --git a/pages/projects/index.jsx b/pages/projects/index.jsx
index 322b294..b5e42a7 100644
--- a/pages/projects/index.jsx
+++ b/pages/projects/index.jsx
@@ -1,19 +1,12 @@
-import React, { useEffect } from "react";
+import React from "react";
import Head from "../../components/head";
import Nav from "../../components/nav";
import GradientBanner from "../../components/gradientBanner";
import ProjectList from "../../components/projects/projectList";
import ProjectExplore from "../../components/projects/projectExplore";
import Footer from "../../components/footer";
-import { initializeGA, logPage } from "../../components/Analytics";
export default function Projects() {
- useEffect(() => {
- initializeGA();
- logPage();
- }, []);
-
- // return project List (regular project Page) if not query (just /projets)
return (
From 451b838a10de67b03312481e23e0af357487ce4c Mon Sep 17 00:00:00 2001
From: Arpan Laha
Date: Wed, 19 Aug 2020 21:39:40 +0000
Subject: [PATCH 2/2] add _document
---
pages/_document.jsx | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 pages/_document.jsx
diff --git a/pages/_document.jsx b/pages/_document.jsx
new file mode 100644
index 0000000..663227d
--- /dev/null
+++ b/pages/_document.jsx
@@ -0,0 +1,16 @@
+import React from "react";
+import Document, { Head, Html, Main, NextScript } from "next/document";
+
+export default class MyDocument extends Document {
+ render() {
+ return (
+
+
+
+
+
+
+
+ );
+ }
+}