-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuOrderPage.jsx
94 lines (85 loc) · 2.55 KB
/
MenuOrderPage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React, { useEffect, useState } from 'react';
import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
function MenuItemList(props){
const {title,dataList,onMenuClick} = props
return <>
<h2>{title}</h2>
<ul style={{listStyle:"none"}}>
{dataList.map((dt,index)=>{
return <li key={index}><a href="#" onClick={(e)=>{
e.preventDefault();
onMenuClick(dt.no);
}}>{dt.name}</a> / {dt.price} </li>
})}
</ul>
</>
}
//주문현황
function OrderStatusPage(props){
const {jumunList} = props
const [tableNo, setTableNo] = useState(1)
return <>
<h1>주문현황 : 테이블번호 : {tableNo}</h1>
</>
}
function MenuOrderPage(props) {
const [siksaList, setSiksaList] = useState([])//식사류
const [gansikList, setGansikList] = useState([])//간식류
const [jumunList, setJumunList] = useState([])//주문현황목록
//초기화코드
useEffect(()=>{
setSiksaList([
{name:"비빔밥", price:7000},
{name:"김치복음밥", price:7000},
])
setGansikList([
{name:"라면", price:5000},
{name:"라볶이", price:6000},
])
},[])
//식사류,간식류 선택시 주문현황으로 데이터 전달
function siksaJumun(menuno){
for(let ss of siksaList){
if(ss.no == menuno){
setJumunList( [...jumunList, ss] )
break;
}
}
}
function gansikJumun(menuno){
for(let ss of gansikList){
if(ss.no == menuno){
setJumunList( [...jumunList, ss] )
break;
}
}
}
return (
<>
<Container>
<h1>주문화면</h1>
<Row>
<Col xs={3}>
<h2>식사류</h2>
<ul style={{listStyle:"none"}}>
{siksaList.map((dt,index)=>{
return <li key={index}><a href="#" onClick={(e)=>{
e.preventDefault();
siksaJumun(dt.no) //식사주문
}}>{dt.name}</a> / {dt.price}</li>
})}
</ul>
</Col>
<Col xs={3}>간식류<MenuItemList
title="간식류"
dataList={gansikList}
onMenuClick={gansikJumun}/></Col>
<Col xs={6}>주문현황:{jumunList.length}</Col>
</Row>
</Container>
</>
);
}
export default MenuOrderPage;