index.tsx 788 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 = () => {
  15. uploadFile('.png,.jpg,.jpeg,.svg')
  16. .then((urlData) => {
  17. onChange(urlData);
  18. });
  19. };
  20. return (
  21. <ContentWrapper>
  22. <Icon glyph="add-image" />
  23. <Button
  24. appearance="link"
  25. style={{ marginLeft: '10px' }}
  26. onClick={handleClick}
  27. >
  28. {t('selectImage')}
  29. </Button>
  30. </ContentWrapper>
  31. )
  32. };
  33. export default ImageSelector;