import FormControl from '@elementor/ui/FormControl';
import FormControlLabel from '@elementor/ui/FormControlLabel';
import ListItem from '@elementor/ui/ListItem';
import ListItemIcon from '@elementor/ui/ListItemIcon';
import Radio from '@elementor/ui/Radio';
import RadioGroup from '@elementor/ui/RadioGroup';
import { styled } from '@elementor/ui/styles';
import Button from '@elementor/ui/Button';
import { __ } from '@wordpress/i18n';
import { MoodEmpty, MoodHappy, MoodSad, MoodSadSquint, MoodSmile } from '../icons';
import { useSettings } from '../hooks/use-settings';
const RatingForm = ( { close, handleSubmitForm } ) => {
const {
rating,
setRating,
setCurrentPage,
nextButtonDisabled,
setNextButtonDisabled,
} = useSettings();
const ratingsMap = [
{ value: '5', label: __( 'Excellent', 'image-optimization' ), icon: },
{ value: '4', label: __( 'Pretty good', 'image-optimization' ), icon: },
{ value: '3', label: __( "It's okay", 'image-optimization' ), icon: },
{ value: '2', label: __( 'Could be better', 'image-optimization' ), icon: },
{ value: '1', label: __( 'Needs improvement', 'image-optimization' ), icon: },
];
const handleRatingChange = ( value ) => {
setRating( value );
setNextButtonDisabled( false );
};
const handleNextButton = async () => {
if ( parseInt( rating ) < 4 ) {
setCurrentPage( 'feedback' );
} else {
const submitted = await handleSubmitForm( close, true );
if ( submitted ) {
setCurrentPage( 'review' );
}
}
};
return (
handleRatingChange( value ) }
name="radio-buttons-group"
>
{ ratingsMap.map( ( { value, label, icon } ) => {
return (
{ icon }
}
label={ label }
value={ value }
labelPlacement="start" />
);
} ) }
);
};
export default RatingForm;
const StyledFormControlLabel = styled( FormControlLabel )`
justify-content: space-between;
margin-left: 0;
width: 100%;
`;