123456789101112131415161718192021222324252627282930313233343536373839 |
- import React from 'react';
- import Icon from '../Icon';
- import Button from '../Button';
- import { uploadFile } from '../../helpers/utility';
- import { ContentWrapper } from './styled';
- type Props = {
- t: (key: string) => string;
- onChange: (data: string) => void;
- };
- const ImageSelector: React.FC<Props> = ({
- t,
- onChange,
- }: Props): React.ReactElement => {
- const handleClick = () => {
- uploadFile('.png,.jpg,.jpeg,.svg')
- .then((urlData) => {
- onChange(urlData);
- });
- };
- return (
- <ContentWrapper>
- <Icon glyph="add-image" />
- <Button
- appearance="link"
- style={{ marginLeft: '10px' }}
- onClick={handleClick}
- >
- {t('selectImage')}
- </Button>
- </ContentWrapper>
- )
- };
- export default ImageSelector;
|