import {InspectorControls, useBlockProps} from '@wordpress/block-editor'; import {__} from '@wordpress/i18n'; import {BlockEditProps} from '@wordpress/blocks'; import {PanelBody, SelectControl} from '@wordpress/components'; import CampaignSelector from '../shared/components/CampaignSelector'; import ServerSideRender from '@wordpress/server-side-render'; import useCampaign from '../shared/hooks/useCampaign'; import './styles.scss'; type statisticType = 'top-donation' | 'average-donation'; export default function Edit({ attributes, setAttributes, }: BlockEditProps<{ campaignId: number; statistic: statisticType; }>) { const blockProps = useBlockProps(); const {campaign, hasResolved} = useCampaign(attributes?.campaignId); const statsHelpText = attributes.statistic === 'top-donation' ? __('Displays the top donation of the selected campaign.', 'give') : __('Displays the average donation of the selected campaign.', 'give'); return (
setAttributes({campaignId})} > {hasResolved && campaign?.id && ( setAttributes({statistic: value})} /> )}
); }