2022-11-11 16:17:49 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { __ } from '@wordpress/i18n';
|
|
|
|
import styled from '@emotion/styled';
|
|
|
|
import { Button } from '@wordpress/components';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { SettingsSection } from '../shared-components';
|
|
|
|
import { useSettingsContext } from './settings-context';
|
|
|
|
|
|
|
|
const SaveSectionWrapper = styled( SettingsSection )`
|
|
|
|
text-align: right;
|
|
|
|
padding-top: 0;
|
|
|
|
margin-top: 0;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const SaveSettings = () => {
|
|
|
|
const { isSaving, save } = useSettingsContext();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SaveSectionWrapper className={ 'submit' }>
|
|
|
|
<Button
|
|
|
|
variant="primary"
|
|
|
|
isBusy={ isSaving }
|
|
|
|
disabled={ isSaving }
|
2022-12-22 13:36:25 +00:00
|
|
|
onClick={ (
|
|
|
|
event: React.MouseEvent< HTMLButtonElement, MouseEvent >
|
|
|
|
) => {
|
|
|
|
const target = event.target as HTMLButtonElement;
|
|
|
|
if ( target?.form?.reportValidity() ) {
|
|
|
|
save();
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
type="submit"
|
2022-11-11 16:17:49 +00:00
|
|
|
>
|
|
|
|
{ __( 'Save changes', 'woo-gutenberg-products-block' ) }
|
|
|
|
</Button>
|
|
|
|
</SaveSectionWrapper>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SaveSettings;
|