I have a component with an email input and I need to figure out a way to check the email address to see if it's valid like 'name@email.com' whenever a user clicks the next button on a form. I also need to send the value of that input back along with other data on the page and I'm not sure how to do either.
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {
  Col, Row, Icon, Input, Tooltip
} from 'antd'
import Checkbox from '../elements/Checkbox'
import Markup from '../core/Markup'
const CustomerDetails = ({ customer }) => {
  const { contact = {}, account = {}, site = {} } = customer || {}
  const [disableInput, setDisableInput] = React.useState(false)
  const [inputValue, setInputValue] = React.useState(contact.email)
  function clearInput() {
    setInputValue(' ')
  }
  function handleInputChange(event) {
    setInputValue(event.target.value)
  }
  function CheckboxClick() {
    if (!disableInput) {
      clearInput()
    }
    setDisableInput(prevValue => !prevValue)
  }
  return (
    <Container>
      <h2>{account.name}</h2>
      <Row>
        <Col span={8}>
          <H3>
            <strong>Primary Contact:</strong>
          </H3>
          <P>{contact.name}</P>
          <P>{contact.phone}</P>
        </Col>
        <Col span={8}>
          <H3>
            <strong>Service Address:</strong>
          </H3>
          <P>{site.address1}</P>
          <P>{site.address2}</P>
          <P>
            {site.city}, {site.state} 
            {site.postalCode}
          </P>
        </Col>
        <Col span={8}>
          <H3>
            <strong>Billing Address:</strong>
          </H3>
          <StyledMarkup>{account.billingStreet}</StyledMarkup>
          <P>
            {account.billingCity}, {account.billingState}
             
            {account.billingPostalCode}
          </P>
        </Col>
      </Row>
      <br />
      <Row>
        <Col span={10}>
          <h4>
            PRIMARY CONTACT EMAIL  
            <Tooltip
              placement="right"
              title={primaryContact}
            >
              <StyledTooltipIcon
                type="question-circle"
                theme="filled"
              />
            </Tooltip>
          </h4>
        </Col>
      </Row>
      <Row>
        <Col span={8}>
          <StyledInput
            value={inputValue}
            onChange={handleInputChange}
            disabled={disableInput}
          />
        </Col>
        <Col span={2} />
        <Col span={8}>
          <StyledCheckbox
            value={disableInput}
            onChange={CheckboxClick}
          /> EMAIL
          OPT OUT{' '}
          <Tooltip
            placement="right"
            title={emailText}
          >
            <StyledTooltipIcon
              type="question-circle"
              theme="filled"
            />
          </Tooltip>
        </Col>
      </Row>
      <br />
      <Row>
        <Col>
          <StyledCheckbox /> EXEMPT
        </Col>
      </Row>
      <br />
      <Row>
        <Col>
          <H4>BUILDER</H4>
        </Col>
      </Row>
    </Container>
  )
}
CustomerDetails.propTypes = {
  customer: PropTypes.object
}
CustomerDetails.defaultProps = {
  customer: {}
}
const Container = styled.div`
  text-align: left;
`
const StyledCheckbox = styled(Checkbox)`
  &&& {
    background: white;
    input + span {
      width: 35px;
      height: 35px;
      border: 2px solid ${({ theme }) => theme.colors.black};
    }
    input + span:after {
      width: 12.5px;
      height: 20px;
    }
    input:focus + span {
      width: 35px;
      height: 35px;
    }
  }
`
const StyledInput = styled(Input)`
  max-width: 100%;
  background: white;
  &&& {
    border: 2px solid ${({ theme }) => theme.colors.black};
    border-radius: 0px;
    height: 35px;
  }
`
const ErrorContainer = styled.div`
  span {
    text-align: center;
  }
`
const StyledTooltipIcon = styled(Icon)`
  color: #1571da;
`
const H3 = styled.h3`
  white-space: nowrap;
  margin-top: 0;
  margin-bottom: 0;
  line-height: 1.5;
`
const H4 = styled.h4`
  text-decoration: underline;
  color: #1590ff;
`
const P = styled.p`
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1rem;
`
const StyledMarkup = styled(Markup)`
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1rem;
`
export default CustomerDetails
 
    