채지성

commuPage

......@@ -198,3 +198,15 @@ npm start
> }
>```
>> 제2기숙사 학식 메뉴 일주일치 가져오기
-------------
### /api/todayMenu
#### GET호출
> response
> ```
> [
> "도시락: 돈까스마요덮밥,매운콩나물국,카레크로켓,마카로니샐러드,볶음김치"
> "운영없음"
> ]
>```
>> 제2기숙사 학식 오늘의 메뉴 가져오기
......
.commuPage{
height: 90%;
width: 80%;
display:grid;
grid-template-rows: 85% 15%;
margin: 1%;
background-color: #FDF5E6;
}
.commuPage > :nth-child(1){
overflow-y: scroll;
overflow-x: hidden;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
height:100%;
}
.commuPage > :nth-child(1)::-webkit-scrollbar {
display: none; /* Chrome, Safari, Opera*/
}
.commuPage > :nth-child(2){
display:flex;
justify-content: end;
align-items: flex-end;
}
.commuPage > :nth-child(2) > button {
width: 15%;
margin:3% 4%;
margin-left: 0%;
}
.outer {
font-size: 10px;
height: 30%;
max-height: 30px;
width: 98%;
background-color: #FDF5F3;
border:0px solid black;
border-bottom: 1px solid black;
padding-left:10%;
display:grid;
grid-template-columns: 15% 20% 40%;
grid-template-rows: 100%;
align-items: center;
padding-top: 1%;
margin: 0.5%
}
.inner{
border: 0px solid black;
background-color: #FDF5F3;
height:100%;
max-height: 18px;
display: block;
text-align: left;
padding:0%;
margin:0%;
overflow: hidden;
}
\ No newline at end of file
import './App.css';
import axios from "axios";
import { useEffect, useState } from 'react';
import './CommuPage.css'
function InnerContent(props) {
return (
<div className='outer'>
<div className='inner'>{props.title}</div>
<div className='inner'></div>
<div className='inner'>{props.content}</div>
</div>
);
}
function CommuPage() {
const [list, setList] = useState([]);
const moveToYesterDay = () => {window.location.href = '/mealtalk/yesterday';}
const moveToWriting = () => {window.location.href = '/writing';}
const todayInnerContent = async () => { // 게시글 목록 가져오기
const arr = (await axios.get('/api/getList')).data;
var idArray = [];
for(var id of arr) idArray.push(id);
axios.post('/api/get',{idArray:idArray}).then((res)=>{
const reverseArr = res.data.reverse();
setList(reverseArr);
console.log(reverseArr);
})
};
useEffect(() => {
todayInnerContent();
}, []);
return (
<div className='commuPage'>
<div>
{list.map((item, index) => {
return (
<InnerContent key={index} title={item.title} content={item.content} />
)
})}
</div>
<div>
<button onClick={moveToWriting}> 작성</button>
<button onClick={moveToYesterDay}>어제 보기</button>
</div>
</div>
);
}
//첫번째: 오늘 메뉴/ 두번째: 오늘 메뉴에 대한 이야기/ 세번째: 어제 메뉴에 대한 이야기
export default CommuPage;
\ No newline at end of file
import './App.css';
import axios from "axios";
import { useEffect, useState } from 'react';
import './CommuPage.css'
function InnerContent(props) {
return (
<div className='outer'>
<div className='inner'>{props.title}</div>
<div className='inner'></div>
<div className='inner'>{props.content}</div>
</div>
);
}
function CommuPageYes() {
const [list2, setList2] = useState([]);
const moveToToday = () => {window.location.href = '/mealtalk';}
const moveToWriting = () => {window.location.href = '/writing';}
const yesterInnerContent = async () =>{
let today = new Date();
let year = today.getFullYear(); // 년도
let month = today.getMonth() + 1; // 월
let date = today.getDate() -1; // 날짜
let todayDate = year+'-0'+month+'-0'+date; // date에 넣을 문자열
const arr = (await axios.get(`/api/getList/:${todayDate}`)).data;
var idArray = [];
for(var id of arr) idArray.push(id);
axios.post('/api/get',{idArray:idArray}).then((res)=>{
const reverseArr = res.data.reverse();
setList2(reverseArr);
console.log(reverseArr);
})
};
useEffect(() => {
yesterInnerContent();
}, []);
return (
<div className='commuPage'>
<div>
{list2.map((item, index) => {
return (
<InnerContent key={index} title={item.title} content={item.content} />
)
})}
</div>
<div>
<button onClick={moveToWriting}> 작성</button>
<button onClick={moveToToday}>오늘 보기</button>
</div>
</div>
);
}
//첫번째: 오늘 메뉴/ 두번째: 오늘 메뉴에 대한 이야기/ 세번째: 어제 메뉴에 대한 이야기
export default CommuPageYes;
\ No newline at end of file
......@@ -11,7 +11,7 @@
}
.mainpage :nth-child(1):not(.mainpage :nth-child(1) :nth-child(1)){
.mainpage :nth-child(1):not(.mainpage :nth-child(1) *, .mainpage :nth-child(2) > * ){
display:grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 8% 12% 79%;
......@@ -78,4 +78,36 @@
display:flex;
flex-direction: column;
background-color: #FDF5E6;
padding:0px;
margin: 0px;
}
.mainpage .mainpageUnder :nth-child(2) > div {
font-size: 10px;
height: 30%;
max-height: 30px;
width: 98%;
background-color: #FDF5F3;
border:0px solid black;
border-bottom: 1px solid black;
padding-left:10%;
display:grid;
grid-template-columns: 15% 20% 40%;
grid-template-rows: 100%;
align-items: center;
padding-top: 1%;
margin: 0.5%
}
.mainpage .mainpageUnder :nth-child(2) > div >div{
border: 0px solid black;
background-color: #FDF5F3;
height:100%;
max-height: 18px;
display: block;
text-align: left;
padding:0%;
margin:0%;
overflow: hidden;
}
\ No newline at end of file
......
import './App.css';
import axios from "axios";
import { useEffect, useState } from 'react';
import './mainpage.css'
import './MainPage.css'
function InnerContent(props) {
return (
<div>
<div style={{ fontSize: '15px', height: '10px', width: '100%', backgroundColor: '#FDF5E6' }}>{props.title} {props.content}</div>
<div className='outer'>
<div className='inner'>{props.title}</div>
<div className='inner'></div>
<div className='inner'>{props.content}</div>
</div>
);
}
function MainPage() {
const [list, setList] = useState([{ title: '하이', content: '바보' }, { title: '하이2', content: '바보2' }, { title: '하이3', content: '바보3' }]);
const [list, setList] = useState([]);
let currentYear = new Date().getFullYear();
let currentMonth = new Date().getMonth() + 1;
let currentDate = new Date().getDate();
......@@ -28,6 +30,11 @@ function MainPage() {
arr_.forEach((elem) => {
let span_ = document.createElement('div');
span_.innerHTML = elem;
span_.style.borderWidth = '0px';
span_.style.textAlign = 'center';
span_.style.gridTemplateColumns = '100%';
span_.style.backgroundColor = '#FDF5E6';
span_.style.padding = '0%';
dom_.appendChild(span_);
});
......@@ -66,8 +73,9 @@ function MainPage() {
var idArray = [];
for(var id of arr) idArray.push(id);
axios.post('/api/get',{idArray:idArray}).then((res)=>{
setList(res.data);
console.log(res.data);
const reverseArr = res.data.reverse().slice(0,8);
setList(reverseArr);
console.log(reverseArr);
})
}
......
......@@ -7,9 +7,10 @@ import 'bootstrap/dist/css/bootstrap.min.css';
//컴포넌트
import TopBanner from './Component/TopBanner'; // 상단 메뉴
import SideChat from './Component/SideChat'; // 측면 대기시간 채팅
import MainPage from './Component/mainpage'; // 초기화면
import MainPage from './Component/MainPage'; // 초기화면
import MenuPage from './Component/MenuPage'; // 학식 메뉴 화면
import CommuPage from './Component/CommuPage'; // 학식 커뮤 화면(오늘)
import CommuPageYes from './Component/CommuPageYes'; // 학식 커뮤 화면(어제)
import Writing from './Component/Writing'; // 글 작성 화면
import {
......@@ -29,7 +30,8 @@ root.render(
<Routes>
<Route path="/" element={<MainPage />} />
<Route path="/menu" element={<MenuPage />} />
<Route path="/mealtalk" element={<MainPage />} />
<Route path="/mealtalk" element={<CommuPage />} />
<Route path="/mealtalk/yesterday" element={<CommuPageYes />} />
<Route path="/writing" element={<Writing />} />
</Routes>
</Router>
......
This diff is collapsed. Click to expand it.