try now
This commit is contained in:
parent
08a3a666a7
commit
590d27be33
@ -1,8 +1,6 @@
|
||||
import clsx from 'clsx'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useTheme } from 'next-themes'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { ArrowLink } from '~/components/icons/arrow'
|
||||
import { LogoFooter } from '~/components/icons/logo'
|
||||
import {
|
||||
Discord,
|
||||
@ -15,73 +13,12 @@ import {
|
||||
Youtube
|
||||
} from '~/components/icons/socials'
|
||||
import { Container } from '~/components/layout/container'
|
||||
import Heading from '~/components/primitives/heading'
|
||||
import Link from '~/components/primitives/link'
|
||||
import Switch from '~/components/primitives/switch'
|
||||
import { useIsomorphicLayoutEffect } from '~/hooks/use-isomorphic-layout-effect'
|
||||
|
||||
import s from './footer.module.scss'
|
||||
|
||||
type FormProps = {
|
||||
className?: string
|
||||
message: string
|
||||
onSubmitted?: ({ EMAIL }: { EMAIL: string }) => void
|
||||
status: 'success' | 'error' | 'sending'
|
||||
style?: React.CSSProperties
|
||||
}
|
||||
|
||||
const SimpleForm = ({
|
||||
className,
|
||||
message,
|
||||
onSubmitted,
|
||||
status,
|
||||
style
|
||||
}: FormProps) => {
|
||||
let input: HTMLInputElement | null
|
||||
|
||||
const submit = (e: any) => {
|
||||
e.preventDefault()
|
||||
if (!onSubmitted) return
|
||||
input &&
|
||||
input.value.indexOf('@') > -1 &&
|
||||
onSubmitted({
|
||||
EMAIL: input.value
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!input) return
|
||||
if (status === 'success') {
|
||||
input.value = ''
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [status])
|
||||
|
||||
return (
|
||||
<div className={clsx(s['form'], className)} style={style}>
|
||||
{status === 'sending' && <div>sending...</div>}
|
||||
{status === 'error' && (
|
||||
<div dangerouslySetInnerHTML={{ __html: message }} />
|
||||
)}
|
||||
{status === 'success' && (
|
||||
<div dangerouslySetInnerHTML={{ __html: message }} />
|
||||
)}
|
||||
<form action="/" onSubmit={(e) => submit(e)}>
|
||||
<input
|
||||
placeholder="Enter your email to stay updated"
|
||||
ref={(node) => (input = node)}
|
||||
required
|
||||
type="email"
|
||||
/>
|
||||
<button type="submit">
|
||||
<ArrowLink />
|
||||
<span className="sr-only">Send</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
interface Props {
|
||||
data: {
|
||||
aboutLinks: { href: string; title: string }[]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user