aboutsummaryrefslogtreecommitdiff
path: root/src/containers/PollCreation/ImageInput.tsx
diff options
context:
space:
mode:
authorEugene Sokolov <eug-vs@keemail.me>2020-08-22 14:56:07 +0300
committerGitHub <noreply@github.com>2020-08-22 14:56:07 +0300
commit89f038c7a0ccf6de94516cba8499a0bc69f8dae1 (patch)
tree5e6dbd7ae5a9d0ce1b79921b2b44986bb13f1874 /src/containers/PollCreation/ImageInput.tsx
parenta42667af463b8c33a38b935b96d39582b543790b (diff)
parent93319d38e904535ce33a7868b3c1e0a2a4f33d65 (diff)
downloadwhich-ui-89f038c7a0ccf6de94516cba8499a0bc69f8dae1.tar.gz
Merge pull request #93 from which-ecosystem/avatar-uploads
Avatar uploads
Diffstat (limited to 'src/containers/PollCreation/ImageInput.tsx')
-rw-r--r--src/containers/PollCreation/ImageInput.tsx10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/containers/PollCreation/ImageInput.tsx b/src/containers/PollCreation/ImageInput.tsx
index 475d527..e807865 100644
--- a/src/containers/PollCreation/ImageInput.tsx
+++ b/src/containers/PollCreation/ImageInput.tsx
@@ -10,6 +10,7 @@ import { Check, CancelOutlined } from '@material-ui/icons';
import AttachLink from '../../components/AttachLink/AttachLink';
import FileUpload from '../../components/FileUpload/FileUpload';
import BackgroundImage from '../../components/Image/BackgroundImage';
+import getLocalFileUrl from '../../utils/getLocalFileUrl';
interface PropTypes {
callback: (file?: File | string) => void;
@@ -59,9 +60,12 @@ const ImageInput: React.FC<PropTypes> = ({ callback, progress }) => {
callback(undefined);
};
- const childrenCallback = (fileUrl: string, file?: File) => {
- setUrl(fileUrl);
- callback(file || fileUrl);
+ const childrenCallback = (value: File | string) => {
+ if (value instanceof File) {
+ getLocalFileUrl(value).then(localUrl => setUrl(localUrl));
+ } else setUrl(value);
+
+ callback(value);
};
const Upload = (