email signup connected
This commit is contained in:
parent
ff37a07fa0
commit
8c68ebbaa3
|
@ -35,7 +35,8 @@
|
|||
"@typescript-eslint/no-unused-vars": [
|
||||
2,
|
||||
{
|
||||
"argsIgnorePattern": "^_"
|
||||
"argsIgnorePattern": "^_",
|
||||
"varsIgnorePattern": "^_"
|
||||
}
|
||||
],
|
||||
"no-console": [
|
||||
|
|
|
@ -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 (
|
||||
<div className="bg-bg-texture bg-cover bg-bottom bg-no-repeat">
|
||||
<div className="max-w-7xl mx-auto ">
|
||||
|
@ -18,22 +38,30 @@ const FooterSection = () => {
|
|||
</span>
|
||||
</h2>
|
||||
|
||||
<form className="mt-8 sm:flex">
|
||||
<form className="mt-8 sm:flex" onSubmit={handleSubmit}>
|
||||
<label className="sr-only">Email address</label>
|
||||
<input
|
||||
id="email-address"
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
required
|
||||
className="w-full px-5 py-2 placeholder-gray-400 text-black text-opacity-80 sm:max-w-xs border-gray-300 rounded-full focus:outline-none"
|
||||
placeholder="Drop us your email..."
|
||||
/>
|
||||
<div className="mt-3 rounded-md shadow sm:mt-0 sm:ml-3 sm:flex-shrink-0">
|
||||
<Button>
|
||||
<span className="">Sign me up!</span>
|
||||
</Button>
|
||||
</div>
|
||||
{done ? (
|
||||
<span>Thank you for signing up!</span>
|
||||
) : (
|
||||
<>
|
||||
<input
|
||||
id="email-address"
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
required
|
||||
className="w-full px-5 py-2 placeholder-gray-400 text-black text-opacity-80 sm:max-w-xs border-gray-300 rounded-full focus:outline-none"
|
||||
placeholder="Drop us your email..."
|
||||
value={email}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<div className="mt-3 rounded-md shadow sm:mt-0 sm:ml-3 sm:flex-shrink-0">
|
||||
<Button>
|
||||
<span className="">Sign me up!</span>
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</form>
|
||||
<div className="w-full mt-4">
|
||||
<p className="text-xl text-gray-400">
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
|
@ -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())
|
||||
}
|
||||
}
|
27
yarn.lock
27
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"
|
||||
|
|
Loading…
Reference in New Issue