김건희

[Add] Weather Files

...@@ -3,6 +3,7 @@ import RegisterPage from './component/views/RegisterPage/RegisterPage'; ...@@ -3,6 +3,7 @@ import RegisterPage from './component/views/RegisterPage/RegisterPage';
3 import LoginPage from './component/views/LoginPage/LoginPage'; 3 import LoginPage from './component/views/LoginPage/LoginPage';
4 import MainPage from './component/views/MainPage/MainPage'; 4 import MainPage from './component/views/MainPage/MainPage';
5 import { Route, Routes } from 'react-router-dom'; 5 import { Route, Routes } from 'react-router-dom';
6 +import WeatherPage from './component/views/WeatherPage/WeatherPage';
6 7
7 function App() { 8 function App() {
8 return ( 9 return (
...@@ -11,6 +12,7 @@ function App() { ...@@ -11,6 +12,7 @@ function App() {
11 <Route exact path = "/login" element = {<LoginPage/>}/> 12 <Route exact path = "/login" element = {<LoginPage/>}/>
12 <Route exact path = "/register" element = {<RegisterPage/>}/> 13 <Route exact path = "/register" element = {<RegisterPage/>}/>
13 <Route exact path = "/main" element = {<MainPage/>}/> 14 <Route exact path = "/main" element = {<MainPage/>}/>
15 + <Route exact path = "/weather" element = {<WeatherPage/>}/>
14 </Routes> 16 </Routes>
15 </div> 17 </div>
16 ); 18 );
......
1 -import React, { useCallback, useState } from "react"; 1 +import React, { useCallback, useEffect, useState } from "react";
2 import { useDispatch, useSelector } from "react-redux"; 2 import { useDispatch, useSelector } from "react-redux";
3 import { useNavigate } from "react-router-dom"; 3 import { useNavigate } from "react-router-dom";
4 import { login } from "../../../modules/user"; 4 import { login } from "../../../modules/user";
...@@ -22,17 +22,19 @@ function LoginPage(props) { ...@@ -22,17 +22,19 @@ function LoginPage(props) {
22 const idRegex = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,14}$/; 22 const idRegex = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,14}$/;
23 const passwordRegex = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-?])(?=.*[0-9]).{8,25}$/; 23 const passwordRegex = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-?])(?=.*[0-9]).{8,25}$/;
24 24
25 - if (checkLogin === true) { 25 + useEffect(() => {
26 - loginResult.then((result) => { 26 + if (checkLogin === true) {
27 - if (result.loginSuccess === true) { 27 + loginResult.then((result) => {
28 - alert('로그인에 성공하였습니다.'); 28 + if (result.loginSuccess === true) {
29 - navigate('/main'); 29 + alert('로그인에 성공하였습니다.');
30 - } 30 + navigate('/main');
31 - else { 31 + }
32 - alert('로그인에 실패하였습니다.'); 32 + else {
33 - } 33 + alert('로그인에 실패하였습니다.');
34 - }) 34 + }
35 - } 35 + })
36 + }
37 + }, [loginResult])
36 38
37 const onIdHandler = useCallback((event) => { 39 const onIdHandler = useCallback((event) => {
38 setId(event.currentTarget.value); 40 setId(event.currentTarget.value);
......
1 import React, { useCallback, useEffect, useState } from "react"; 1 import React, { useCallback, useEffect, useState } from "react";
2 import { useDispatch, useSelector } from "react-redux"; 2 import { useDispatch, useSelector } from "react-redux";
3 import { useNavigate } from "react-router-dom"; 3 import { useNavigate } from "react-router-dom";
4 -import { address, coordinate, information } from "../../../modules/weather"; 4 +import { todayInformation, tommorrowInformation } from "../../../modules/weather";
5 import "../style/MainPage.scss" 5 import "../style/MainPage.scss"
6 6
7 function MainPage(props) { 7 function MainPage(props) {
...@@ -19,9 +19,8 @@ function MainPage(props) { ...@@ -19,9 +19,8 @@ function MainPage(props) {
19 const [GuAdd, setGuAdd] = useState(""); 19 const [GuAdd, setGuAdd] = useState("");
20 const [DongAdd, setDongAdd] = useState(""); 20 const [DongAdd, setDongAdd] = useState("");
21 21
22 - const [checkAddress, setCheckAddress] = useState(false); 22 + // const [checkNameError, setCheckNameError] = useState(false);
23 - const [checkNameError, setCheckNameError] = useState(false); 23 + // const [checkSexError, setCheckSexError] = useState(true);
24 - const [checkSexError, setCheckSexError] = useState(true);
25 const [checkCityAddError, setCheckCityAddError] = useState(true); 24 const [checkCityAddError, setCheckCityAddError] = useState(true);
26 const [checkGuAddError, setCheckGuAddError] = useState(true); 25 const [checkGuAddError, setCheckGuAddError] = useState(true);
27 const [checkDongAddError, setCheckDongAddError] = useState(true); 26 const [checkDongAddError, setCheckDongAddError] = useState(true);
...@@ -34,13 +33,6 @@ function MainPage(props) { ...@@ -34,13 +33,6 @@ function MainPage(props) {
34 33
35 const [Time, setTime] = useState("00:00:00"); 34 const [Time, setTime] = useState("00:00:00");
36 35
37 - useEffect(() => {
38 - user.then((result) => {
39 - setName(result.logData.name);
40 - setSex(result.logData.gender);
41 - })
42 - }, [user])
43 -
44 const currentTime = () => { 36 const currentTime = () => {
45 const date = new Date(); 37 const date = new Date();
46 const hours = String(date.getHours()).padStart(2, "0"); 38 const hours = String(date.getHours()).padStart(2, "0");
...@@ -55,6 +47,14 @@ function MainPage(props) { ...@@ -55,6 +47,14 @@ function MainPage(props) {
55 47
56 startTimer() 48 startTimer()
57 49
50 + useEffect(() => {
51 + user.then((result) => {
52 + console.log(result);
53 + setName(result.logData.name);
54 + setSex(result.logData.gender);
55 + })
56 + }, [user])
57 +
58 // 시/군/구 주소 58 // 시/군/구 주소
59 useEffect(() => { 59 useEffect(() => {
60 const tempList = []; 60 const tempList = [];
...@@ -92,23 +92,6 @@ function MainPage(props) { ...@@ -92,23 +92,6 @@ function MainPage(props) {
92 }); 92 });
93 }, [GuAdd]); 93 }, [GuAdd]);
94 94
95 - const onNameHandler = useCallback((event) => {
96 - setName(event.currentTarget.value);
97 -
98 - // 이름 유효성 검사
99 - if (event.currentTarget.value.length < 2) {
100 - setCheckNameError(true);
101 - }
102 - else {
103 - setCheckNameError(false);
104 - }
105 - }, [checkNameError]);
106 -
107 - const onSexHandler = useCallback((event) => {
108 - setSex(event.currentTarget.value);
109 - setCheckSexError(false);
110 - }, [checkSexError]);
111 -
112 const onCityAddhandler = useCallback((event) => { 95 const onCityAddhandler = useCallback((event) => {
113 setCityAdd(event.currentTarget.value); 96 setCityAdd(event.currentTarget.value);
114 97
...@@ -146,13 +129,7 @@ function MainPage(props) { ...@@ -146,13 +129,7 @@ function MainPage(props) {
146 const onSubmitHandler = useCallback((event) => { //제출 전 오류 확인 함수 129 const onSubmitHandler = useCallback((event) => { //제출 전 오류 확인 함수
147 event.preventDefault(); //체크박스 미리 클릭 방지 130 event.preventDefault(); //체크박스 미리 클릭 방지
148 131
149 - if (checkNameError || Name === "") { 132 + if (checkCityAddError || CityAdd === "") {
150 - setCheckSubmitError(true);
151 - }
152 - else if (checkSexError || Sex === "") {
153 - setCheckSubmitError(true);
154 - }
155 - else if (checkCityAddError || CityAdd === "") {
156 setCheckSubmitError(true); 133 setCheckSubmitError(true);
157 } 134 }
158 else if (checkGuAddError || GuAdd === "") { 135 else if (checkGuAddError || GuAdd === "") {
...@@ -171,20 +148,25 @@ function MainPage(props) { ...@@ -171,20 +148,25 @@ function MainPage(props) {
171 for (let i = 0; i<result.length; i++) { 148 for (let i = 0; i<result.length; i++) {
172 149
173 if (result[i].address1 === CityAdd && result[i].address2 === GuAdd && result[i].address3 === DongAdd) { 150 if (result[i].address1 === CityAdd && result[i].address2 === GuAdd && result[i].address3 === DongAdd) {
174 - console.log(CityAdd, GuAdd, DongAdd);
175 const dotData = { 151 const dotData = {
152 + address1 : CityAdd,
153 + address2 : GuAdd,
154 + address3 : DongAdd,
176 dotX : result[i].dotX, 155 dotX : result[i].dotX,
177 dotY : result[i].dotY, 156 dotY : result[i].dotY,
178 } 157 }
179 158
180 - dispatch(information(dotData)); 159 + dispatch(todayInformation(dotData));
160 + dispatch(tommorrowInformation(dotData));
161 +
162 + navigate('/weather');
181 break; 163 break;
182 } 164 }
183 } 165 }
184 }) 166 })
185 } 167 }
186 168
187 - }, [checkNameError, checkSexError, checkCityAddError, checkDongAddError, checkGuAddError, checkSubmitError, Name, Sex, CityAdd, GuAdd, DongAdd]); 169 + }, [checkCityAddError, checkDongAddError, checkGuAddError, checkSubmitError, Name, Sex, CityAdd, GuAdd, DongAdd]);
188 170
189 return ( 171 return (
190 <> 172 <>
...@@ -204,34 +186,28 @@ function MainPage(props) { ...@@ -204,34 +186,28 @@ function MainPage(props) {
204 <div id = "body"> 186 <div id = "body">
205 <div className="info-box"> 187 <div className="info-box">
206 <p className="info">정보를 입력해주세요.</p> 188 <p className="info">정보를 입력해주세요.</p>
207 - <div className="main-input-area"> 189 + <div className="main-input-area" readOnly>
208 <li>이름</li> 190 <li>이름</li>
209 <input 191 <input
210 placeholder={Name} 192 placeholder={Name}
211 type="text" 193 type="text"
212 value={Name} 194 value={Name}
213 - onChange={onNameHandler}
214 /> 195 />
215 </div> 196 </div>
216 - <div className="main-check-variable">
217 - {checkNameError && <div style={{color : 'red'}}>이름을 두글자 이상 입력해 주세요.</div>}
218 - </div>
219 <hr/> 197 <hr/>
220 - <div className="main-input-area"> 198 + <div className="main-input-area" readOnly>
221 <li>성별</li> 199 <li>성별</li>
222 <p>남자</p> 200 <p>남자</p>
223 <input 201 <input
224 type="radio" //라디오 버튼 타입 202 type="radio" //라디오 버튼 타입
225 value = "0" 203 value = "0"
226 checked = {Sex === "0"} 204 checked = {Sex === "0"}
227 - onChange={onSexHandler}
228 /> 205 />
229 <p>여자</p> 206 <p>여자</p>
230 <input 207 <input
231 type="radio" 208 type="radio"
232 value = "1" 209 value = "1"
233 checked = {Sex === "1"} 210 checked = {Sex === "1"}
234 - onChange={onSexHandler}
235 /> 211 />
236 </div> 212 </div>
237 <hr/> 213 <hr/>
......
...@@ -27,20 +27,22 @@ function RegisterPage(props) { ...@@ -27,20 +27,22 @@ function RegisterPage(props) {
27 const idRegex = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,14}$/; 27 const idRegex = /^(?=.*[a-zA-Z])(?=.*[0-9]).{6,14}$/;
28 const passwordRegex = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-?])(?=.*[0-9]).{8,25}$/; 28 const passwordRegex = /^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-?])(?=.*[0-9]).{8,25}$/;
29 29
30 - if (checkRegister === true) { 30 + useEffect(() => {
31 - registerResult.then((result) => { 31 + if (checkRegister === true) {
32 - if (result.registerSuccess === '1') { 32 + registerResult.then((result) => {
33 - alert('회원 가입에 성공하였습니다.'); 33 + if (result.registerSuccess === '1') {
34 - navigate('/login'); 34 + alert('회원 가입에 성공하였습니다.');
35 - } 35 + navigate('/login');
36 - else if (result.registerSuccess === '0') { 36 + }
37 - alert('중복된 아이디가 존재합니다.'); 37 + else if (result.registerSuccess === '0') {
38 - } 38 + alert('중복된 아이디가 존재합니다.');
39 - else { 39 + }
40 - alert('회원 가입에 실패하였습니다.'); 40 + else {
41 - } 41 + alert('회원 가입에 실패하였습니다.');
42 - }) 42 + }
43 - } 43 + })
44 + }
45 + }, [registerResult])
44 46
45 const onIdHandler = useCallback((event) => { 47 const onIdHandler = useCallback((event) => {
46 setId(event.currentTarget.value); 48 setId(event.currentTarget.value);
......
1 +import React, { useCallback, useEffect, useState } from "react";
2 +import { useDispatch, useSelector } from "react-redux";
3 +import { useNavigate } from "react-router-dom";
4 +import { recommend } from "../../../modules/clothes";
5 +import "../style/WeatherPage.scss"
6 +
7 +function WeatherPage(props) {
8 +
9 + const dispatch = useDispatch();
10 + const navigate = useNavigate();
11 +
12 + const user = useSelector((state) => state.user.loginData);
13 + const todayWeatherResult = useSelector((state) => state.weather.todayInformation);
14 + const tommorrowWeatherResult = useSelector((state) => state.weather.tommorrowInformation);
15 +
16 + const today = new Date();
17 + const detailWeather = [];
18 + let currentHour;
19 +
20 + const today_year = today.getFullYear();
21 + const today_month = today.getMonth();
22 + const today_date = today.getDate();
23 +
24 + const [todayHighTemperature, setTodayHighTemperature] = useState(-100);
25 + const [todayLowTemperature, setTodayLowTemperature] = useState(100);
26 + const [todayWeatherSymbol, setTodayWeatherSymbol] = useState('☀️');
27 + const [nowWeatherSymbol, setNowWeatherSymbol] = useState('');
28 + const [nowTemperature, setNowTemperature] = useState("");
29 + const [tommorrowHighTemperature, setTommorrowHighTemperature] = useState(-100);
30 + const [tommorrowLowTemperature, setTommorrowLowTemperature] = useState(100);
31 + const [tommorrowWeatherSymbol, setTommorrowWeatherSymbol] = useState('');
32 + const [todayWeatherLevel, setTodayWeatherLevel] = useState('');
33 + const [userGender, setUserGender] = useState('');
34 +
35 + const [cityAdd, setCityAdd] = useState('');
36 + const [guAdd, setGuAdd] = useState('');
37 + const [dongAdd, setDongAdd] = useState('');
38 +
39 + const [Time, setTime] = useState("00:00:00");
40 +
41 + const currentTime = () => {
42 + const date = new Date();
43 + const hours = String(date.getHours()).padStart(2, "0");
44 + const minutes = String(date.getMinutes()).padStart(2, "0");
45 + const seconds = String(date.getSeconds()).padStart(2, "0");
46 + setTime(hours+" : "+minutes+" : "+seconds);
47 + }
48 +
49 + const startTimer = () => {
50 + setInterval(currentTime, 1000)
51 + }
52 +
53 + startTimer()
54 +
55 + useEffect(() => {
56 +
57 + todayWeatherResult.then((result) => {
58 +
59 + let highTemperature = -100;
60 + let lowTemperature = 100;
61 + let symbol = '';
62 +
63 + currentHour = Time[0] + Time[1];
64 +
65 + // 주소 설정
66 + setCityAdd(result[24].address1);
67 + setGuAdd(result[24].address2);
68 + setDongAdd(result[24].address3);
69 +
70 + for (let i = 0; i<24; i++) {
71 +
72 + if (i === 13) {
73 + setTodayWeatherLevel(result[i].weather);
74 + }
75 +
76 + // 세부 시간 정보
77 + if (i > Number(currentHour)) {
78 + if (result[i].rainPer >= 50) {
79 + symbol = '🌧️';
80 + setTodayWeatherSymbol('🌧️');
81 + }
82 + else if (i > 18 || i < 6) {
83 + symbol = '🌙';
84 + }
85 + else {
86 + symbol = '☀️';
87 + }
88 +
89 + const tempData = {
90 + time : result[i].time,
91 + temperature : result[i].temperature,
92 + symbol : symbol,
93 + }
94 +
95 + detailWeather.push(tempData);
96 + }
97 +
98 + // 현재 시간 정보 다루는 부분
99 + if (i === Number(currentHour)) {
100 + if (result[i].rainPer >= 50) {
101 + setNowWeatherSymbol('🌧️');
102 + }
103 + else if (i >= 18 || i < 6) {
104 + setNowWeatherSymbol('🌙');
105 + }
106 + else {
107 + setNowWeatherSymbol('☀️');
108 + }
109 +
110 + setNowTemperature(result[i].temperature);
111 + }
112 +
113 + // 하루 온도 정보 다루는 부분
114 + if (result[i].temperature < lowTemperature) {
115 + lowTemperature = result[i].temperature;
116 + }
117 +
118 + if (result[i].temperature > highTemperature) {
119 + highTemperature = result[i].temperature;
120 + }
121 + }
122 +
123 + setTodayHighTemperature(highTemperature);
124 + setTodayLowTemperature(lowTemperature);
125 + })
126 + }, [todayWeatherResult, Time])
127 +
128 + // 내일의 날씨
129 + useEffect(() => {
130 + tommorrowWeatherResult.then((result) => {
131 + console.log(result);
132 +
133 + let highTemperature = -100;
134 + let lowTemperature = 100;
135 + let symbol = '☀️';
136 +
137 + for (let i = 0; i < 24; i++) {
138 + // symbol 설정
139 + if (result[i].rainPer >= 50) {
140 + symbol = '🌧️';
141 + }
142 +
143 + // 내일 온도 정보 다루는 부분
144 + if (result[i].temperature < lowTemperature) {
145 + lowTemperature = result[i].temperature;
146 + }
147 +
148 + if (result[i].temperature > highTemperature) {
149 + highTemperature = result[i].temperature;
150 + }
151 +
152 + setTommorrowHighTemperature(highTemperature);
153 + setTommorrowLowTemperature(lowTemperature);
154 + setTommorrowWeatherSymbol(symbol);
155 +
156 + }
157 + })
158 + }, [tommorrowWeatherResult])
159 +
160 + useEffect(() => {
161 + user.then((result) => {
162 + setUserGender(result.logData.gender);
163 + });
164 + }, [user])
165 +
166 + const onSubmitHandler = useCallback((event) => {
167 + event.preventDefault(); //체크박스 미리 클릭 방지
168 +
169 + let todayWeather = '';
170 + let isRain = 0;
171 +
172 + let tempData = [];
173 +
174 + if (todayWeatherSymbol === '🌧️') {
175 + isRain = 1;
176 + }
177 + tempData.push(isRain);
178 +
179 + console.log(todayWeatherLevel);
180 + console.log(userGender);
181 + console.log(isRain);
182 +
183 +
184 + const sendData = {
185 + gender : 0,
186 + weather : "1",
187 + rain : isRain
188 + }
189 +
190 + console.log(sendData);
191 +
192 + dispatch(recommend(sendData))
193 +
194 + }, [todayWeatherResult, user]);
195 +
196 + return (
197 + <>
198 + <dir id = "header">
199 + <dir className="clock">
200 + <h1 id="clock">{Time}</h1>
201 + </dir>
202 + <dir className="title">
203 + <h1>Weather_Briefing</h1>
204 + </dir>
205 + <dir className="Login-Register">
206 + <button type="button" >Login</button>
207 + <button type="button" >Register</button>
208 + </dir>
209 + </dir>
210 +
211 + <div id = "body">
212 + <div className="address">
213 + <p>{cityAdd} {guAdd} {dongAdd}</p>
214 + </div>
215 + <div className="today_weather">
216 + <div className="days">
217 + <h1>오늘의 날씨</h1>
218 + <h2 id="day">{today_year} {today_month + 1} {today_date}</h2>
219 + </div>
220 + <div className="today_now_weather_info">
221 + <h2>현재 온도</h2>
222 + <h1 id="present_do">{nowWeatherSymbol} {nowTemperature}</h1>
223 + </div>
224 + <div className="today_weather_info">
225 + <h2>전체 날씨</h2>
226 + <div className="today_whole_weather">
227 + <h1>{todayWeatherSymbol}</h1>
228 + <div className="today_whole_weather_temperature">
229 + <p>최고: {todayHighTemperature}</p>
230 + <p>최저: {todayLowTemperature}</p>
231 + </div>
232 + </div>
233 + </div>
234 + </div>
235 + <div className="tommorrow_weather">
236 + <div className="days">
237 + <h1>내일의 날씨</h1>
238 + <h2 id="day">{today_year} {today_month + 1} {today_date+1}</h2>
239 + </div>
240 + <div className="tommorrow_weather_info">
241 + <h2>날씨 정보</h2>
242 + <div className="tommorrow_whole_weather">
243 + <h1>{tommorrowWeatherSymbol}</h1>
244 + <div className="tommorrow_temperator">
245 + <p>최고: {tommorrowHighTemperature}</p>
246 + <p>최저: {tommorrowLowTemperature}</p>
247 + </div>
248 + </div>
249 +
250 + </div>
251 + </div>
252 + <div className="weather-btn-area" onClick={onSubmitHandler}>
253 + <button className="submit-btn">
254 + 양식 제출
255 + </button>
256 + </div>
257 + </div>
258 + </>
259 + );
260 +}
261 +
262 +export default WeatherPage;
...\ No newline at end of file ...\ No newline at end of file
1 +#body {
2 + display: flex;
3 + justify-content: center;
4 + align-items: center;
5 + flex-wrap: wrap;
6 + flex-direction: column;
7 + border-top: 2px solid;
8 + border-bottom: 2px solid;
9 + .address {
10 + display: flex;
11 + justify-content: center;
12 + align-items: center;
13 + margin-top: 150px;
14 + font-size: 30px;
15 + }
16 + .today_weather {
17 + display: flex;
18 + justify-content: center;
19 + align-items: center;
20 + border: 2px solid;
21 + width: 50%;
22 + margin-top: 30px;
23 + margin-bottom: 10px;
24 + .today_now_weather_info {
25 + display: flex;
26 + justify-content: center;
27 + align-items: center;
28 + flex-direction: column;
29 + margin-right: 30px;
30 + }
31 + .days {
32 + display: flex;
33 + justify-content: center;
34 + align-items: center;
35 + flex-wrap: wrap;
36 + flex-direction: column;
37 + margin-top: 25px;
38 + margin-bottom: 25px;
39 + margin-left: 15px;
40 + margin-right: 200px;
41 + }
42 + .today_whole_weather{
43 + display: flex;
44 + flex-direction: row;
45 + }
46 + }
47 +
48 + .tommorrow_weather {
49 + display: flex;
50 + justify-content: center;
51 + align-items: center;
52 + border: 2px solid;
53 + width: 50%;
54 + margin-top: 20px;
55 + margin-bottom: 20px;
56 + .days {
57 + display: flex;
58 + justify-content: center;
59 + align-items: center;
60 + flex-wrap: wrap;
61 + flex-direction: column;
62 + margin-top: 25px;
63 + margin-bottom: 25px;
64 + margin-left: 15px;
65 + margin-right: 200px;
66 + }
67 + .tommorrow_weather_info {
68 + display: flex;
69 + justify-content: center;
70 + align-items: center;
71 + flex-direction: column;
72 + margin-right: 30px;
73 + .tommorrow_whole_weather{
74 + display: flex;
75 + flex-direction: row;
76 + }
77 + }
78 + }
79 + .weather-btn-area {
80 + display: flex;
81 + justify-content: center;
82 + margin-top: 20px;
83 + margin-bottom: 10px;
84 +
85 + button {
86 + width: 150px;
87 + height: 60px;
88 + font-size: 15px;
89 + font-weight: bold;
90 + background-color:rgb(255, 253, 238);
91 + cursor: pointer;
92 + }
93 + }
94 + }
...\ No newline at end of file ...\ No newline at end of file
1 import { combineReducers } from "redux"; 1 import { combineReducers } from "redux";
2 import user from "./user.js"; 2 import user from "./user.js";
3 import weather from "./weather"; 3 import weather from "./weather";
4 +import clothes from "./clothes";
4 5
5 const rootReducer = combineReducers({ 6 const rootReducer = combineReducers({
6 user, 7 user,
7 weather, 8 weather,
9 + clothes,
8 }) 10 })
9 11
10 export default rootReducer; 12 export default rootReducer;
...\ No newline at end of file ...\ No newline at end of file
......
1 +import axios from "axios";
2 +
3 +const CLOTHES_RECOMMEND = 'weather/RECOMMEND';
4 +
5 +export function recommend() {
6 + const req = axios.post('http://localhost:4000/api/clothes')
7 + .then(res => res.data);
8 +
9 + return {
10 + type: CLOTHES_RECOMMEND,
11 + payload: req,
12 + }
13 +}
14 +
15 +export default function (state = {}, action) {
16 + switch (action.type) {
17 + case CLOTHES_RECOMMEND:
18 + return { ...state, clothesRecommend: action.payload };
19 + break;
20 + default:
21 + return state;
22 + }
23 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,6 +3,7 @@ import axios from 'axios'; ...@@ -3,6 +3,7 @@ import axios from 'axios';
3 const USER_REGISTER = 'user/REGISTER'; 3 const USER_REGISTER = 'user/REGISTER';
4 const USER_LOGIN = 'user/LOGIN'; 4 const USER_LOGIN = 'user/LOGIN';
5 const USER_LOGOUT = 'user/LOGOUT'; 5 const USER_LOGOUT = 'user/LOGOUT';
6 +const USER_DATA = 'user/DATA';
6 7
7 export function register (dataToSubmit) { 8 export function register (dataToSubmit) {
8 9
......
...@@ -3,6 +3,7 @@ import axios from "axios"; ...@@ -3,6 +3,7 @@ import axios from "axios";
3 const WEATHER_ADDRESS = 'weather/ADDRESS'; 3 const WEATHER_ADDRESS = 'weather/ADDRESS';
4 const WEATHER_COORDINATE = 'weather/COORDINATE'; 4 const WEATHER_COORDINATE = 'weather/COORDINATE';
5 const WEATHER_TODAY_INFORMATION = 'weather/TODAY_INFORMATION'; 5 const WEATHER_TODAY_INFORMATION = 'weather/TODAY_INFORMATION';
6 +const WEATHER_TOMMORROW_INFORMATION = 'weather/TOMMORROW_INFORMATION';
6 7
7 export function address() { 8 export function address() {
8 const req = axios.post('http://localhost:4000/api/address') 9 const req = axios.post('http://localhost:4000/api/address')
...@@ -25,7 +26,7 @@ export function coordinate(dataToSubmit) { ...@@ -25,7 +26,7 @@ export function coordinate(dataToSubmit) {
25 } 26 }
26 }; 27 };
27 28
28 -export function information(dataToSubmit) { 29 +export function todayInformation(dataToSubmit) {
29 30
30 const req = axios.post('http://localhost:4000/api/weather', dataToSubmit) 31 const req = axios.post('http://localhost:4000/api/weather', dataToSubmit)
31 .then(res => res.data); 32 .then(res => res.data);
...@@ -36,6 +37,17 @@ export function information(dataToSubmit) { ...@@ -36,6 +37,17 @@ export function information(dataToSubmit) {
36 } 37 }
37 }; 38 };
38 39
40 +export function tommorrowInformation(dataToSubmit) {
41 +
42 + const req = axios.post('http://localhost:4000/api/tommorrow', dataToSubmit)
43 + .then(res => res.data);
44 +
45 + return {
46 + type: WEATHER_TOMMORROW_INFORMATION,
47 + payload: req,
48 + }
49 +};
50 +
39 export default function (state = {}, action) { 51 export default function (state = {}, action) {
40 switch (action.type) { 52 switch (action.type) {
41 case WEATHER_ADDRESS: 53 case WEATHER_ADDRESS:
...@@ -47,6 +59,9 @@ export default function (state = {}, action) { ...@@ -47,6 +59,9 @@ export default function (state = {}, action) {
47 case WEATHER_TODAY_INFORMATION: 59 case WEATHER_TODAY_INFORMATION:
48 return { ...state, todayInformation: action.payload }; 60 return { ...state, todayInformation: action.payload };
49 break; 61 break;
62 + case WEATHER_TOMMORROW_INFORMATION:
63 + return { ...state, tommorrowInformation: action.payload };
64 + break;
50 default: 65 default:
51 return state; 66 return state;
52 } 67 }
......