import React from 'react'; import { useTranslation } from 'react-i18next'; import Button from '../components/Button'; import Icon from '../components/Icon'; import ExpansionPanel from '../components/ExpansionPanel'; import TextfieldTool from './TextfieldTool'; import CheckboxTool from './CheckboxTool'; import RadioButtonTool from './RadioButtonTool'; import useStore from '../store'; import useActions from '../actions'; type Props = { sidebarState: string; onClickSidebar: (state: string) => void; }; const FormTools: React.FC = ({ sidebarState, onClickSidebar, }: Props) => { const { t } = useTranslation('sidebar'); const [{ toolState }, dispatch] = useStore(); const { setTool } = useActions(dispatch); const isActive = sidebarState === 'create-form'; const onClickTool = (state: string): void => { if (state === toolState) { setTool(''); } else { setTool(state); } }; const Label = ( ); return ( { onClickTool('textfield'); }} /> { onClickTool('checkbox'); }} /> { onClickTool('radio'); }} /> ); }; export default FormTools;