import React from 'react' import { Button, Divider, Form, Input, message, Row, Typography } from 'antd' import FormItem from 'antd/lib/form/FormItem' import { Content } from 'antd/lib/layout/layout' import { useState } from 'react' import { useHistory } from 'react-router-dom' import { createClient } from '../api' type FormData = { name: string email: string phone: string } export const Dashboard = () => { const history = useHistory() const [error, setError] = useState(null) const [form] = Form.useForm() const handleReset = () => { form.resetFields() } const handleSubmit = async (values: FormData) => { if (values.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: values.name, email: values.email, phone: parseInt(values.phone.replace(/\D/g, '')), }) history.push(`/sessions/${client_id}`) } return ( Dashboard
Enter the name, email and phone number of the subject {error &&

{error}

}
) }