// Dependencies
import { validateEmail, validateTld, getSearchParam } from '@freesewing/utils'
// Hooks
import React, { useState, useContext, useEffect } from 'react'
import { useAccount } from '@freesewing/react/hooks/useAccount'
import { useBackend } from '@freesewing/react/hooks/useBackend'
// Context
import { LoadingStatusContext } from '@freesewing/react/context/LoadingStatus'
import { ModalContext } from '@freesewing/react/context/Modal'
// Components
import { Link } from '@freesewing/react/components/Link'
import {
LeftIcon,
RightIcon,
HelpIcon,
GoogleIcon,
GitHubIcon,
KeyIcon,
EmailIcon,
DownIcon,
} from '@freesewing/react/components/Icon'
import { ModalWrapper } from '@freesewing/react/components/Modal'
import { EmailInput } from '@freesewing/react/components/Input'
import { IconButton } from '@freesewing/react/components/Button'
import { Spinner } from '@freesewing/react/components/Spinner'
import { Consent } from '@freesewing/react/components/Account'
export const SignUp = ({ embed = false }) => {
// State
const [email, setEmail] = useState('')
const [emailValid, setEmailValid] = useState(false)
const [result, setResult] = useState(false)
const [showAll, setShowAll] = useState(false)
// Hooks
const backend = useBackend()
// Context
const { setModal } = useContext(ModalContext)
const { setLoadingStatus } = useContext(LoadingStatusContext)
const updateEmail = (value) => {
setEmail(value)
const valid = (validateEmail(value) && validateTld(value)) || false
setEmailValid(valid === true ? true : false)
}
const signupHandler = async (evt) => {
evt.preventDefault()
if (!emailValid) {
setLoadingStatus([true, 'Please provide a valid email address', true, false])
return
}
const [status, body] = await backend.signUp({ email })
if (status === 201 && body.result === 'created') setResult('success')
else {
setModal(
Unfortunately, we cannot recover from this error, we need a human being to look into
this.
Feel free to try again, or reach out to support so we can assist you.
An error occured while trying to process your request
Go check your inbox for an email from FreeSewing.org
Click your personal signup link in that email to create your FreeSewing account.
Unfortunately, we cannot recover from this error, we need a human being to look into this.
Feel free to try again, or reach out to support so we can assist you.
To receive a sign-up link, enter your email address
{showAll ? ( <>