import React, {useState} from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl';
import Radio from '@material-ui/core/Radio';
import RadioGroup from '@material-ui/core/RadioGroup';
import "./NewCaseForm.css"
import Button from '@material-ui/core/Button';
import Snackbar from '@material-ui/core/Snackbar';
import Slide from '@material-ui/core/Slide';
import {animated, useSpring} from "react-spring";
import Alert from '@material-ui/lab/Alert';
const useStyles = makeStyles((theme) => ({
backgroundColor: '#00000029',
backgroundColor: '#9b97a28f',
backgroundImage: 'linear-gradient(180deg,hsla(0,0%,100%,.1),hsla(0,0%,100%,0))',
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
function StyledRadio(props) {
const classes = useStyles();
checkedIcon={<span className={clsx(classes.icon, classes.checkedIcon)} />}
icon={<span className={classes.icon} />}
export default function Form(props) {
const [open, setOpen] = React.useState(false);
const [transition, setTransition] = React.useState(undefined);
const [age, setAge] = useState('');
const [gender, setGender] = useState('Male');
const [status, setStatus] = useState('Confirmed');
const [Arrival, setArrival] = useState('');
const [Depart, setDepart] = useState('');
const [transport, setTransport] = useState('Plane');
const [source, setSource] = useState('');
const [announced_date, setAnnounced_date] = React.useState('');
const classes = useStyles();
const propsAnim = useSpring({opacity: 1, from: {opacity: 0}});
console.log(announced_date)
const handleClick = (Transition) => () => {
setTransition(() => Transition);
const handleClose = () => {
function TransitionUp(props) {
return <Slide {...props} direction="up" />;
async function sendForm() {
const response = await fetch("https://api.codataset.com/new", {
body: JSON.stringify(data),
'Content-Type': 'application/json'
const json = await response.json();
console.log('Успех:', JSON.stringify(json));
console.error('Где-то ошибка:', error );
'announced_date':announced_date,
<div className="formContainer">
<Snackbar autoHideDuration={5000}
TransitionComponent={transition}
<animated.div className="formTitle" style={propsAnim}>
<animated.div className="About" style={propsAnim}>
<TextField onChange={(e) => setAge(e.target.value)}
className={classes.textField}
color: 'rgba(242, 242, 242, 0.25)'
<animated.div className="genderAnim" style={propsAnim}>
<FormControl className="setGenderContainer" component="fieldset">
<RadioGroup className="setGenderBox" value={gender} defaultValue="male" onChange={(e) => setGender(e.target.value)} aria-label="gender"
name="customized-radios">
<FormControlLabel style={{marginRight:50}} name="Male" value="Male" control={<StyledRadio/>} label="Male"/>
<FormControlLabel style={{marginRight:50}} name="Female" value="Female" control={<StyledRadio/>} label="Female"/>
<animated.div className="statusAnim" style={propsAnim}>
<FormControl className="setGenderContainer" component="fieldset">
<RadioGroup className="setGenderBox" value={status} defaultValue="Confirmed" aria-label="Status" onChange={(e) => setStatus(e.target.value)}
name="customized-radios">
<FormControlLabel style={{marginRight:50}} name="Confirmed" value="Confirmed" control={<StyledRadio/>} label="Confirmed"/>
<FormControlLabel style={{marginRight:50}} name="Recovered" value="Recovered" control={<StyledRadio/>} label="Recovered"/>
<FormControlLabel style={{marginRight:50}} name="Hospitalized" value="Hospitalized" control={<StyledRadio/>} label="Hospitalized"/>
<FormControlLabel style={{marginRight:50}} name="Deceased" value="Deceased" control={<StyledRadio/>} label="Deceased"/>
<div className="date_source_places">
<animated.div className="date_source" style={propsAnim}>
<TextField onChange={(e) => setAnnounced_date(e.target.value)}
defaultValue="01.01.2020"
<TextField onChange={(e) => setSource(e.target.value)}
color: 'rgba(242, 242, 242, 0.25)'
<div className="placesWithTransport">
<div className="movementPlaces">
<animated.div style={propsAnim} className="depPlace">
<TextField onChange={(e) => setDepart(e.target.value)}
label="Departure Country, Region, City"
className="movementInputs"
color: 'rgba(242, 242, 242, 0.25)'
<animated.div style={propsAnim} className="arrPlace">
<TextField onChange={(e) => setArrival(e.target.value)}
label="Arrival Country, Region, City"
className="movementInputs"
color: 'rgba(242, 242, 242, 0.25)'
<animated.div style={propsAnim} className="transportAnim">
<RadioGroup className="transport" defaultValue="Plane" value={transport} aria-label="transport" onChange={(e) => setTransport(e.target.value)}
name="customized-radios">
<FormControlLabel style={{marginRight:50}} name="Plane" value="Plane" control={<StyledRadio/>} label="Plane"/>
<FormControlLabel style={{marginRight:50}} name="Ship" value="Ship" control={<StyledRadio/>} label="Ship"/>
<FormControlLabel style={{marginRight: 50}} name="Train" value="Train" control={<StyledRadio/>} label="Train"/>
<FormControlLabel style={{marginRight: 50}} name="Car" value="Car" control={<StyledRadio/>} label="Car"/>
<animated.div style={propsAnim} className="submitBtnContainer">
<div className="submitBtn" onClick={sendForm}>Confirm</div>