| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
|
| 3 |
export const UpdateSiteVisibilityConfirm = ({ onConfirm, onCancel }) => { |
| 4 |
// skipAgent resolves no inputs, so the direction comes from the current state. |
| 5 |
const isPublished = Boolean(window.extAgentData?.agentContext?.sitePublished); |
| 6 |
|
| 7 |
const handleConfirm = () => { |
| 8 |
onConfirm({ |
| 9 |
data: { visibility: isPublished ? 'unpublished' : 'published' }, |
| 10 |
shouldRefreshPage: true, |
| 11 |
}); |
| 12 |
}; |
| 13 |
|
| 14 |
return ( |
| 15 |
<div className="mb-4 ms-2 me-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50"> |
| 16 |
<div className="rounded-lg border-b border-gray-300 bg-white"> |
| 17 |
<div className="p-3"> |
| 18 |
<p className="m-0 p-0 text-sm text-gray-900"> |
| 19 |
{isPublished |
| 20 |
? __( |
| 21 |
'Your site will be hidden from visitors until you publish it again. Confirm to take it offline.', |
| 22 |
'extendify-local', |
| 23 |
) |
| 24 |
: __( |
| 25 |
'Your site will become visible to everyone. Confirm to take it live.', |
| 26 |
'extendify-local', |
| 27 |
)} |
| 28 |
</p> |
| 29 |
</div> |
| 30 |
</div> |
| 31 |
<div className="flex justify-start gap-2 p-3"> |
| 32 |
<button |
| 33 |
type="button" |
| 34 |
className="w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900" |
| 35 |
onClick={onCancel} |
| 36 |
> |
| 37 |
{__('Cancel', 'extendify-local')} |
| 38 |
</button> |
| 39 |
<button |
| 40 |
type="button" |
| 41 |
className="w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white" |
| 42 |
onClick={handleConfirm} |
| 43 |
> |
| 44 |
{__('Confirm', 'extendify-local')} |
| 45 |
</button> |
| 46 |
</div> |
| 47 |
</div> |
| 48 |
); |
| 49 |
}; |
| 50 |
|