Showing
26 changed files
with
10 additions
and
49 deletions
... | @@ -7,7 +7,6 @@ import axios from 'axios'; | ... | @@ -7,7 +7,6 @@ import axios from 'axios'; |
7 | 7 | ||
8 | function RecommandPage(props) { | 8 | function RecommandPage(props) { |
9 | 9 | ||
10 | - const dispatch = useDispatch(); | ||
11 | const navigate = useNavigate(); | 10 | const navigate = useNavigate(); |
12 | 11 | ||
13 | const [Time, setTime] = useState("00:00:00"); | 12 | const [Time, setTime] = useState("00:00:00"); |
... | @@ -32,23 +31,13 @@ function RecommandPage(props) { | ... | @@ -32,23 +31,13 @@ function RecommandPage(props) { |
32 | 31 | ||
33 | const navigate_register = useCallback((event) => { | 32 | const navigate_register = useCallback((event) => { |
34 | navigate('../register'); | 33 | navigate('../register'); |
35 | - }) | 34 | + }) |
35 | + | ||
36 | + console.log(initData); | ||
36 | 37 | ||
37 | - const [initData, setInitData] = useState([{ | ||
38 | - inputData: { | ||
39 | - today: '', | ||
40 | - time: '', | ||
41 | - temperature: '', | ||
42 | - rainper: '', | ||
43 | - weather: '' | ||
44 | - }, | ||
45 | - }]) | ||
46 | - | ||
47 | - // 원활한 데이터 관리를 위해 글 갯수를 파악한다. | ||
48 | - | ||
49 | useEffect(async() => { | 38 | useEffect(async() => { |
50 | try{ | 39 | try{ |
51 | - const res = await axios.get('/api/weatherData') | 40 | + const res = await axios.post('localhost:4000/api/weather') |
52 | const _inputData = await res.data.map((weatherData) => ( | 41 | const _inputData = await res.data.map((weatherData) => ( |
53 | { | 42 | { |
54 | today: weatherData.today, | 43 | today: weatherData.today, |
... | @@ -67,46 +56,18 @@ function RecommandPage(props) { | ... | @@ -67,46 +56,18 @@ function RecommandPage(props) { |
67 | 56 | ||
68 | const [Rainstring, setRainstring] = useState(""); | 57 | const [Rainstring, setRainstring] = useState(""); |
69 | const rain = () => { | 58 | const rain = () => { |
70 | - if(initData.inputData.rainper > 0) { | 59 | + if(initData.inputData.umbrella == 1) { |
71 | setRainstring("비 예보가 있습니다. 우산을 꼭 챙겨주세요!"); | 60 | setRainstring("비 예보가 있습니다. 우산을 꼭 챙겨주세요!"); |
72 | } | 61 | } |
73 | - else { | 62 | + else if(initData.inputData.umbrella == 0) { |
74 | setRainstring("비 예보가 없습니다!"); | 63 | setRainstring("비 예보가 없습니다!"); |
75 | } | 64 | } |
76 | - } | 65 | + } //weather.js |
77 | 66 | ||
78 | - const [topPath, settopPath] = useState([""]); | 67 | + rain(); |
79 | - const [bottomPath, setbottomPath] = useState([""]); | ||
80 | - | ||
81 | - const clothesImage = () => { | ||
82 | - if(initData.inputData.weather == 0) { | ||
83 | - settopPath(['../../../../src/img/weather0/기모옷.jpg', '../../../../src/img/weather0/패딩.jpg']); | ||
84 | - setbottomPath(['../../../../src/img/weather0/조거팬츠.jpg']); | ||
85 | - } | ||
86 | - else if(initData.inputData.weather == 1) { | ||
87 | - settopPath(['../../../../src/img/weather1/가죽자켓.jpg', '../../../../src/img/weather1/청자켓.jpg', | ||
88 | - '../../../../src/img/weather1/울코트.jpg', '../../../../src/img/weather1/트렌치코트.jpg', '../../../../src/img/weather1/후드티.jpg']); | ||
89 | - setbottomPath(['../../../../src/img/weather1/청바지.jpg']); | ||
90 | - } | ||
91 | - else if(initData.inputData.weather == 2) { | ||
92 | - settopPath(['../../../../src/img/weather2/가디건.jpg', '../../../../src/img/weather2/니트.jpg', | ||
93 | - '../../../../src/img/weather2/맨투맨.jpg', '../../../../src/img/weather2/자켓.jpg']); | ||
94 | - setbottomPath(['../../../../src/img/weather2/슬랙스.jpg', '../../../../src/img/weather2/롱스커트.jpg']); | ||
95 | - } | ||
96 | - else if(initData.inputData.weather == 3) { | ||
97 | - settopPath(['../../../../src/img/weather3/린넨셔츠.jpg', '../../../../src/img/weather3/블라우스.jpg']); | ||
98 | - setbottomPath(['../../../../src/img/weather3/스타킹.jpg', '../../../../src/img/weather2/면바지.jpg']); | ||
99 | - } | ||
100 | - else { | ||
101 | - settopPath(['../../../../src/img/weather4/민소매(남).jpg', '../../../../src/img/weather4/민소매(여).jpg', | ||
102 | - '../../../../src/img/weather4/반팔.jpg']); | ||
103 | - setbottomPath(['../../../../src/img/weather4/치마(여).jpg', '../../../../src/img/weather4/반바지.jpg', | ||
104 | - '../../../../src/img/weather4/핫팬츠.jpg']); | ||
105 | - } | ||
106 | - } | ||
107 | 68 | ||
108 | - const topClothes = topPath[Math.floor(Math.random() * topPath.length)]; | 69 | + const [topPath, settopPath] = useState([""]); |
109 | - const bottomClothes = bottomPath[Math.floor(Math.random() * bottomPath.length)]; | 70 | + const [bottomPath, setbottomPath] = useState([""]); //clothes.js |
110 | 71 | ||
111 | return ( | 72 | return ( |
112 | <> | 73 | <> | ... | ... |
.jpg)
27.6 KB
-
Please register or login to post a comment