| 1 |
import { useActivityStore } from '@shared/state/activity'; |
| 2 |
import { Button, Modal as Dialog } from '@wordpress/components'; |
| 3 |
import { __ } from '@wordpress/i18n'; |
| 4 |
|
| 5 |
const { adminUrl } = window.extSharedData; |
| 6 |
|
| 7 |
export const ConfirmationModal = ({ |
| 8 |
setConfirmationOpen, |
| 9 |
confirmationOpen, |
| 10 |
setModalOpen, |
| 11 |
}) => { |
| 12 |
const { incrementActivity } = useActivityStore(); |
| 13 |
|
| 14 |
const confirmDeletion = () => { |
| 15 |
setConfirmationOpen(false); |
| 16 |
setModalOpen(true); |
| 17 |
incrementActivity('page-creator-delete-content-button-click'); |
| 18 |
}; |
| 19 |
|
| 20 |
return ( |
| 21 |
<Dialog |
| 22 |
onRequestClose={() => setConfirmationOpen(false)} |
| 23 |
className="extendify-page-creator" |
| 24 |
size="medium" |
| 25 |
aria-labelledby="page-creator-confirmation" |
| 26 |
role="dialog" |
| 27 |
isOpen={confirmationOpen} |
| 28 |
title={__('Confirmation', 'extendify-local')} |
| 29 |
> |
| 30 |
<div className="flex flex-col space-y-6 text-sm"> |
| 31 |
<div> |
| 32 |
{__( |
| 33 |
'Do you want to replace existing content or create a new page?', |
| 34 |
'extendify-local', |
| 35 |
)} |
| 36 |
</div> |
| 37 |
<div className="flex w-full items-center justify-end space-x-2"> |
| 38 |
<Button size="default" variant="tertiary" onClick={confirmDeletion}> |
| 39 |
{__('Delete existing content', 'extendify-local')} |
| 40 |
</Button> |
| 41 |
<Button |
| 42 |
variant="primary" |
| 43 |
size="default" |
| 44 |
href={`${adminUrl}post-new.php?post_type=page&ext-open-ai-creator=1`} |
| 45 |
target="_blank" |
| 46 |
> |
| 47 |
{__('Create a new page', 'extendify-local')} |
| 48 |
</Button> |
| 49 |
</div> |
| 50 |
</div> |
| 51 |
</Dialog> |
| 52 |
); |
| 53 |
}; |
| 54 |
|