diff --git a/.eslintrc.json b/.eslintrc.json index d51bd66..9d333f3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -35,7 +35,8 @@ "@typescript-eslint/no-unused-vars": [ 2, { - "argsIgnorePattern": "^_" + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" } ], "no-console": [ diff --git a/components/FooterSection.tsx b/components/FooterSection.tsx index db9c2f3..28e5789 100644 --- a/components/FooterSection.tsx +++ b/components/FooterSection.tsx @@ -1,3 +1,4 @@ +import { useState } from 'react' import MangoPill from '../components/MangoPill' import Button from './Button' @@ -6,6 +7,25 @@ const doNothing = (e) => { } const FooterSection = () => { + const [done, setDone] = useState(false) + const [email, setEmail] = useState('') + + const handleChange = (e) => { + setEmail(e.target.value) + } + + const handleSubmit = async (e) => { + e.preventDefault() + + await fetch('/api/signup', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ email }), + }) + + setDone(true) + } + return (
@@ -18,22 +38,30 @@ const FooterSection = () => { -
+ - -
- -
+ {done ? ( + Thank you for signing up! + ) : ( + <> + +
+ +
+ + )}

diff --git a/package.json b/package.json index 458dbcc..0183e05 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@headlessui/react": "^1.0.0", "@heroicons/react": "^1.0.1", "@project-serum/sol-wallet-adapter": "^0.2.0", + "@sendgrid/client": "^7.4.3", "@solana/spl-token": "^0.1.3", "@solana/web3.js": "^1.5.0", "gsap": "^3.7.1", diff --git a/pages/api/hello.ts b/pages/api/hello.ts deleted file mode 100644 index b3be12c..0000000 --- a/pages/api/hello.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -import { NextApiRequest, NextApiResponse } from 'next' - -const handler = (req: NextApiRequest, res: NextApiResponse) => { - res.status(200).json({ name: 'John Doe' }) -} - -export default handler diff --git a/pages/api/signup.ts b/pages/api/signup.ts new file mode 100644 index 0000000..ff3631f --- /dev/null +++ b/pages/api/signup.ts @@ -0,0 +1,26 @@ +import client from '@sendgrid/client' + +const { SENDGRID_API_KEY } = process.env +client.setApiKey(SENDGRID_API_KEY) + +export default async function handler(req, res) { + try { + if (req.method !== 'POST') { + res.status(405).json({ error: 'Method not allowed' }) + return + } + + const { email } = req.body + const request = { + method: 'PUT' as any, + url: '/v3/marketing/contacts', + body: { contacts: [{ email }] }, + } + + const [_, body] = await client.request(request) + res.status(200).send(body) + } catch (e) { + console.error(e) + res.status(500).send(e.toString()) + } +} diff --git a/yarn.lock b/yarn.lock index 795ea0b..ee013d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -824,6 +824,21 @@ bs58 "^4.0.1" eventemitter3 "^4.0.4" +"@sendgrid/client@^7.4.3": + version "7.4.3" + resolved "https://registry.yarnpkg.com/@sendgrid/client/-/client-7.4.3.tgz#bc71aae05de2cd9aa607f4eb1d886711d09f9595" + integrity sha512-tTaHx893w5iqG0sVtUnMyRchuwYF95k4UOkmov1MouMIeMUbNvbalITo7cG7YSXUTY9rT2t4eBY6HcEBCVeqfg== + dependencies: + "@sendgrid/helpers" "^7.4.3" + axios "^0.21.1" + +"@sendgrid/helpers@^7.4.3": + version "7.4.3" + resolved "https://registry.yarnpkg.com/@sendgrid/helpers/-/helpers-7.4.3.tgz#231a4405266cfa291054df8b668fe3a4dc9387aa" + integrity sha512-Wt+68g1sVEM5UspJh34O/cxtv6BBbtAIk7U9B3PB2ySOtPs9e6hI1QkgYVwpNmkt7k2p86muUNyma/Aig25agg== + dependencies: + deepmerge "^4.2.2" + "@sinonjs/commons@^1.7.0": version "1.8.3" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" @@ -1484,6 +1499,13 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== +axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== + dependencies: + follow-redirects "^1.10.0" + babel-jest@^26.6.3: version "26.6.3" resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-26.6.3.tgz#d87d25cb0037577a0c89f82e5755c5d293c01056" @@ -3182,6 +3204,11 @@ flatten@^1.0.2: resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b" integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg== +follow-redirects@^1.10.0: + version "1.14.1" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.1.tgz#d9114ded0a1cfdd334e164e6662ad02bfd91ff43" + integrity sha512-HWqDgT7ZEkqRzBvc2s64vSZ/hfOceEol3ac/7tKwzuvEyWx3/4UegXh5oBOIotkGsObyk3xznnSRVADBgWSQVg== + for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"