/** * WordPress dependencies */ import { useDispatch } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { ConfirmationDialog } from '@nab/components'; import { store as NAB_DATA, usePageAttribute } from '@nab/data'; export function AlternativeApplicationModal(): JSX.Element | null { const [ alternativeToApply, setAlternativeToApply ] = usePageAttribute( 'results/alternativeToApply', false ); const [ alternativeBeingApplied ] = usePageAttribute( 'results/alternativeBeingApplied', false ); const { applyAlternative } = useDispatch( NAB_DATA ); const closeModal = () => setAlternativeToApply( false ); if ( ! alternativeToApply ) { return null; } return ( { void applyAlternative( alternativeToApply ).then( () => closeModal() ); } } /> ); }