PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.21.0
GiveWP – Donation Plugin and Fundraising Platform v3.21.0
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 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / src / Donations / resources / components / DonationsListTable.tsx
give / src / Donations / resources / components Last commit date
DonationRowActions.tsx 3 years ago DonationsListTable.tsx 2 years ago ListTable.module.scss 3 years ago
DonationsListTable.tsx
261 lines
1 import {__} from '@wordpress/i18n';
2 import {ListTablePage} from '@givewp/components';
3 import {DonationRowActions} from './DonationRowActions';
4 import ListTableApi from '@givewp/components/ListTable/api';
5 import tableStyles from '@givewp/components/ListTable/ListTablePage/ListTablePage.module.scss';
6 import styles from './ListTable.module.scss';
7 import {IdBadge} from '@givewp/components/ListTable/TableCell';
8 import {BulkActionsConfig, FilterConfig} from '@givewp/components/ListTable/ListTablePage';
9 import {Interweave} from 'interweave';
10 import BlankSlate from '@givewp/components/ListTable/BlankSlate';
11 import ProductRecommendations from '@givewp/components/ListTable/ProductRecommendations';
12 import {RecommendedProductData} from '@givewp/promotions/hooks/useRecommendations';
13
14 declare global {
15 interface Window {
16 GiveDonations: {
17 apiNonce: string;
18 apiRoot: string;
19 adminUrl: string;
20 forms: Array<{value: string; text: string}>;
21 table: {columns: Array<object>};
22 paymentMode: boolean;
23 manualDonations: boolean;
24 pluginUrl: string;
25 dismissedRecommendations: Array<string>;
26 addonsBulkActions: Array<BulkActionsConfig>;
27 };
28 }
29 }
30
31 const API = new ListTableApi(window.GiveDonations);
32
33 const filters: Array<FilterConfig> = [
34 {
35 name: 'search',
36 type: 'search',
37 inlineSize: '14rem',
38 text: __('Name, Email, or Donation ID', 'give'),
39 ariaLabel: __('search donations', 'give'),
40 },
41 {
42 name: 'form',
43 type: 'formselect',
44 text: __('Select Form', 'give'),
45 ariaLabel: __('filter donation forms by status', 'give'),
46 options: window.GiveDonations.forms,
47 },
48 {
49 name: 'toggle',
50 type: 'checkbox',
51 text: __('Test', 'give'),
52 ariaLabel: __('View Test Donations', 'give'),
53 },
54 ];
55
56 const bulkActions: Array<BulkActionsConfig> = [
57 {
58 label: __('Delete', 'give'),
59 value: 'delete',
60 type: 'danger',
61 action: async (selected) => {
62 const response = await API.fetchWithArgs('/delete', {ids: selected.join(',')}, 'DELETE');
63 return response;
64 },
65 confirm: (selected, names) => (
66 <>
67 <p>{__('Really delete the following donations?', 'give')}</p>
68 <ul role="document" tabIndex={0}>
69 {selected.map((donationId, index) => (
70 <li key={donationId}>
71 <IdBadge id={donationId} />{' '}
72 <span>
73 {__('from ', 'give')} <Interweave content={names[index]} />
74 </span>
75 </li>
76 ))}
77 </ul>
78 </>
79 ),
80 },
81 ...(() => {
82 const donationStatuses = {
83 publish: __('Set To Completed', 'give'),
84 pending: __('Set To Pending', 'give'),
85 processing: __('Set To Processing', 'give'),
86 refunded: __('Set To Refunded', 'give'),
87 revoked: __('Set To Revoked', 'give'),
88 failed: __('Set To Failed', 'give'),
89 cancelled: __('Set To Cancelled', 'give'),
90 abandoned: __('Set To Abandoned', 'give'),
91 preapproval: __('Set To Preapproval', 'give'),
92 };
93
94 return Object.entries(donationStatuses).map(([value, label]) => {
95 return {
96 label,
97 value,
98 action: async (selected) =>
99 await API.fetchWithArgs(
100 '/setStatus',
101 {
102 ids: selected.join(','),
103 status: value,
104 },
105 'POST'
106 ),
107 confirm: (selected, names) => (
108 <>
109 <p>{__('Set status for the following donations?', 'give')}</p>
110 <ul role="document" tabIndex={0}>
111 {selected.map((donationId, index) => (
112 <li key={donationId}>
113 <IdBadge id={donationId} /> <span>{__('from', 'give')}</span>
114 <Interweave content={names[index]} />
115 </li>
116 ))}
117 </ul>
118 </>
119 ),
120 };
121 });
122 })(),
123 {
124 label: __('Resend Email Receipts', 'give'),
125 value: 'resendEmailReceipt',
126 action: async (selected) => await API.fetchWithArgs('/resendEmailReceipt', {ids: selected.join(',')}, 'POST'),
127 confirm: (selected, names) => (
128 <>
129 <p>{__('Resend Email Receipts for following donations?', 'give')}</p>
130 <ul role="document" tabIndex={0}>
131 {selected.map((donationId, index) => (
132 <li key={donationId}>
133 <IdBadge id={donationId} /> <span>{__('from', 'give')}</span>
134 <Interweave content={names[index]} />
135 </li>
136 ))}
137 </ul>
138 </>
139 ),
140 },
141 ];
142
143 /**
144 * Displays a blank slate for the Donations table.
145 * @since 2.27.0
146 */
147 const ListTableBlankSlate = (
148 <BlankSlate
149 imagePath={`${window.GiveDonations.pluginUrl}/assets/dist/images/list-table/blank-slate-donations-icon.svg`}
150 description={__('No donations found', 'give')}
151 href={'https://docs.givewp.com/donations'}
152 linkText={__('GiveWP Donations.', 'give')}
153 />
154 );
155
156 interface DonationTableRecommendations {
157 recurring: RecommendedProductData;
158 feeRecovery: RecommendedProductData;
159 designatedFunds: RecommendedProductData;
160 }
161
162 /**
163 * @since 2.27.1
164 */
165 const RecommendationConfig: DonationTableRecommendations = {
166 recurring: {
167 enum: 'givewp_donations_recurring_recommendation_dismissed',
168 documentationPage: 'https://docs.givewp.com/recurring-donations-list',
169 message: __('Increase your fundraising revenue by over 30% with recurring giving campaigns.', 'give'),
170 innerHtml: __('Get More Donations', 'give'),
171 },
172 feeRecovery: {
173 enum: 'givewp_donations_fee_recovery_recommendation_dismissed',
174 documentationPage: 'https://docs.givewp.com/feerecovery-donations-list',
175 message: __(
176 'Raise more money per donation by providing donors with the option to help cover the credit card processing fees.',
177 'give'
178 ),
179 innerHtml: __('Get Fee Recovery', 'give'),
180 },
181 designatedFunds: {
182 enum: 'givewp_donations_designated_funds_recommendation_dismissed',
183 documentationPage: 'https://docs.givewp.com/funds-donations-list',
184 message: __(
185 'Elevate your fundraising campaigns with unlimited donation fund designations, and tailored fundraising reports.',
186 'give'
187 ),
188 innerHtml: __('Start creating designated funds', 'give'),
189 },
190 };
191
192 const rotatingRecommendation = (
193 <ProductRecommendations
194 options={[
195 RecommendationConfig.recurring,
196 RecommendationConfig.feeRecovery,
197 RecommendationConfig.designatedFunds,
198 ]}
199 apiSettings={window.GiveDonations}
200 />
201 );
202
203 export default function DonationsListTable() {
204 return (
205 <ListTablePage
206 title={__('Donations', 'give')}
207 singleName={__('donation', 'give')}
208 pluralName={__('donations', 'give')}
209 rowActions={DonationRowActions}
210 bulkActions={bulkActions}
211 apiSettings={window.GiveDonations}
212 filterSettings={filters}
213 paymentMode={!!window.GiveDonations.paymentMode}
214 listTableBlankSlate={ListTableBlankSlate}
215 productRecommendation={rotatingRecommendation}
216 >
217 {window.GiveDonations.manualDonations ? (
218 <a
219 className={tableStyles.addFormButton}
220 href={`${window.GiveDonations.adminUrl}edit.php?post_type=give_forms&page=give-manual-donation`}
221 >
222 {__('New Donation', 'give')}
223 </a>
224 ) : (
225 <a
226 className={styles.manualDonationsNotice}
227 href={'https://docs.givewp.com/enterdonation'}
228 target={'_blank'}
229 >
230 <span className={styles.manualDonationsAddOn}>{__('ADD-ON', 'give')}</span>
231 {__('Enter Donations', 'give')}
232 <span className={styles.manualDonationsMessage}>
233 <img
234 src={`${window.GiveDonations.pluginUrl}/assets/dist/images/admin/triangle-tip.svg`}
235 alt={'manual donations'}
236 />{' '}
237 {__(
238 'Need to add in a record for a donation received elsewhere, or reconcile with the payment gateway? Add donation records with the Manual Donations add-on!',
239 'give'
240 )}
241 </span>
242 </a>
243 )}
244 <a
245 className={tableStyles.addFormButton}
246 href={` ${window.GiveDonations.adminUrl}edit.php?post_type=give_forms&page=give-tools&tab=import&importer-type=import_donations`}
247 >
248 {__('Import Donations', 'give')}
249 </a>
250 <button className={tableStyles.addFormButton} onClick={showLegacyDonations}>
251 {__('Switch to Legacy View', 'give')}
252 </button>
253 </ListTablePage>
254 );
255 }
256
257 const showLegacyDonations = async (event) => {
258 await API.fetchWithArgs('/view', {isLegacy: 1});
259 window.location.reload();
260 };
261