diff --git a/src/views/examples/FileUploaderPage.js b/src/views/examples/FileUploaderPage.js index 555f05e..9f11ade 100644 --- a/src/views/examples/FileUploaderPage.js +++ b/src/views/examples/FileUploaderPage.js @@ -1,6 +1,7 @@ import React, {useState} from 'react'; import axios from 'axios'; import FileUpload from 'components/Functions/FileUpload'; +import { useNavigate } from 'react-router-dom'; // reactstrap components import { @@ -15,6 +16,9 @@ import DefaultFooter from "components/Footers/DefaultFooter.js"; function FileUploaderPage() { + // 페이지 이동을 위한 navigate + const navigate = useNavigate(); + const [URLThumbnail, setURLThumbnail] = useState(); const createImageURL = (fileBlob) => { // createObjectURL 방식 @@ -33,13 +37,13 @@ function FileUploaderPage() { const uploadImage = files[0]; let nickname = sessionStorage.getItem('nickname'); - createImageURL(uploadImage); if (uploadImage) { + let formData = new FormData(); formData.append('file', uploadImage); - formData.append('nickname', 'yourNickname'); + formData.append('nickname', nickname); axios({ method:'post', @@ -52,6 +56,7 @@ function FileUploaderPage() { .then(function(response){ // 업로드 성공 시 실행할 코드 console.log('이미지 업로드 성공'); + navigate(`/result`); }) .catch(function(error){ // 업로드 실패 시 실행할 코드 diff --git a/src/views/examples/ResultPage.js b/src/views/examples/ResultPage.js index acd4ce0..1bedf8c 100644 --- a/src/views/examples/ResultPage.js +++ b/src/views/examples/ResultPage.js @@ -16,19 +16,21 @@ import DefaultFooter from "components/Footers/DefaultFooter.js"; function ResultPage () { - React.useEffect(() => { - document.body.classList.add("landing-page"); - document.body.classList.add("sidebar-collapse"); - document.documentElement.classList.remove("nav-open"); - window.scrollTo(0, 0); - document.body.scrollTop = 0; - return function cleanup() { - document.body.classList.remove("landing-page"); - document.body.classList.remove("sidebar-collapse"); - }; - }, []); - - + React.useEffect(() => { + document.body.classList.add("landing-page"); + document.body.classList.add("sidebar-collapse"); + document.documentElement.classList.remove("nav-open"); + window.scrollTo(0, 0); + document.body.scrollTop = 0; + return function cleanup() { + document.body.classList.remove("landing-page"); + document.body.classList.remove("sidebar-collapse"); + }; + }, []); + + // 세션 스토리지에서 nickname 가져오기 + const nickname = sessionStorage.getItem('nickname'); + return ( <> @@ -38,9 +40,9 @@ function ResultPage () { -

ooo님의 두피 검사 결과입니다!

-



- +

{nickname}님의 두피 검사 결과입니다!

+ +