PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.7.1
GiveWP – Donation Plugin and Fundraising Platform v4.7.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 2.31.0 2.31.1 All 253 releases
give / src / Campaigns / resources / admin / components / CreateCampaignModal / index.tsx
index.tsx
47 lines 1.5 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 style={{borderRadius: '4px'}} className={`button button-primary ${styles.createCampaignButton}`} onClick={openModal}>
32 {__('Create campaign', 'give')}
33 </a>
34 <CampaignFormModal
35 isOpen={isOpen}
36 handleClose={closeModal}
37 title={__('Create your campaign', 'give')}
38 apiSettings={apiSettings}
39 />
40 </>
41 );
42 }
43
44 type ResponseProps = {
45 id?: string;
46 };
47