CreateForm.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import Button from '../components/Button';
  4. import Icon from '../components/Icon';
  5. import ExpansionPanel from '../components/ExpansionPanel';
  6. import useActions from '../actions';
  7. import useStore from '../store';
  8. import { BtnWrapper } from '../global/toolStyled';
  9. const CreateForm: React.FC = () => {
  10. const { t } = useTranslation('sidebar');
  11. const [{ sidebarState }, dispatch] = useStore();
  12. const { setSidebar } = useActions(dispatch);
  13. const onClickSidebar = (state: string): void => {
  14. if (state === sidebarState) {
  15. setSidebar('');
  16. } else {
  17. setSidebar(state);
  18. }
  19. };
  20. return (
  21. <ExpansionPanel
  22. label={(
  23. <Button shouldFitContainer align="left" onClick={(): void => { onClickSidebar('create-form'); }}>
  24. <Icon glyph="create-form" style={{ marginRight: '10px' }} />
  25. {t('createForm')}
  26. </Button>
  27. )}
  28. isActive={sidebarState === 'create-form'}
  29. >
  30. <BtnWrapper>
  31. <Button shouldFitContainer align="left">
  32. <Icon glyph="text-field" style={{ marginRight: '10px' }} />
  33. {t('textField')}
  34. </Button>
  35. </BtnWrapper>
  36. <BtnWrapper>
  37. <Button shouldFitContainer align="left">
  38. <Icon glyph="checkbox" style={{ marginRight: '10px' }} />
  39. {t('checkBox')}
  40. </Button>
  41. </BtnWrapper>
  42. <BtnWrapper>
  43. <Button shouldFitContainer align="left">
  44. <Icon glyph="radio-button" style={{ marginRight: '10px' }} />
  45. {t('radioButton')}
  46. </Button>
  47. </BtnWrapper>
  48. </ExpansionPanel>
  49. );
  50. };
  51. export default CreateForm;