Showing
2 changed files
with
83 additions
and
40 deletions
1 | -.mainpage { | 1 | +.mainpage{ |
2 | - display:grid; | ||
3 | - grid-template-rows: 1.3fr 1fr; | ||
4 | - width: 80%; | ||
5 | height: 90%; | 2 | height: 90%; |
6 | - padding:5%; | 3 | + width: 80%; |
4 | + | ||
5 | + display:grid; | ||
6 | + grid-template-rows: 1.4fr 1fr; | ||
7 | 7 | ||
8 | -} | ||
9 | 8 | ||
10 | -.mainpage :nth-child(1) { | ||
11 | - display: grid; | ||
12 | - grid-template-rows: 1fr 10fr; | ||
13 | } | 9 | } |
14 | 10 | ||
15 | -.mainpage :nth-child(2) { | 11 | +.mainpage :nth-child(1):not(.mainpage :nth-child(1) :nth-child(1)){ |
16 | display:grid; | 12 | display:grid; |
17 | grid-template-columns: 1fr 1fr; | 13 | grid-template-columns: 1fr 1fr; |
18 | -} | 14 | + grid-template-rows: 8% 16% 74%; |
19 | 15 | ||
20 | -.whatAboutMeal { | ||
21 | - display: grid; | ||
22 | - grid-template-rows: 1fr 8fr; | ||
23 | - grid-template-columns: 100%; | ||
24 | } | 16 | } |
25 | 17 | ||
18 | +.mainpage :nth-child(1) :nth-child(1){ | ||
19 | + padding-left: 10%; | ||
20 | +} | ||
21 | +.mainpage :nth-child(1) :nth-child(3), | ||
22 | +.mainpage :nth-child(1) :nth-child(4), | ||
23 | +.mainpage :nth-child(1) :nth-child(5), | ||
24 | +.mainpage :nth-child(1) :nth-child(6){ | ||
25 | + text-align: center; | ||
26 | + padding-top: 2%; | ||
27 | +} | ||
26 | 28 | ||
27 | - | ||
28 | -.mainpageInner { | ||
29 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
29 | +.lunchTable, .dinnerTable{ | ||
30 | + display:flex; | ||
31 | + flex-direction: column; | ||
32 | + | ||
33 | +} | ... | ... |
1 | import './App.css'; | 1 | import './App.css'; |
2 | import axios from "axios"; | 2 | import axios from "axios"; |
3 | -import { useEffect } from 'react'; | 3 | +import { useEffect, useState } from 'react'; |
4 | import './mainpage.css' | 4 | import './mainpage.css' |
5 | 5 | ||
6 | -let today = '~'+'월'+'*'+'일'; // 날짜 받아오기 | 6 | + |
7 | 7 | ||
8 | 8 | ||
9 | function MainPage() { | 9 | function MainPage() { |
10 | - const callApi = async()=>{ | 10 | + const [lunch, setlunch] = useState(""); |
11 | - axios.get("/api").then((res)=>{console.log(res.data.test)}); | 11 | + const [dinner, setdinner] = useState(""); |
12 | - | 12 | + let currentYear = new Date().getFullYear(); |
13 | + let currentMonth = new Date().getMonth(); | ||
14 | + let currentDate = new Date().getDate(); | ||
15 | + let today = currentYear+'/'+currentMonth+'/'+currentDate; | ||
16 | + | ||
17 | + const makeTable = (arr_, dom_) => { | ||
18 | + | ||
19 | + arr_.forEach((elem)=>{ | ||
20 | + let span_ = document.createElement('div'); | ||
21 | + span_.innerHTML = elem; | ||
22 | + dom_.appendChild(span_); | ||
23 | + console.log("하이1"); | ||
24 | + }); | ||
25 | + | ||
13 | }; | 26 | }; |
14 | 27 | ||
28 | + const todayMealTable = async()=>{ | ||
29 | + axios.get("/api/todayMenu").then( | ||
30 | + (res) => { | ||
31 | + const index1 = res.data[0].indexOf(':'); | ||
32 | + const index2 = res.data[1].indexOf(':'); | ||
33 | + let lunchArr = res.data[0].substring(index1+1); | ||
34 | + let dinnerArr = res.data[1].substring(index2+1); | ||
35 | + | ||
36 | + if(index1 !== -1){ | ||
37 | + lunchArr = lunchArr.split(','); | ||
38 | + } | ||
39 | + if(index1 !== -1){ | ||
40 | + dinnerArr = dinnerArr.split(','); | ||
41 | + } | ||
42 | + console.log(lunchArr, dinnerArr); | ||
43 | + | ||
44 | + const lunchDom = document.getElementsByClassName('lunchTable')[0]; | ||
45 | + const dinnerDom = document.getElementsByClassName('dinnerTable')[0]; | ||
46 | + | ||
47 | + makeTable(lunchArr, lunchDom); | ||
48 | + makeTable(dinnerArr, dinnerDom); | ||
49 | + setlunch(lunchArr); | ||
50 | + setdinner(dinnerArr); | ||
51 | + | ||
52 | + } | ||
53 | + ) | ||
54 | + } | ||
55 | + | ||
56 | + | ||
15 | useEffect(()=>{ | 57 | useEffect(()=>{ |
16 | - callApi(); | 58 | + todayMealTable(); |
59 | + | ||
60 | + | ||
17 | }, []); | 61 | }, []); |
18 | 62 | ||
19 | return ( | 63 | return ( |
20 | - <div className='mainpage' > | 64 | + <div className='mainpage'> |
21 | - <div className='mainpageInner' id='MealTable' > | 65 | + |
22 | - {today} 제2기숙사 학식 | 66 | + <div> |
23 | <div> | 67 | <div> |
68 | + {today} 제2기숙사 학식 | ||
69 | + </div> | ||
70 | + <div></div> | ||
71 | + <div>점심</div> | ||
72 | + <div>저녁</div> | ||
73 | + <div className='lunchTable'> | ||
24 | 74 | ||
25 | </div> | 75 | </div> |
76 | + <div className='dinnerTable'></div> | ||
26 | </div> | 77 | </div> |
27 | - <div className='mainpageInner' > | 78 | + <div> |
28 | - <div className='whatAboutMeal'> | ||
29 | - 오늘 메뉴 어때? | ||
30 | - <div> | ||
31 | 79 | ||
32 | - </div> | ||
33 | - </div> | ||
34 | - <div className='whatAboutMeal'> | ||
35 | - 어제 메뉴 어땠어? | ||
36 | - <div> | ||
37 | - | ||
38 | - </div> | ||
39 | - </div> | ||
40 | </div> | 80 | </div> |
41 | </div> | 81 | </div> |
42 | - | ||
43 | ); | 82 | ); |
44 | } | 83 | } |
45 | //첫번째: 오늘 메뉴/ 두번째: 오늘 메뉴에 대한 이야기/ 세번째: 어제 메뉴에 대한 이야기 | 84 | //첫번째: 오늘 메뉴/ 두번째: 오늘 메뉴에 대한 이야기/ 세번째: 어제 메뉴에 대한 이야기 | ... | ... |
-
Please register or login to post a comment