import React, { useState } from 'react'; import { Grid, TextField, Button } from '@material-ui/core'; import { post } from '../../requests'; import { Event } from '../../types'; interface PropTypes { mutate: () => void; } const EventForm: React.FC = ({ mutate }) => { const [name, setName] = useState(''); const [schedule, setSchedule] = useState('* * * * * *'); const [attendanceId, setAttendanceId] = useState(''); const [conferenceId, setConferenceId] = useState(''); const createHandler = (setter: any) => (event: React.ChangeEvent) => { setter(event.target.value); }; const handleSubmit = () => { if (schedule && conferenceId) { const event: Partial = { name, schedule, context: { attendanceId, conferenceId, participants: [] } }; setName(''); setAttendanceId(''); setConferenceId(''); setSchedule(''); return post('/events', event).then(() => mutate()); } } return ( ); }; export default EventForm;