import React from 'react';
import {Button} from "@wordpress/components";
import {__} from "@wordpress/i18n";
import {useFormContext} from "react-hook-form";
import type {FormProps} from "../types/form-props";

const SubmitButton = () => {
	const {formState: {isSubmitting}} = useFormContext<FormProps>();

	return (
		<p className="submit">
			<Button
				id="submit"
				type="submit"
				name="submit"
				variant="primary"
				isBusy={isSubmitting}
				disabled={isSubmitting}
			>
				{__('Save Changes', 'product-description-in-loop-for-woocommerce')}
			</Button>
		</p>
	);
};

export default SubmitButton;
