import React, { ChangeEvent, MouseEvent, useState } from 'react'; import { Modal } from 'react-responsive-modal'; import { Button, Flex } from '@wordpress/components'; import GuaranteeBadge from '../../components/Badges/GuaranteeBadge'; import ReviewBadge from '../../components/Badges/ReviewBadge'; import TrustBadgeInterface from '../../interfaces/TrustBadgeInterface'; import MediaLibraryButton from './MediaLibraryButton'; import RichTextArea from './RichTextArea'; import { cfw__ } from '../../functions/translationWrappers'; import RuleSet from './Metaboxes/Fields/Rules/RuleSet'; import { RuleType } from './Metaboxes/Fields/Rules/RuleField'; interface TrustBadgeRowProps { badge: TrustBadgeInterface; setBadge: ( badge: TrustBadgeInterface ) => void; removeHandler: ( event: MouseEvent ) => void; dragHandleProps: any; // You might want to use a specific type if you know the shape or library you're using } function TrustBadgeRow( { badge, setBadge, removeHandler, dragHandleProps }: TrustBadgeRowProps ): React.JSX.Element { const [ isOpen, setIsOpen ] = useState( false ); const setTitle = ( value: string ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.title = value; setBadge( badgeCopy ); }; const setSubTitle = ( value: string ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.subtitle = value; setBadge( badgeCopy ); }; const setDescription = ( value: string ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.description = value; setBadge( badgeCopy ); }; const setImage = ( value: Record ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.image = value; setBadge( badgeCopy ); }; const setTemplate = ( value: string ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.template = value; setBadge( badgeCopy ); }; const setMode = ( value: string ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.mode = value; setBadge( badgeCopy ); }; const setRules = ( value: RuleType[] ) => { const badgeCopy: TrustBadgeInterface = { ...badge }; badgeCopy.rules = value; setBadge( badgeCopy ); }; return (
setIsOpen( false )} center={true} classNames={{ root: 'cfw-modal-root', overlay: 'cfw-modal-overlay', modal: 'cfw-modal', modalContainer: 'cfw-modal-container', }} showCloseIcon={false} >

Display Conditions

Determine when this Trust Badge should be displayed.

{badge.template === 'guarantee' ? ( ) : ( )}
); } export default TrustBadgeRow;