HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: /var/www/wp-content/plugins/image-optimization/modules/reviews/assets/src/components/review-form.js
import styled from '@emotion/styled';
import { Button, Flex } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import useStorage from '../hooks/use-storage';
import Typography from '../../../../../assets/dev/js/components/typography';
import { WORDPRESS_REVIEW_LINK } from '../constants';

const ReviewForm = ( { close } ) => {
	const { save, get } = useStorage();

	const handleSubmit = async () => {
		await save( {
			image_optimizer_review_data: {
				...get.data.image_optimizer_review_data,
				repo_review_clicked: true,
			},
		} );

		close();
		window.open( WORDPRESS_REVIEW_LINK, '_blank' );
	};

	return (
		<Flex direction="column">
			<Typography variant="body1" marginBottom={ 1 }>
				{ __( 'It would mean a lot if you left us a quick review, so others can discover it too.', 'image-optimization' ) }
			</Typography>
			<StyledButton
				variant="primary"
				onClick={ handleSubmit }
			>
				{ __( 'Leave a review', 'image-optimization' ) }
			</StyledButton>
		</Flex>
	);
};

export default ReviewForm;

const StyledButton = styled( Button )`
	min-width: 80px;
	align-self: flex-end;
	margin-top: 16px;
	background-color: #515962 !important;
	align-items: center;
	justify-content: center;
	color: #FFF;
`;