Server IP : 192.158.238.246 / Your IP : 18.219.24.193 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/cwd/plugins/give/src/DonationForms/V2/resources/components/ |
Upload File : |
import {__} from '@wordpress/i18n'; import {useSWRConfig} from 'swr'; import RowAction from '@givewp/components/ListTable/RowAction'; import ListTableApi from '@givewp/components/ListTable/api'; import {useContext} from 'react'; import {ShowConfirmModalContext} from '@givewp/components/ListTable/ListTablePage'; import {Interweave} from 'interweave'; import {OnboardingContext} from './Onboarding'; import {UpgradeModalContent} from "./Migration"; const donationFormsApi = new ListTableApi(window.GiveDonationForms); export function DonationFormsRowActions({data, item, removeRow, addRow, setUpdateErrors, parameters}) { const {mutate} = useSWRConfig(); const showConfirmModal = useContext(ShowConfirmModalContext); const [OnboardingState, setOnboardingState] = useContext(OnboardingContext); const trashEnabled = Boolean(data?.trash); const deleteEndpoint = trashEnabled && !item.status.includes('trash') ? '/trash' : '/delete'; const fetchAndUpdateErrors = async (parameters, endpoint, id, method) => { const response = await donationFormsApi.fetchWithArgs(endpoint, {ids: [id]}, method); setUpdateErrors(response); await mutate(parameters); return response; }; const deleteForm = async (selected) => await fetchAndUpdateErrors(parameters, deleteEndpoint, item.id, 'DELETE'); const confirmDeleteForm = (selected) => ( <p> {__('Really delete the following form?', 'give')} <br /> <Interweave content={item?.title} /> </p> ); const confirmTrashForm = (selected) => ( <p> {__('Really trash the following form?', 'give')} <br /> <Interweave content={item?.title} /> </p> ); const confirmModal = (event) => { showConfirmModal(__('Delete', 'give'), confirmDeleteForm, deleteForm, 'danger'); }; const confirmTrashModal = (event) => { showConfirmModal(__('Trash', 'give'), confirmTrashForm, deleteForm, 'danger'); }; const confirmUpgradeModal = (event) => { showConfirmModal( __('Upgrade', 'give'), UpgradeModalContent, async (selected) => { const response = await donationFormsApi.fetchWithArgs("/migrate/" + item.id, {}, 'POST'); await mutate(parameters); return response; } ); }; return ( <> {parameters.status === 'trash' ? ( <> <RowAction onClick={removeRow( async () => await fetchAndUpdateErrors(parameters, '/restore', item.id, 'POST') )} actionId={item.id} displayText={__('Restore', 'give')} hiddenText={item?.name} /> <RowAction onClick={confirmModal} actionId={item.id} displayText={__('Delete Permanently', 'give')} hiddenText={item?.name} highlight /> </> ) : ( <> <RowAction href={item.edit} displayText={__('Edit', 'give')} hiddenText={item?.name} /> <RowAction onClick={confirmTrashModal} actionId={item.id} highlight={true} displayText={trashEnabled ? __('Trash', 'give') : __('Delete', 'give')} hiddenText={item?.name} /> <RowAction href={item.permalink} displayText={__('View', 'give')} hiddenText={item?.name} /> <RowAction onClick={addRow(async (id) => await fetchAndUpdateErrors(parameters, '/duplicate', id, 'POST'))} actionId={item.id} displayText={__('Duplicate', 'give')} hiddenText={item?.name} /> {!item.v3form && (<RowAction onClick={confirmUpgradeModal} actionId={item.id} displayText={__('Upgrade', 'give')} hiddenText={item?.name} />)} </> )} </> ); }