김건희

[Update] Weather File

...@@ -50,7 +50,6 @@ function MainPage(props) { ...@@ -50,7 +50,6 @@ function MainPage(props) {
50 50
51 useEffect(() => { 51 useEffect(() => {
52 user.then((result) => { 52 user.then((result) => {
53 - console.log(result);
54 setName(result.logData.name); 53 setName(result.logData.name);
55 setSex(result.logData.gender); 54 setSex(result.logData.gender);
56 }) 55 })
...@@ -156,12 +155,14 @@ function MainPage(props) { ...@@ -156,12 +155,14 @@ function MainPage(props) {
156 setCheckSubmitError(false); 155 setCheckSubmitError(false);
157 } 156 }
158 157
158 +
159 if (!checkSubmitError) { 159 if (!checkSubmitError) {
160 160
161 addressResult.then((result) => { 161 addressResult.then((result) => {
162 for (let i = 0; i<result.length; i++) { 162 for (let i = 0; i<result.length; i++) {
163 163
164 if (result[i].address1 === CityAdd && result[i].address2 === GuAdd && result[i].address3 === DongAdd) { 164 if (result[i].address1 === CityAdd && result[i].address2 === GuAdd && result[i].address3 === DongAdd) {
165 +
165 const dotData = { 166 const dotData = {
166 address1 : CityAdd, 167 address1 : CityAdd,
167 address2 : GuAdd, 168 address2 : GuAdd,
...@@ -170,8 +171,6 @@ function MainPage(props) { ...@@ -170,8 +171,6 @@ function MainPage(props) {
170 dotY : result[i].dotY, 171 dotY : result[i].dotY,
171 } 172 }
172 173
173 - console.log(dotData)
174 -
175 dispatch(todayInformation(dotData)); 174 dispatch(todayInformation(dotData));
176 dispatch(tommorrowInformation(dotData)); 175 dispatch(tommorrowInformation(dotData));
177 176
......
...@@ -16,9 +16,6 @@ function RecommandPage(props) { ...@@ -16,9 +16,6 @@ function RecommandPage(props) {
16 16
17 useEffect(() => { 17 useEffect(() => {
18 clothesResult.then((result) => { 18 clothesResult.then((result) => {
19 - console.log(result);
20 - console.log(result.top);
21 - console.log(result.bottom);
22 19
23 if (result.umbrella == 1) { 20 if (result.umbrella == 1) {
24 setIsRain("비 예보가 있습니다. 우산을 꼭 챙겨주세요!"); 21 setIsRain("비 예보가 있습니다. 우산을 꼭 챙겨주세요!");
......
...@@ -25,12 +25,15 @@ function WeatherPage(props) { ...@@ -25,12 +25,15 @@ function WeatherPage(props) {
25 const [tommorrowHighTemperature, setTommorrowHighTemperature] = useState(-100); 25 const [tommorrowHighTemperature, setTommorrowHighTemperature] = useState(-100);
26 const [tommorrowLowTemperature, setTommorrowLowTemperature] = useState(100); 26 const [tommorrowLowTemperature, setTommorrowLowTemperature] = useState(100);
27 const [tommorrowWeatherSymbol, setTommorrowWeatherSymbol] = useState(''); 27 const [tommorrowWeatherSymbol, setTommorrowWeatherSymbol] = useState('');
28 - const [todayWeatherLevel, setTodayWeatherLevel] = useState(''); 28 +
29 - const [userGender, setUserGender] = useState('');
30 const [cityAdd, setCityAdd] = useState(''); 29 const [cityAdd, setCityAdd] = useState('');
31 const [guAdd, setGuAdd] = useState(''); 30 const [guAdd, setGuAdd] = useState('');
32 const [dongAdd, setDongAdd] = useState(''); 31 const [dongAdd, setDongAdd] = useState('');
33 const [Time, setTime] = useState("00:00:00"); 32 const [Time, setTime] = useState("00:00:00");
33 +
34 + let todayWeatherLevel = 0;
35 + let userGender;
36 +
34 const currentTime = () => { 37 const currentTime = () => {
35 const date = new Date(); 38 const date = new Date();
36 const hours = String(date.getHours()).padStart(2, "0"); 39 const hours = String(date.getHours()).padStart(2, "0");
...@@ -60,7 +63,22 @@ function WeatherPage(props) { ...@@ -60,7 +63,22 @@ function WeatherPage(props) {
60 63
61 for (let i = 0; i<24; i++) { 64 for (let i = 0; i<24; i++) {
62 if (i === 13) { 65 if (i === 13) {
63 - setTodayWeatherLevel(result[i].weather); 66 + if (result[i].weather === 0) {
67 + todayWeatherLevel = 0;
68 + }
69 + else if (result[i].weather === 1) {
70 + todayWeatherLevel = 1;
71 + }
72 + else if (result[i].weather === 2) {
73 + todayWeatherLevel = 2;
74 + }
75 + else if (result[i].weather === 3) {
76 + todayWeatherLevel = 3;
77 + }
78 + else if (result[i].weather === 4) {
79 + todayWeatherLevel = 4;
80 + }
81 +
64 } 82 }
65 // 세부 시간 정보 83 // 세부 시간 정보
66 if (i > Number(currentHour)) { 84 if (i > Number(currentHour)) {
...@@ -103,6 +121,7 @@ function WeatherPage(props) { ...@@ -103,6 +121,7 @@ function WeatherPage(props) {
103 highTemperature = result[i].temperature; 121 highTemperature = result[i].temperature;
104 } 122 }
105 } 123 }
124 +
106 setTodayHighTemperature(highTemperature); 125 setTodayHighTemperature(highTemperature);
107 setTodayLowTemperature(lowTemperature); 126 setTodayLowTemperature(lowTemperature);
108 }) 127 })
...@@ -111,7 +130,6 @@ function WeatherPage(props) { ...@@ -111,7 +130,6 @@ function WeatherPage(props) {
111 // 내일의 날씨 130 // 내일의 날씨
112 useEffect(() => { 131 useEffect(() => {
113 tommorrowWeatherResult.then((result) => { 132 tommorrowWeatherResult.then((result) => {
114 - console.log(result);
115 133
116 let highTemperature = -100; 134 let highTemperature = -100;
117 let lowTemperature = 100; 135 let lowTemperature = 100;
...@@ -136,9 +154,19 @@ function WeatherPage(props) { ...@@ -136,9 +154,19 @@ function WeatherPage(props) {
136 }) 154 })
137 }, [tommorrowWeatherResult]) 155 }, [tommorrowWeatherResult])
138 156
157 + // 유저 성별 정보
139 useEffect(() => { 158 useEffect(() => {
159 +
140 user.then((result) => { 160 user.then((result) => {
141 - setUserGender(result.logData.gender); 161 + console.log(result);
162 +
163 + if (result.logData.gender === '0') {
164 + userGender = 0;
165 + }
166 + else {
167 + userGender = 1;
168 + }
169 +
142 }); 170 });
143 }, [user]) 171 }, [user])
144 172
...@@ -157,28 +185,22 @@ function WeatherPage(props) { ...@@ -157,28 +185,22 @@ function WeatherPage(props) {
157 185
158 const onSubmitHandler = useCallback((event) => { 186 const onSubmitHandler = useCallback((event) => {
159 event.preventDefault(); //체크박스 미리 클릭 방지 187 event.preventDefault(); //체크박스 미리 클릭 방지
160 - let todayWeather = ''; 188 +
161 let isRain = 0; 189 let isRain = 0;
162 - let tempData = [];
163 190
164 if (todayWeatherSymbol === '🌧️') { 191 if (todayWeatherSymbol === '🌧️') {
165 isRain = 1; 192 isRain = 1;
166 } 193 }
167 194
168 - tempData.push(isRain);
169 - console.log(todayWeatherLevel);
170 - console.log(userGender);
171 - console.log(isRain);
172 -
173 const sendData = { 195 const sendData = {
174 - gender : 0, 196 + gender : userGender,
175 - weather : "1", 197 + weather : todayWeatherLevel,
176 rain : isRain 198 rain : isRain
177 } 199 }
178 200
179 console.log(sendData); 201 console.log(sendData);
180 - dispatch(recommend(sendData)) 202 + dispatch(recommend(sendData));
181 - navigate('/recommand') 203 + navigate('/recommand');
182 204
183 }, [todayWeatherResult, user]); 205 }, [todayWeatherResult, user]);
184 206
......