import { Button, Divider, message, PageHeader } 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' 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 } const client_id = await createClient({ name, email, phone: parseInt(phone), }) history.push(`/sessions/${client_id}`) } return (
{error &&

{error}

}
) }