From a8b0fd0f94736a3100c3b014477b1898c503718a Mon Sep 17 00:00:00 2001 From: jhynsoo Date: Wed, 25 Oct 2023 20:01:12 +0900 Subject: [PATCH] feat: Add image input --- src/pages/WriteSteps/PhotoStep.jsx | 30 ++++++++++++++++-------------- src/styles/ImageInput.styles.js | 3 ++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/pages/WriteSteps/PhotoStep.jsx b/src/pages/WriteSteps/PhotoStep.jsx index 59fab8b..ed773e0 100644 --- a/src/pages/WriteSteps/PhotoStep.jsx +++ b/src/pages/WriteSteps/PhotoStep.jsx @@ -1,27 +1,29 @@ import Button from '../../components/Button'; import ButtonArea from '../../components/ButtonArea'; +import ImageInput from '../../components/ImageInput'; import ImageViewer from '../../components/ImageViewer'; +import Spacer from '../../components/Spacer'; import * as S from '../../styles/WriteSteps.styles'; function PhotoStep({ gotoNextStep, gotoPrevStep, photos, setPhotos }) { + const handleChange = ({ target }) => { + const { files } = target; + const newPhotos = [...photos]; + Array.from(files).forEach((file) => + newPhotos.push(URL.createObjectURL(file)) + ); + setPhotos(newPhotos); + }; return ( 휴대폰 사진을 올려주세요 - 사진 - {/* TODO: upload photo */} - { - const file = e.target.files[0]; - const reader = new FileReader(); - reader.onload = () => { - setPhotos([...photos, reader.result]); - }; - reader.readAsDataURL(file); - }} + - {photos && } + + {photos.length > 0 && }