index.tsx 792 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import React from 'react';
  2. import Icon from '../Icon';
  3. import Button from '../Button';
  4. import { uploadFile } from '../../helpers/utility';
  5. import { ContentWrapper } from './styled';
  6. type Props = {
  7. t: (key: string) => string;
  8. onChange: (data: string) => void;
  9. };
  10. const ImageSelector: React.FC<Props> = ({
  11. t,
  12. onChange,
  13. }: Props): React.ReactElement => {
  14. const handleClick = (): void => {
  15. uploadFile('.png,.jpg,.jpeg,.svg').then((urlData: string) => {
  16. onChange(urlData);
  17. });
  18. };
  19. return (
  20. <ContentWrapper>
  21. <Icon glyph="add-image" />
  22. <Button
  23. appearance="link"
  24. style={{ marginLeft: '10px' }}
  25. onClick={handleClick}
  26. >
  27. {t('selectImage')}
  28. </Button>
  29. </ContentWrapper>
  30. );
  31. };
  32. export default ImageSelector;