PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / Campaigns / resources / admin / components / CampaignsListTable / CampaignsRowActions.tsx

CampaignsRowActions.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/Campaigns/resources/admin/components/CampaignsListTable/CampaignsRowActions.tsx

42 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {useContext} from 'react';
2 import {useSWRConfig} from 'swr';
3 import {__, sprintf} from '@wordpress/i18n';
4 import RowAction from '@givewp/components/ListTable/RowAction';
5 import {ShowConfirmModalContext} from '@givewp/components/ListTable/ListTablePage';
6 import ListTableApi from '@givewp/components/ListTable/api';
7 import {getCampaignOptionsWindowData} from '@givewp/campaigns/utils';
8
9 const API = new ListTableApi(getCampaignOptionsWindowData());
10
11 export function CampaignsRowActions({item, setUpdateErrors, parameters}) {
12 const showConfirmModal = useContext(ShowConfirmModalContext);
13 const {mutate} = useSWRConfig();
14
15 const duplicateItem = async () => {
16 const response = await API.fetchWithArgs(`/${item.id}/duplicate`, {}, 'POST');
17 setUpdateErrors(response);
18 await mutate(parameters);
19 return response;
20 };
21
22 const confirmDuplicate = () => (
23 <p>{sprintf(__('Are you sure you want to duplicate the following campaign: %s?', 'give'), item.titleRaw)}</p>
24 );
25
26 const confirmModal = () => showConfirmModal(__('Duplicate', 'give'), confirmDuplicate, duplicateItem, 'info');
27
28 return (
29 <>
30 <RowAction
31 href={`edit.php?post_type=give_forms&page=give-campaigns&id=${item.id}`}
32 displayText={__('Edit', 'give')}
33 />
34 <RowAction
35 actionId={item.id}
36 displayText={__('Duplicate', 'give')}
37 onClick={confirmModal}
38 />
39 </>
40 );
41 }
42