CreateForm.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. const Label = (
  21. <Button
  22. shouldFitContainer
  23. align="left"
  24. onClick={(): void => {
  25. onClickSidebar('create-form');
  26. }}
  27. >
  28. <Icon glyph="create-form" style={{ marginRight: '10px' }} />
  29. {t('createForm')}
  30. </Button>
  31. );
  32. return (
  33. <ExpansionPanel label={Label} isActive={sidebarState === 'create-form'}>
  34. <BtnWrapper>
  35. <Button shouldFitContainer align="left">
  36. <Icon glyph="text-field" style={{ marginRight: '10px' }} />
  37. {t('textField')}
  38. </Button>
  39. </BtnWrapper>
  40. <BtnWrapper>
  41. <Button shouldFitContainer align="left">
  42. <Icon glyph="checkbox" style={{ marginRight: '10px' }} />
  43. {t('checkBox')}
  44. </Button>
  45. </BtnWrapper>
  46. <BtnWrapper>
  47. <Button shouldFitContainer align="left">
  48. <Icon glyph="radio-button" style={{ marginRight: '10px' }} />
  49. {t('radioButton')}
  50. </Button>
  51. </BtnWrapper>
  52. </ExpansionPanel>
  53. );
  54. };
  55. export default CreateForm;