diff --git a/README.md b/README.md index aeea428..1490382 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,22 @@ yarn run dev ``` 🚀 The dev site will be running locally at `localhost:3000` 🚀. + +#### Environment +You'll need some credentials to get up and running properly. + +Create a `.env` file in the same directory as your `package.json`, as follows. +```env +DATABASE_URL="postgresql://" +SHADOW_DATABASE_URL="postgresql:// { it("should render the page", () => { - render(); + render( + + + + ); + + const headingArray = screen.getAllByRole("heading"); + + headingArray.map((heading) => { + expect(heading).toBeInTheDocument(); + }); + }); +}); + +describe("Index", () => { + it("should render the page", () => { + render( + + + + ); const headingArray = screen.getAllByRole("heading"); diff --git a/components/FactSnippetsHero.jsx b/components/FactSnippetsHero.jsx index 2dac93f..5c6e916 100644 --- a/components/FactSnippetsHero.jsx +++ b/components/FactSnippetsHero.jsx @@ -1,11 +1,12 @@ +import { signIn, signOut } from "next-auth/react"; + export default function FactSnippetsHero({ subTitle, title, description, cta1, - cta2, cta1Href, - cta2Href, + session, }) { return (
@@ -23,12 +24,14 @@ export default function FactSnippetsHero({ > {cta1} - - {cta2} - + {!!session ? ( + + ) : null}
); diff --git a/components/Hero.jsx b/components/Hero.jsx index 7b5346a..059e848 100644 --- a/components/Hero.jsx +++ b/components/Hero.jsx @@ -1,4 +1,13 @@ -export default function Hero({ heading, subHeading, cta1, cta2, imageSrc }) { +import { signIn, signOut } from "next-auth/react"; + +export default function Hero({ + heading, + subHeading, + cta1, + cta2, + imageSrc, + session, +}) { return (
@@ -15,12 +24,21 @@ export default function Hero({ heading, subHeading, cta1, cta2, imageSrc }) { > {cta1} - - {cta2} - + {!session ? ( + + ) : ( + + )}
diff --git a/components/MobileNavbar.jsx b/components/MobileNavbar.jsx index 5bc7bae..162ab24 100644 --- a/components/MobileNavbar.jsx +++ b/components/MobileNavbar.jsx @@ -4,6 +4,7 @@ export default function MobileNavbar({ navigationLinks, navigationHrefs, cta, + session, }) { return (
diff --git a/components/Navbar.jsx b/components/Navbar.jsx index c690deb..40d49ea 100644 --- a/components/Navbar.jsx +++ b/components/Navbar.jsx @@ -1,10 +1,12 @@ import NavigationItem from "./NavigationItem"; +import { signIn, signOut } from "next-auth/react"; export default function Navbar({ entityTitle, navigationLinks, navigationHrefs, cta, + session, }) { return ( ); } diff --git a/components/Sections/FactSnippets.jsx b/components/Sections/FactSnippets.jsx index 2717086..ecffef7 100644 --- a/components/Sections/FactSnippets.jsx +++ b/components/Sections/FactSnippets.jsx @@ -9,6 +9,7 @@ export default function FactSnippets({ cta1Href, cta2Href, factSnippetsCardContent, + session, }) { return (
diff --git a/components/Sections/NavigationHero.jsx b/components/Sections/NavigationHero.jsx index eabfef7..b60fe6f 100644 --- a/components/Sections/NavigationHero.jsx +++ b/components/Sections/NavigationHero.jsx @@ -7,6 +7,7 @@ export default function NavigationHero({ navigationLinks, navigationHrefs, cta, + session, }) { return (
); diff --git a/package.json b/package.json index a72e0d5..26c9adf 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "react-dom": "^17.0.2" }, "devDependencies": { + "@next-auth/prisma-adapter": "^1.0.1", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "autoprefixer": "^10.4.2", @@ -23,6 +24,8 @@ "jwt-decode": "^3.1.2", "localforage": "^1.10.0", "nanoid": "^3.2.0", + "next-auth": "^4.1.2", + "nodemailer": "^6.7.2", "postcss": "^8.4.5", "prisma": "^3.8.1", "swr": "^1.2.0", diff --git a/pages/_app.jsx b/pages/_app.jsx index 49523e5..5caec75 100644 --- a/pages/_app.jsx +++ b/pages/_app.jsx @@ -1,7 +1,12 @@ import "../styles/global.css"; +import { SessionProvider } from "next-auth/react"; -function MyApp({ Component, pageProps }) { - return ; +function MyApp({ Component, pageProps: { session, ...pageProps } }) { + return ( + + + + ); } export default MyApp; diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js new file mode 100644 index 0000000..0871f16 --- /dev/null +++ b/pages/api/auth/[...nextauth].js @@ -0,0 +1,19 @@ +import {PrismaAdapter} from "@next-auth/prisma-adapter" +import {PrismaClient} from "@prisma/client" +import NextAuth from "next-auth" +import EmailProvider from "next-auth/providers/email" + +const prisma = new PrismaClient() + +export default NextAuth({ + adapter : PrismaAdapter(prisma), + secret : process.env.NEXTAUTH_SECRET, + providers : [ + EmailProvider({ + server : process.env.EMAIL_SERVER, + from : process.env.FROM_EMAIL || 'investors@tincre.com', + maxAge : 600, // in seconds + }), + ], + debug : false, +}) diff --git a/pages/index.jsx b/pages/index.jsx index db4b2e3..3352242 100644 --- a/pages/index.jsx +++ b/pages/index.jsx @@ -1,5 +1,6 @@ import { useState, useRef, useEffect } from "react"; import { fetcher, clientJwtDecode } from "../lib/utils"; +import { useSession, signIn, signOut } from "next-auth/react"; import localforage from "localforage"; import useSwr, { mutate } from "swr"; import Footer from "../components/Footer"; @@ -39,6 +40,7 @@ export default function Funded() { const [inputError, setInputError] = useState(false); const [message, setMessage] = useState(""); const [subscribed, setSubscribed] = useState(false); + const { data: session, status } = useSession(); const hostname = "investor.tincre.com"; const subscribe = async (e) => { e.preventDefault(); @@ -149,40 +151,46 @@ export default function Funded() { navigationLinks={navigationLinks} navigationHrefs={navigationHrefs} cta={cta} + session={session} /> - - - - - - - + {!session ? null : ( + <> + + + + + + + + + )}