import { message } from 'antd' import { Content } from 'antd/lib/layout/layout' import React, { FormEvent } from 'react' import { useState } from 'react' import { useHistory } from 'react-router-dom' import { createClient } from '../api' import settings from '../settings' export const Dashboard = () => { const history = useHistory() const [error, setError] = useState(null) const [name, setName] = useState('') const [email, setEmail] = useState('') const [phone, setPhone] = useState('') const handleReset = () => { // setName('') setEmail('') setPhone('') } const handleSubmit = async (e: FormEvent) => { e.preventDefault() if (phone.length < 10) { // helpful message message.error('Check all fields!') setError('Phone number needs to be a length of at least 10') return } if (settings.env === 'jank') { history.push(`/sessions/${phone}`) return } await createClient({ name, email, phone: parseInt(phone) }) history.push(`/sessions/${phone}`) } return (

Dashboard

{error &&

{error}

}
) }