김건희

[Update] Weather File

......@@ -50,7 +50,6 @@ function MainPage(props) {
useEffect(() => {
user.then((result) => {
console.log(result);
setName(result.logData.name);
setSex(result.logData.gender);
})
......@@ -156,12 +155,14 @@ function MainPage(props) {
setCheckSubmitError(false);
}
if (!checkSubmitError) {
addressResult.then((result) => {
for (let i = 0; i<result.length; i++) {
if (result[i].address1 === CityAdd && result[i].address2 === GuAdd && result[i].address3 === DongAdd) {
const dotData = {
address1 : CityAdd,
address2 : GuAdd,
......@@ -170,8 +171,6 @@ function MainPage(props) {
dotY : result[i].dotY,
}
console.log(dotData)
dispatch(todayInformation(dotData));
dispatch(tommorrowInformation(dotData));
......
......@@ -16,9 +16,6 @@ function RecommandPage(props) {
useEffect(() => {
clothesResult.then((result) => {
console.log(result);
console.log(result.top);
console.log(result.bottom);
if (result.umbrella == 1) {
setIsRain("비 예보가 있습니다. 우산을 꼭 챙겨주세요!");
......
......@@ -25,12 +25,15 @@ function WeatherPage(props) {
const [tommorrowHighTemperature, setTommorrowHighTemperature] = useState(-100);
const [tommorrowLowTemperature, setTommorrowLowTemperature] = useState(100);
const [tommorrowWeatherSymbol, setTommorrowWeatherSymbol] = useState('');
const [todayWeatherLevel, setTodayWeatherLevel] = useState('');
const [userGender, setUserGender] = useState('');
const [cityAdd, setCityAdd] = useState('');
const [guAdd, setGuAdd] = useState('');
const [dongAdd, setDongAdd] = useState('');
const [Time, setTime] = useState("00:00:00");
let todayWeatherLevel = 0;
let userGender;
const currentTime = () => {
const date = new Date();
const hours = String(date.getHours()).padStart(2, "0");
......@@ -60,7 +63,22 @@ function WeatherPage(props) {
for (let i = 0; i<24; i++) {
if (i === 13) {
setTodayWeatherLevel(result[i].weather);
if (result[i].weather === 0) {
todayWeatherLevel = 0;
}
else if (result[i].weather === 1) {
todayWeatherLevel = 1;
}
else if (result[i].weather === 2) {
todayWeatherLevel = 2;
}
else if (result[i].weather === 3) {
todayWeatherLevel = 3;
}
else if (result[i].weather === 4) {
todayWeatherLevel = 4;
}
}
// 세부 시간 정보
if (i > Number(currentHour)) {
......@@ -103,6 +121,7 @@ function WeatherPage(props) {
highTemperature = result[i].temperature;
}
}
setTodayHighTemperature(highTemperature);
setTodayLowTemperature(lowTemperature);
})
......@@ -111,7 +130,6 @@ function WeatherPage(props) {
// 내일의 날씨
useEffect(() => {
tommorrowWeatherResult.then((result) => {
console.log(result);
let highTemperature = -100;
let lowTemperature = 100;
......@@ -136,9 +154,19 @@ function WeatherPage(props) {
})
}, [tommorrowWeatherResult])
// 유저 성별 정보
useEffect(() => {
user.then((result) => {
setUserGender(result.logData.gender);
console.log(result);
if (result.logData.gender === '0') {
userGender = 0;
}
else {
userGender = 1;
}
});
}, [user])
......@@ -157,28 +185,22 @@ function WeatherPage(props) {
const onSubmitHandler = useCallback((event) => {
event.preventDefault(); //체크박스 미리 클릭 방지
let todayWeather = '';
let isRain = 0;
let tempData = [];
if (todayWeatherSymbol === '🌧️') {
isRain = 1;
}
tempData.push(isRain);
console.log(todayWeatherLevel);
console.log(userGender);
console.log(isRain);
const sendData = {
gender : 0,
weather : "1",
gender : userGender,
weather : todayWeatherLevel,
rain : isRain
}
console.log(sendData);
dispatch(recommend(sendData))
navigate('/recommand')
dispatch(recommend(sendData));
navigate('/recommand');
}, [todayWeatherResult, user]);
......