diff --git a/components/index/cards/mailing-list.js b/components/index/cards/mailing-list.js index cb194793f..306ce9ceb 100644 --- a/components/index/cards/mailing-list.js +++ b/components/index/cards/mailing-list.js @@ -1,199 +1,219 @@ -import Icon from "@hackclub/icons"; -import { useRef, useState } from "react"; -import { Box, Input, Button, Text, Card, Flex, Grid, Link } from "theme-ui"; -import MailCard from "../../mail-card"; -import BGImg from "../../background-image"; +import Icon from '@hackclub/icons' +import {useRef, useState} from 'react' +import { Box, Input, Button, Text, Card, Flex, Grid, Link } from 'theme-ui' +import MailCard from '../../mail-card' +import BGImg from '../../background-image' -import background from "../../../public/home/footer.png"; +import background from '../../../public/home/footer.png' const Loading = () => ( -); +) const MailingList = () => { - const [submitting, setSubmitting] = useState(false); - const [submitted, setSubmitted] = useState(false); - const formRef = useRef(null); + const [submitting, setSubmitting] = useState(false) + const [submitted, setSubmitted] = useState(false) + const [letters, setLetters] = useState([]) + const formRef = useRef(null) const handleSubmit = async (e) => { - e.preventDefault(); - setSubmitting(true); + e.preventDefault() + setSubmitting(true) - let res = await fetch("/api/mailing-list", { - method: "POST", + let res = await fetch('/api/mailing-list', { + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ name: e.target.name.value, email: e.target.email.value, }), - }); + }) - formRef.current.reset(); + formRef.current.reset() if (res.ok) { - setSubmitted(true); + setSubmitted(true) } - setSubmitting(false); - }; + setSubmitting(false) + } + + /* useEffect(() => { + const newsletters = async () => { + const res = await fetch('https://api.github.com/repositories/313119644/contents/updates', { + headers: { + 'Content-Type': 'application/json', + } + }) + + const data = await res.json() + setLetters(data) + } + + newsletters() + }, [])*/ + return ( - + - + Join the newsletter - We’ll send you an email no more than once a month, when we work - on something cool for you. Check out our{" "} - previous issues. + We'll send you an email no more than once a month, when we work + on something cool for you. Check out our{' '} + previous issues. - + - + {submitting ? ( <> Subscribe > ) : submitted ? ( <> - You're on the list! + You're on the list! > ) : ( - "Subscribe" + 'Subscribe' )} + {/* + Read more + */} - ); -}; + ) +} -export default MailingList; +export default MailingList diff --git a/components/mail-card.js b/components/mail-card.js index 91756b757..b30167991 100644 --- a/components/mail-card.js +++ b/components/mail-card.js @@ -1,43 +1,54 @@ -import { Box, Card, Text } from "theme-ui"; -import Link from "next/link"; +import { Box, Card, Text } from 'theme-ui' export default function MailCard({ body, issue, date, link }) { - body = body.length > 80 ? body.substring(0, 80) + "..." : body; + body = body.length > 80 ? body.substring(0, 80) + '...' : body return ( - - + + + - - - {date} - - Newsletter #{issue} — From Hack Club, To You - - {body} - + sx={{ px: [3, 4] }} + > + + + {date} + + Newsletter #{issue} — From Hack Club, To You + + {body} + + - - + + - ); + ) } + +/* + + + + + */