From 01b2a42830a2eb02f2fbdc42df4c2ee88547533c Mon Sep 17 00:00:00 2001 From: Elaine Date: Thu, 19 Dec 2019 10:34:59 -0500 Subject: [PATCH] adjusted json scripts & server start messages --- .gitignore | 1 + .../Questions/AddModal/ImageUpload.jsx | 78 ++++----- dist/styles.css | 156 ++++-------------- package.json | 12 +- server/index.js | 5 +- 5 files changed, 79 insertions(+), 173 deletions(-) diff --git a/.gitignore b/.gitignore index 60fcd8c..592bcd7 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ typings/ # dotenv environment variables file .env +.env.prod .env.test # parcel-bundler cache (https://parceljs.org/) diff --git a/client/components/Questions/AddModal/ImageUpload.jsx b/client/components/Questions/AddModal/ImageUpload.jsx index bf5bf96..ec95c82 100644 --- a/client/components/Questions/AddModal/ImageUpload.jsx +++ b/client/components/Questions/AddModal/ImageUpload.jsx @@ -3,46 +3,48 @@ import React, { useState } from 'react'; import ThumbnailGallery from '../ThumbnailGallery'; const ImageUpload = ({ updatePhotos }) => { - const [imagePreviews, setImagePreviews] = useState([]); - const [error, setError] = useState(''); - const uploadImage = event => { - const files = Array.from(event.target.files); - if (!files) { - setError('Please select at least 1 image.'); - } else if (files.length > 5) { - setError('Please choose only 5 images!'); - } else { - const formData = new FormData(); - files.forEach((file, i) => { - formData.append(i, file); - }); - axios - .post('/img', formData) - .then(res => { - updatePhotos(res.data); - setImagePreviews(res.data); - setError(''); - }) - .catch(() => setError('An error occurred. Please try again.')); - } - }; + const [imagePreviews, setImagePreviews] = useState([]); + const [error, setError] = useState(''); + const uploadImage = event => { + const files = Array.from(event.target.files); + if (!files) { + setError('Please select at least 1 image.'); + } else if (files.length > 5) { + setError('Please choose only 5 images!'); + } else { + const formData = new FormData(); + files.forEach((file, i) => { + formData.append(i, file); + }); + axios + .post('/img', formData) + .then(res => { + updatePhotos(res.data); + setImagePreviews(res.data); + setError(''); + }) + .catch(() => setError('An error occurred. Please try again.')); + } + }; - return ( - <> -