import React from 'react'; import { Grid, TextField, Button } from '@material-ui/core'; import { Formik, Form, Field } from 'formik'; import { post } from '../../requests'; import { Event } from '../../types'; interface PropTypes { mutate: () => void; } interface Fields { name: string; schedule: string; attendanceId: string; conferenceId: string; } const EventForm: React.FC = ({ mutate }) => { const handleSubmit = (fields: Fields, { resetForm }: any) => { const { name, schedule, attendanceId, conferenceId } = fields; if (schedule && conferenceId) { const event: Partial = { type: 'class', schedule, context: { name, attendanceId, conferenceId, participants: [] } }; return post('/events', event).then(() => { mutate(); resetForm(); }); } } return ( {({ values, errors, touched, isSubmitting }) => (
)}
); }; export default EventForm;