import { memo, useState, useCallback } from '@wordpress/element'; import { Button, TextControl } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { Heading, Text, Divider } from '@admin/components/Experimental'; import { EditPopoverContainer, PopoverActions, PopoverInputGroup, } from './styled'; import Mappings from '../Mappings'; import type { ValueMapping } from '../Mappings/consts'; import type { EditPopoverProps } from './consts'; import { getHeadingLabel } from '../utilities'; const EditPopover = ({ heading, onClose, onSave }: EditPopoverProps) => { const headingLabel = getHeadingLabel(heading); const originalLabel = heading.label; const [label, setLabel] = useState(headingLabel); const [mappings, setMappings] = useState(heading.overrides?.mappings || []); const handleSave = useCallback(() => { onSave({ ...heading, overrides: { ...(heading.overrides || {}), label, mappings } }); }, [heading, label, mappings, onSave]); return ( {__('Editing: ', 'petitioner')} {headingLabel} {__('ID: ', 'petitioner')} {`${heading.id}`} {__('Original label: ', 'petitioner')} {originalLabel} ); }; export default memo(EditPopover);