import React, { useState } from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { TextField, Button } from '@material-ui/core'; import { Rating } from '@material-ui/lab'; import { useSnackbar } from 'notistack'; import { useFeedback } from '../../hooks/APIClient'; import { post } from '../../requests'; interface PropTypes { version: string; } const useStyles = makeStyles(theme => ({ root: { display: 'flex', flexDirection: 'column' }, textField: { margin: theme.spacing(2, 0) } })); const ReviewForm: React.FC = ({ version }) => { const [contents, setContents] = useState(''); const [score, setScore] = useState(0); const { mutate: updateFeedbacks } = useFeedback(); const classes = useStyles(); const { enqueueSnackbar } = useSnackbar(); const handleSubmit = (): void => { if (score) { post('/feedback', { contents, score, version }).then(() => { enqueueSnackbar('Your feedback has been submitted!', { variant: 'success' }); updateFeedbacks(); }); } }; const handleChange = (event: React.ChangeEvent): void => { setContents(event.target?.value || ''); }; const handleChangeRating = (event: React.ChangeEvent>, newScore: number | null): void => { setScore(newScore || 0); }; return (
); }; export default ReviewForm;