From 5dcdfbff377d882f52eaa37421b64a053dd59308 Mon Sep 17 00:00:00 2001 From: Christopher Stevers Date: Fri, 14 Oct 2022 07:56:46 -0400 Subject: [PATCH 1/3] added converkit connected email form --- src/components/footer/index.js | 12 ++++++---- src/components/footer/subscribe.js | 38 ++++++++++++++++++++++++++++++ src/twind.config.js | 3 +++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/components/footer/subscribe.js diff --git a/src/components/footer/index.js b/src/components/footer/index.js index 1a3313d..f51c2e6 100755 --- a/src/components/footer/index.js +++ b/src/components/footer/index.js @@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router'; +import Subscibe from './subscribe'; const Footer = () => { const [showCookieNotice, setShowCookieNotice] = useState(true); @@ -83,9 +84,9 @@ const Footer = () => { OpenQ Logo

OpenQ

-
+
    -
  • +
  • Socials

      @@ -107,7 +108,7 @@ const Footer = () => {
  • -
  • +
  • Resources

      @@ -129,9 +130,9 @@ const Footer = () => {
  • -
  • +
  • -

    About Us

    +

    About Us

+
{/*
diff --git a/src/components/footer/subscribe.js b/src/components/footer/subscribe.js new file mode 100644 index 0000000..7d5924e --- /dev/null +++ b/src/components/footer/subscribe.js @@ -0,0 +1,38 @@ +import { useState } from 'react'; +import { tw } from 'twind'; + +const Subscribe = () => { + const [email, setEmail] = useState(""); + const [subscribed, setSubscribed] = useState(); + + const subscribe = async () => { + const formData = new FormData(); + formData.append("api_key", "JlUKxDNJAmbFF44byOHTNQ"); + formData.append("email", email); + const response = await fetch('https://api.convertkit.com/v3/forms/3697685/subscribe', { + method: "POST", + body: formData + }); + const subscribeJson = await response.json(); + if (subscribeJson) { + setSubscribed(true); + } + + }; + return (
+
+ Sign up for our newsletter.
+ {subscribed ? +
+ Success! Now check your email to confirm your subscription. + +
+ + :
+ setEmail(e.target.value)} className={tw(`rounded-md border-gray-400 w-full sm:w-auto border h-12 px-2 text-black`)} /> + +
} +
+ ); +}; +export default Subscribe; \ No newline at end of file diff --git a/src/twind.config.js b/src/twind.config.js index ff14aa4..616d9a3 100755 --- a/src/twind.config.js +++ b/src/twind.config.js @@ -24,6 +24,9 @@ export default { maxHeight: { '128': '32rem', }, + spacing: { + '128': '32rem' + }, colors: { transparent: 'transparent', 'dark-mode': '#121212', From f5b67cc9ac3d5753edef6c6fc3f6ddfab29474c1 Mon Sep 17 00:00:00 2001 From: Christopher Stevers Date: Fri, 14 Oct 2022 08:02:19 -0400 Subject: [PATCH 2/3] added error state for subscribe --- src/components/footer/subscribe.js | 50 +++++++++++++++++++----------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/src/components/footer/subscribe.js b/src/components/footer/subscribe.js index 7d5924e..07b9009 100644 --- a/src/components/footer/subscribe.js +++ b/src/components/footer/subscribe.js @@ -1,37 +1,51 @@ import { useState } from 'react'; import { tw } from 'twind'; +import { Z_STREAM_ERROR } from 'zlib'; const Subscribe = () => { const [email, setEmail] = useState(""); const [subscribed, setSubscribed] = useState(); + const [error, setError] = useState(); const subscribe = async () => { - const formData = new FormData(); - formData.append("api_key", "JlUKxDNJAmbFF44byOHTNQ"); - formData.append("email", email); - const response = await fetch('https://api.convertkit.com/v3/forms/3697685/subscribe', { - method: "POST", - body: formData - }); - const subscribeJson = await response.json(); - if (subscribeJson) { - setSubscribed(true); + try { + const formData = new FormData(); + formData.append("api_key", "JlUKxDNJAmbFF44byOHTNQ"); + formData.append("email", email); + const response = await fetch('https://api.convertkit.com/v3/forms/3697685/subscribe', { + method: "POST", + body: formData + }); + const subscribeJson = await response.json(); + if (subscribeJson) { + setSubscribed(true); + } } + catch (err) { + setError(err); + } }; return (
Sign up for our newsletter.
- {subscribed ? -
- Success! Now check your email to confirm your subscription. + { + + error ?
+ Couldn't process your subscription, please reload and try again. + +
: + + subscribed ? +
+ Success! Now check your email to confirm your subscription. -
+
- :
- setEmail(e.target.value)} className={tw(`rounded-md border-gray-400 w-full sm:w-auto border h-12 px-2 text-black`)} /> - -
} + :
+ setEmail(e.target.value)} className={tw(`rounded-md border-gray-400 w-full sm:w-auto border h-12 px-2 text-black`)} /> + +
}
); }; From 9dd3a0998bee21346ecff3d045b2cf9980dab982 Mon Sep 17 00:00:00 2001 From: Christopher Stevers Date: Fri, 14 Oct 2022 08:09:33 -0400 Subject: [PATCH 3/3] aligned Hackathon launchpad text --- src/components/footer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/footer/index.js b/src/components/footer/index.js index 26ea0b4..35029dd 100755 --- a/src/components/footer/index.js +++ b/src/components/footer/index.js @@ -137,7 +137,7 @@ const Footer = () => {
  • - +