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 / DonationForms / resources / app / form / Section.tsx

Section.tsx in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/DonationForms/resources/app/form/Section.tsx

39 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {withTemplateWrapper} from '@givewp/forms/app/templates';
2 import SectionNode from '@givewp/forms/app/fields/SectionNode';
3 import useVisibilityCondition from '@givewp/forms/app/hooks/useVisibilityCondition';
4 import {Field, isField, Section as SectionType} from '@givewp/forms/types';
5 import DonationFormErrorBoundary from '@givewp/forms/app/errors/boundaries/DonationFormErrorBoundary';
6 import {useEffect} from '@wordpress/element';
7
8 const formTemplates = window.givewp.form.templates;
9 const FormSectionTemplate = withTemplateWrapper(formTemplates.layouts.section, 'section');
10
11 export default function Section({section}: {section: SectionType}) {
12 const showNode = useVisibilityCondition(section.visibilityConditions);
13 const {unregister} = window.givewp.form.hooks.useFormContext();
14
15 useEffect(() => {
16 if (showNode) {
17 return;
18 }
19
20 section.walkNodes((field: Field) => {
21 unregister(field.name);
22 }, isField);
23 }, [showNode]);
24
25 if (!showNode) {
26 return null;
27 }
28
29 return (
30 <FormSectionTemplate section={section}>
31 {section.nodes.map((node) => (
32 <DonationFormErrorBoundary key={node.name}>
33 <SectionNode node={node} />
34 </DonationFormErrorBoundary>
35 ))}
36 </FormSectionTemplate>
37 );
38 }
39