PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 2.30.0 All 255 releases
give / src / Campaigns / resources / admin / components / CreateCampaignModal / index.tsx

index.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Campaigns/resources/admin/components/CreateCampaignModal/index.tsx

46 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {__} from '@wordpress/i18n';
2 import styles from './CreateCampaignModal.module.scss';
3 import CampaignFormModal from '../CampaignFormModal';
4 import {getGiveCampaignsListTableWindowData} from '../CampaignsListTable';
5
6 /**
7 * Create Campaign Modal component
8 *
9 * @since 4.0.0
10 */
11 export default function CreateCampaignModal({isOpen, setOpen}) {
12
13 const openModal = () => setOpen(true);
14 const closeModal = (response: ResponseProps = {}) => {
15 setOpen(false);
16
17 if (response?.id) {
18 window.location.href =
19 getGiveCampaignsListTableWindowData().adminUrl +
20 'edit.php?post_type=give_forms&page=give-campaigns&id=' +
21 response?.id;
22 }
23 };
24
25 const apiSettings = getGiveCampaignsListTableWindowData();
26 // Remove the /list-table from the apiRoot. This is a hack to make the API work while we don't refactor other list tables.
27 apiSettings.apiRoot = apiSettings.apiRoot.replace('/list-table', '');
28
29 return (
30 <>
31 <a
32 style={{borderRadius: '4px'}}
33 className={`button button-primary ${styles.createCampaignButton}`}
34 onClick={openModal}
35 >
36 {__('Create campaign', 'give')}
37 </a>
38 <CampaignFormModal isOpen={isOpen} handleClose={closeModal} apiSettings={apiSettings} />
39 </>
40 );
41 }
42
43 type ResponseProps = {
44 id?: string;
45 };
46