손수민

[Update] Recommand Page Server Function Update

Showing 25 changed files with 31 additions and 45 deletions
......@@ -2,11 +2,33 @@ import React, { useCallback, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import "../style/RecommandPage.scss"
import axios from 'axios';
function RecommandPage(props) {
const clothesResult = useSelector((state) => state.clothes.clothesRecommend);
const [IsRain, setIsRain] = useState("");
const [TopPath, setTopPath] = useState('');
const [BottomPath, setBottomPath] = useState('');
useEffect(() => {
clothesResult.then((result) => {
console.log(result);
console.log(result.top);
console.log(result.bottom);
if (result.umbrella == 1) {
setIsRain("비 예보가 있습니다. 우산을 꼭 챙겨주세요!");
}
else {
setIsRain("비 예보가 없습니다!");
}
setTopPath(result.top);
setBottomPath(result.bottom);
})
}, [clothesResult])
const navigate = useNavigate();
const [Time, setTime] = useState("00:00:00");
......@@ -33,42 +55,6 @@ function RecommandPage(props) {
navigate('../register');
})
console.log(initData);
useEffect(async() => {
try{
const res = await axios.post('localhost:4000/api/weather')
const _inputData = await res.data.map((weatherData) => (
{
today: weatherData.today,
time: weatherData.time,
temperature: weatherData.temperature,
rainper: weatherData.rainper,
weather: weatherData.weather
})
)
// initData 그릇에 concat 으로 추가
setInitData(initData.concat(_inputData))
} catch(e){
console.error(e.message)
}
},[])
const [Rainstring, setRainstring] = useState("");
const rain = () => {
if(initData.inputData.umbrella == 1) {
setRainstring("비 예보가 있습니다. 우산을 꼭 챙겨주세요!");
}
else if(initData.inputData.umbrella == 0) {
setRainstring("비 예보가 없습니다!");
}
} //weather.js
rain();
const [topPath, settopPath] = useState([""]);
const [bottomPath, setbottomPath] = useState([""]); //clothes.js
return (
<>
<dir id = "header">
......@@ -86,24 +72,24 @@ function RecommandPage(props) {
<div id = "recommand_body">
<dir className="fashion_recommand">
<dir className="rainOrnot">{Rainstring}</dir>
<dir className="rainOrnot">{IsRain}</dir>
<dir className="clothes">
<dir className="Top">
<h1>TOP</h1>
<img src={topClothes} className='Top_Image' />
<img src={TopPath} className='Top_Image' />
</dir>
<dir className="Bottom">
<h1>BOTTOM</h1>
<img src={bottomClothes} className='Bottom_Image' />
<img src={BottomPath} className='Bottom_Image' />
</dir>
<dir className="Head">
{/* <dir className="Head">
<h1>HEAD</h1>
<img src={topClothes} className='Head_Image' />
<img src="../../../img/조거팬츠.jpg" className='Head_Image' />
</dir>
<dir className="Shoes">
<h1>SHOES</h1>
<img src={bottomClothes} className='Shoes_Image' />
</dir>
<img src="../../../../src/img/조거팬츠.jpg" className='Shoes_Image' />
</dir> */}
</dir>
</dir>
</div>
......