RecommandPage.js
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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 navigate = useNavigate();
const [Time, setTime] = useState("00:00:00");
const currentTime = () => {
const date = new Date();
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
setTime(hours+":"+minutes+":"+seconds);
}
const startTimer = () => {
setInterval(currentTime, 1000)
}
startTimer()
const navigate_login = useCallback((event) => {
navigate('../login');
})
const navigate_register = useCallback((event) => {
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">
<dir className="clock">
<h1 id="clock">{Time}</h1>
</dir>
<dir className="title">
<h1>Weather_Briefing</h1>
</dir>
<dir className="Login-Register">
<button type="button" onClick={navigate_login}>Login</button>
<button type="button" onClick={navigate_register}>Register</button>
</dir>
</dir>
<div id = "recommand_body">
<dir className="fashion_recommand">
<dir className="rainOrnot">{Rainstring}</dir>
<dir className="clothes">
<dir className="Top">
<h1>TOP</h1>
<img src={topClothes} className='Top_Image' />
</dir>
<dir className="Bottom">
<h1>BOTTOM</h1>
<img src={bottomClothes} className='Bottom_Image' />
</dir>
<dir className="Head">
<h1>HEAD</h1>
<img src={topClothes} className='Head_Image' />
</dir>
<dir className="Shoes">
<h1>SHOES</h1>
<img src={bottomClothes} className='Shoes_Image' />
</dir>
</dir>
</dir>
</div>
<dir id = "footer">
<dir className="footer_logo">
<h1>logo</h1>
</dir>
<dir className="footer_info">
<p>경희대학교</p>
<p>컴퓨터공학과 김건희ㅣ오석진ㅣ손수민</p>
</dir>
</dir>
</>
);
};
export default RecommandPage;