import {InspectorControls, useBlockProps} from '@wordpress/block-editor'; import {BlockEditProps} from '@wordpress/blocks'; import { __experimentalNumberControl as NumberControl, PanelBody, SelectControl, TextControl, ToggleControl, } from '@wordpress/components'; import {__} from '@wordpress/i18n'; import ServerSideRender from '@wordpress/server-side-render'; import CampaignSelector from '../shared/components/CampaignSelector'; import useCampaign from '../shared/hooks/useCampaign'; export default function Edit({ attributes, setAttributes, }: BlockEditProps<{ campaignId: number; showAnonymous: boolean; showIcon: boolean; showButton: boolean; donateButtonText: string; sortBy: string; donationsPerPage: number; loadMoreButtonText: string; }>) { const blockProps = useBlockProps(); const {campaign, hasResolved} = useCampaign(attributes.campaignId); const {showAnonymous, showIcon, showButton, donateButtonText, sortBy, donationsPerPage, loadMoreButtonText} = attributes; return (
setAttributes({campaignId})} > {hasResolved && campaign?.id && ( setAttributes({showAnonymous: value})} /> setAttributes({showIcon: value})} /> setAttributes({showButton: value})} /> setAttributes({donateButtonText: value})} help={__('This shows on the header', 'give')} /> setAttributes({sortBy: value})} help={__('The order donations are displayed in.', 'give')} /> {/* TODO: Revert the label and help text back to what are in the designs once the backend for pagination is ready */} setAttributes({donationsPerPage: parseInt(value)})} help={__('The maximum number of donations to display.', 'give')} /> {/* TODO: Revert the field back once the backend for pagination is ready setAttributes({loadMoreButtonText: value})} /> */} )}
); }