PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 4.16.6
GiveWP – Donation Plugin and Fundraising Platform v4.16.6
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 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 / Campaigns / resources / admin / components / CampaignDetailsPage / Tabs / Settings.tsx
give / src / Campaigns / resources / admin / components / CampaignDetailsPage / Tabs Last commit date
images 1 year ago Forms.tsx 1 year ago Overview.tsx 1 year ago Settings.tsx 9 months ago definitions.tsx 9 months ago
Settings.tsx
187 lines
1 import {__} from '@wordpress/i18n';
2 import {useFormContext} from 'react-hook-form';
3 import {Upload} from '../../Inputs';
4 import styles from '../CampaignDetailsPage.module.scss';
5 import {getCampaignOptionsWindowData} from '@givewp/campaigns/utils';
6 import ColorControl from '@givewp/campaigns/admin/components/CampaignDetailsPage/Components/ColorControl';
7 import TextareaControl from '@givewp/campaigns/admin/components/CampaignDetailsPage/Components/TextareaControl';
8 import {CurrencyControl} from '@givewp/form-builder-library';
9 import type {CurrencyCode} from '@givewp/form-builder-library/build/CurrencyControl/CurrencyCode';
10 import {CampaignGoalInputAttributes} from '@givewp/campaigns/admin/constants/goalInputAttributes';
11 import CampaignNotice from '@givewp/campaigns/admin/components/CampaignDetailsPage/Components/Notices/CampaignNotice';
12 import {useCampaignNoticeHook} from '@givewp/campaigns/hooks';
13 import AdminSection, { AdminSectionField, AdminSectionsWrapper } from '@givewp/components/AdminDetailsPage/AdminSection';
14
15 const {currency, isRecurringEnabled} = getCampaignOptionsWindowData();
16
17 /**
18 * @since 4.0.0
19 */
20 export default function CampaignDetailsSettingsTab() {
21 const [showTooltip, dismissTooltip] = useCampaignNoticeHook('givewp_campaign_settings_notice');
22
23 const {
24 register,
25 watch,
26 setValue,
27 formState: {errors},
28 } = useFormContext();
29
30 const [goal, goalType, image, status, shortDescription] = watch([
31 'goal',
32 'goalType',
33 'image',
34 'status',
35 'shortDescription',
36 ]);
37
38 const isDisabled = status === 'archived';
39
40 const goalInputAttributes = new CampaignGoalInputAttributes(goalType, currency);
41
42 return (
43 <AdminSectionsWrapper>
44 <AdminSection
45 title={__('Campaign Details', 'give')}
46 description={__('This includes the campaign title, description, and the cover of your campaign.', 'give')}
47 >
48 <AdminSectionField
49 subtitle={__("What's the title of your campaign?", 'give')}
50 description={__("Give your campaign a title that tells donors what it's about.", 'give')}
51 error={errors.title?.message as string}
52 >
53 <input {...register('title')} disabled={isDisabled} />
54 </AdminSectionField>
55
56 <AdminSectionField
57 subtitle={__("What's your campaign about?", 'give')}
58 description={__('Let your donors know the story behind your campaign.', 'give')}
59 error={errors.shortDescription?.message as string}
60 >
61 <TextareaControl
62 name={'shortDescription'}
63 disabled={isDisabled}
64 maxLength={120}
65 rows={3}
66 help={__('This will be displayed in your campaign block and campaign grid.', 'give')}
67 />
68 </AdminSectionField>
69
70 <AdminSectionField
71 subtitle={__('Add a cover image for your campaign.', 'give')}
72 description={__('Upload an image to represent and inspire your campaign.', 'give')}
73 error={errors.image?.message as string}
74 >
75 <div className={styles.upload}>
76 <Upload
77 disabled={isDisabled}
78 id="givewp-campaigns-upload-cover-image"
79 label={__('Cover', 'give')}
80 actionLabel={__('Select to upload', 'give')}
81 value={image}
82 onChange={(coverImageUrl, coverImageAlt) => {
83 setValue('image', coverImageUrl, {shouldDirty: true});
84 }}
85 reset={() => setValue('image', '', {shouldDirty: true})}
86 />
87 <p className={styles.sectionFieldHelpText}>{__('This will be displayed in your campaign block and campaign grid.', 'give')}</p>
88 </div>
89 </AdminSectionField>
90 </AdminSection>
91
92 {/* Campaign Goal */}
93 <AdminSection
94 title={__('Campaign Goal', 'give')}
95 description={__('How would you like to set your goal?', 'give')}
96 >
97 <AdminSectionField
98 subtitle={__('Set the details of your campaign goal here.', 'give')}
99 description={__('How would you like to set your goal?', 'give')}
100 error={errors.goalType?.message as string}
101 >
102 <select {...register('goalType')} disabled={isDisabled}>
103 <option value="amount">{__('Amount raised', 'give')}</option>
104 <option value="donations">{__('Number of donations', 'give')}</option>
105 <option value="donors">{__('Number of donors', 'give')}</option>
106 {isRecurringEnabled && (
107 <>
108 <option value="amountFromSubscriptions">
109 {__('Recurring amount raised', 'give')}
110 </option>
111 <option value="subscriptions">{__('Number of recurring donations', 'give')}</option>
112 <option value="donorsFromSubscriptions">
113 {__('Number of recurring donors', 'give')}
114 </option>
115 </>
116 )}
117 </select>
118 <div className={styles.sectionFieldDescription}>{goalInputAttributes.getHelp()}</div>
119 </AdminSectionField>
120
121 <AdminSectionField
122 subtitle={goalInputAttributes.getLabel()}
123 description={goalInputAttributes.getDescription()}
124 error={errors.goal?.message as string}
125 >
126
127 {goalInputAttributes.isCurrencyType() ? (
128 <div className={styles.sectionFieldCurrencyControl}>
129 <CurrencyControl
130 name="goal"
131 currency={currency as CurrencyCode}
132 disabled={isDisabled}
133 placeholder={goalInputAttributes.getPlaceholder()}
134 value={goal}
135 onValueChange={(value) => {
136 setValue('goal', Number(value ?? 0), {shouldDirty: true});
137 }}
138 />
139 </div>
140 ) : (
141 <input
142 type="number"
143 {...register('goal', {valueAsNumber: true})}
144 disabled={isDisabled}
145 placeholder={goalInputAttributes.getPlaceholder()}
146 />
147 )}
148
149 </AdminSectionField>
150 </AdminSection>
151
152 {/* Campaign Theme */}
153 <AdminSection
154 title={__('Campaign Theme', 'give')}
155 description={__('Choose a preferred theme for your campaign.', 'give')}
156 >
157 <AdminSectionField
158 subtitle={__('Select your preferred primary color', 'give')}
159 description={__('This will affect your main cta’s like your donate button, active and focus states of other UI elements.', 'give')}
160 error={errors.primaryColor?.message as string}
161 >
162 <ColorControl name="primaryColor" disabled={isDisabled} className={styles.colorControl} />
163 </AdminSectionField>
164
165 <AdminSectionField
166 subtitle={__('Select your preferred secondary color', 'give')}
167 description={__('This will affect your goal progress indicator, badges, icons, etc', 'give')}
168 error={errors.secondaryColor?.message as string}
169 >
170 <ColorControl name="secondaryColor" disabled={isDisabled} className={styles.colorControl} />
171 </AdminSectionField>
172 </AdminSection>
173
174 {showTooltip && (
175 <CampaignNotice
176 title={__('Campaign Settings', 'give')}
177 description={__('You can make changes to your campaign page, campaign details, campaign goal, and campaign theme. Publish your campaign when you’re done with your changes.', 'give')}
178 linkHref="https://docs.givewp.com/campaign-settings"
179 linkText={__('Learn more about campaign and form settings', 'give')}
180 handleDismiss={dismissTooltip}
181 type={'campaignSettings'}
182 />
183 )}
184 </AdminSectionsWrapper>
185 );
186 };
187