| 1 |
import { useCallback } from '@wordpress/element'; |
| 2 |
import { __, sprintf } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
const statusMap = { |
| 5 |
draft: __('Draft'), |
| 6 |
publish: __('Published'), |
| 7 |
}; |
| 8 |
|
| 9 |
export const UpdatePostStatusConfirm = ({ inputs, onConfirm, onCancel }) => { |
| 10 |
const handleConfirm = () => { |
| 11 |
if (window?.extAgentData?.context) { |
| 12 |
window.extAgentData.context.postStatus = inputs.updatedStatus; |
| 13 |
} |
| 14 |
onConfirm({ data: inputs }); |
| 15 |
}; |
| 16 |
|
| 17 |
const handleCancel = useCallback(() => { |
| 18 |
onCancel(); |
| 19 |
}, [onCancel]); |
| 20 |
|
| 21 |
return ( |
| 22 |
<div className="mb-4 ms-2 me-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50"> |
| 23 |
<div className="rounded-lg border-b border-gray-300 bg-white"> |
| 24 |
<div className="p-3"> |
| 25 |
<p className="m-0 p-0 text-sm text-gray-900"> |
| 26 |
{sprintf( |
| 27 |
// translators: %1$s is the current page or post status, and %2$s is the updated page or post status. |
| 28 |
__( |
| 29 |
'Status will change from "%s" to "%s", please confirm to save.', |
| 30 |
'extendify-local', |
| 31 |
), |
| 32 |
statusMap[inputs.postStatus], |
| 33 |
statusMap[inputs.updatedStatus], |
| 34 |
)} |
| 35 |
</p> |
| 36 |
</div> |
| 37 |
</div> |
| 38 |
<div className="flex justify-start gap-2 p-3"> |
| 39 |
<button |
| 40 |
type="button" |
| 41 |
className="w-full rounded-sm border border-gray-500 bg-white p-2 text-sm text-gray-900" |
| 42 |
onClick={handleCancel} |
| 43 |
> |
| 44 |
{__('Cancel', 'extendify-local')} |
| 45 |
</button> |
| 46 |
<button |
| 47 |
type="button" |
| 48 |
className="w-full rounded-sm border border-design-main bg-design-main p-2 text-sm text-white" |
| 49 |
onClick={handleConfirm} |
| 50 |
> |
| 51 |
{__('Confirm', 'extendify-local')} |
| 52 |
</button> |
| 53 |
</div> |
| 54 |
</div> |
| 55 |
); |
| 56 |
}; |
| 57 |
|