-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages_menu_Menu.js.html
498 lines (454 loc) · 24.5 KB
/
pages_menu_Menu.js.html
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: pages/menu/Menu.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: pages/menu/Menu.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import React, { useEffect, useState, useRef } from "react";
import "../../css/menu.css";
import { HOST } from "../../host";
/**
React component that displays a menu and handles fetching of menu data from the server.
@returns {JSX.Element} The Menu component.
*/
export default function Menu() {
const [menu, setMenu] = useState("");
const [menu1, setMenu1] = useState("");
const [items, newItems] = useState([]);
/**
A side effect hook that fetches new menu items from a server and updates the state of newItems with the received data.
@param {Array} newItems - The state array of menu items to be updated with the fetched data.
@param {String} HOST - The server address to fetch the data from.
@returns {void}
*/
useEffect(() => {
const handleNewItems = async () => {
const res = await fetch(`${HOST}/newMenuItems`);
const getdata = await res.json();
newItems(getdata);
console.log(getdata);
};
handleNewItems();
}, []);
/**
This effect retrieves the menu from the server and sets the state of the menu and menu1.
@function
@name getMenuEffect
@param {Array} dependencies - an empty array indicating that the effect should only run once on mount.
@returns {void}
*/
useEffect(() => {
const getMenu = async () => {
const res = await fetch(`${HOST}/menu`);
const data = await res.json();
const newObj = {};
const newObj2 = {};
for (const key in data) {
const { menu_item_id, menu_item_price, menu_item_name } =
data[key];
newObj[menu_item_id] = menu_item_price;
newObj2[menu_item_id] = menu_item_name;
}
setMenu(newObj);
setMenu1(newObj2);
};
getMenu();
}, []);
/**
Gets the price of a menu item given its ID.
@param {number} menuItemId - The ID of the menu item to get the price for.
@param {Object} menu - The menu object containing the menu item data.
@returns {number} The price of the menu item.
*/
const getMenuPrice = (menuItemId, menu) => {
return menu[menuItemId];
};
/**
Gets the name of a menu item given its ID.
@param {number} menuItemId - The ID of the menu item to get the name for.
@param {Object} menu1 - The menu object containing the menu item data.
@returns {string} The name of the menu item.
*/
const getMenuName = (menuItemId, menu1) => {
return menu1[menuItemId];
};
const bdy = useRef(null);
/**
A function to request the fullscreen mode for the body element of the document.
@returns {void}
*/
const handleFullscreen = () => {
if (bdy.current) {
if (bdy.current.requestFullscreen) {
bdy.current.requestFullscreen();
} else if (bdy.current.webkitRequestFullscreen) {
bdy.current.webkitRequestFullscreen();
} else if (bdy.current.msRequestFullscreen) {
bdy.current.msRequestFullscreen();
}
}
};
/**
A hook that listens for the "Enter" keydown event and triggers the handleFullscreen function.
@returns {void}
*/
useEffect(() => {
/**
A function to handle the "Enter" keydown event and trigger the handleFullscreen function.
@param {KeyboardEvent} event - The event object representing the keydown event.
@returns {void}
*/
const handleKeyDown = (event) => {
if (event.key === "Enter") {
handleFullscreen();
}
};
document.addEventListener("keydown", handleKeyDown);
return () => {
document.removeEventListener("keydown", handleKeyDown);
};
}, []);
console.log(items);
return (
<>
{/* <header><h1>Menu</h1></header> */}
<style>
@import
url('https://fonts.googleapis.com/css2?family=Lato:wght@300&family=Montserrat:wght@300&display=swap');
</style>
{/* <button onclick={toggleFullScreen}>Open Fullscreen</button> */}
<div className="bdy" ref={bdy} allow="fullscreen">
<div className="b1">
<br></br>
<h2>Entrees & Meals</h2>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
<div className="s1">
<div className="sandwich1">
<div className="containerR">
<img
className="menuImg"
src="/resource/sand.png"
alt="Chick-fil-A Chicken Sandwich"
></img>
<div className="rhs">
<h3>{getMenuName(1, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(25, menu)} Meal | $
{getMenuPrice(1, menu)} Entree
</h4>
<br></br>
<h3>{getMenuName(2, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(26, menu)} Meal | $
{getMenuPrice(2, menu)} Entree
</h4>
</div>
</div>
<br></br>
<div className="containerL">
<img
className="menuImg"
src="/resource/spicysSand.jpg"
></img>
<div className="lhs">
<h3>{getMenuName(3, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(27, menu)} Meal | $
{getMenuPrice(3, menu)} Entree
</h4>
<br></br>
<h3>{getMenuName(4, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(28, menu)} Meal | $
{getMenuPrice(4, menu)} Entree
</h4>
</div>
</div>
<br></br>
<div className="containerR">
<img
className="menuImg"
src="/resource/gsand.png"
></img>
<div className="rhs">
<h3>{getMenuName(18, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(29, menu)} Meal | $
{getMenuPrice(18, menu)} Entree
</h4>
<br></br>
<h3>{getMenuName(34, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(35, menu)} Meal | $
{getMenuPrice(34, menu)} Entree
</h4>
</div>
</div>
<br></br>
<div className="containerL">
<img
className="menuImg"
src="/resource/nuggs.jpg"
></img>
<div className="lhs">
<h3>{getMenuName(6, menu1)}</h3>
<h4>
{" "}
8ct: ${getMenuPrice(30, menu)} Meal | $
{getMenuPrice(6, menu)} Entree
</h4>
<h4>
{" "}
12ct: ${getMenuPrice(31, menu)} Meal | $
{getMenuPrice(7, menu)} Entree
</h4>
<br></br>
<h3>{getMenuName(16, menu1)}</h3>
<h4>
{" "}
8ct: ${getMenuPrice(32, menu)} Meal | $
{getMenuPrice(16, menu)} Entree
</h4>
<h4>
{" "}
12ct: ${getMenuPrice(33, menu)} Meal | $
{getMenuPrice(17, menu)} Entree
</h4>
<br></br><br></br><br></br>
</div>
</div>
</div>
</div>
</div>
<div className="rhs-menu">
<div className="uppermenu">
<div className="b">
<br></br>
<h2>Salads</h2>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
<div className="s">
<div className="salads">
<div className="containerR">
<img
className="menuImg"
src="/resource/wrap1.png"
></img>
<div className="rhs1">
<h3>{getMenuName(36, menu1)}</h3>
<h4>
{" "}
${getMenuPrice(36, menu)} Meal |
${getMenuPrice(37, menu)} Entree
</h4>
</div>
</div>
<br></br>
<div className="containerL">
<img
className="menuImg"
src="/resource/marketSalad2.png"
></img>
<div className="rhs">
<br></br>
<h3>{getMenuName(38, menu1)}</h3>
<h4>${getMenuPrice(38, menu)}</h4>
<br></br>
<h3>{getMenuName(19, menu1)}</h3>
<h4>${getMenuPrice(19, menu)}</h4>
<br></br>
<h3>{getMenuName(39, menu1)}</h3>
<h4>${getMenuPrice(39, menu)}</h4>
</div>
</div>
</div>
</div>
</div>
<div className="b">
<br></br>
<h2>Drinks</h2>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
<div className="s">
<div className="drinks">
<div className="containerR1">
<img
className="menuImg"
src="/resource/Screenshot 2023-04-12 095510.jpg"
></img>
<div className="rhs">
<h3>Freshly-Brewed Iced Tea</h3>
<h4>
M: ${getMenuPrice(40, menu)} |
L: ${getMenuPrice(41, menu)}
</h4>
<br></br>
<h3>Chick-Fil-A Lemondade</h3>
<h4>
M: ${getMenuPrice(15, menu)} |
L: ${getMenuPrice(12, menu)}
</h4>
<br></br>
<h3>Chick-Fil-A Sunjoy</h3>
<h4>
M: ${getMenuPrice(44, menu)} |
L: ${getMenuPrice(45, menu)}
</h4>
</div>
</div>
<br></br>
<div className="lhs1">
<h3>Cold Brew Iced Coffee</h3>
<h4>${getMenuPrice(46, menu)}</h4>
<br></br>
<h3>Soft Drink</h3>
<h4>
M: ${getMenuPrice(9, menu)} | L: $
{getMenuPrice(43, menu)}
</h4>
<br></br>
<h3>Bottled Water</h3>
<h4>$1.95</h4>
<br></br>
</div>
</div>
</div>
</div>
<div className="b">
<br></br>
<h2>Treats</h2>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
<div className="s">
<div className="Treats">
<div className="containerL1">
<img
className="menuImg1"
src="/resource/desserts-removebg.png"
></img>
<div classname="lhs">
<h3>Hand-Spun Milkshakes</h3>
<h4>${getMenuPrice(22, menu)}</h4>
<br></br>
<h3>{getMenuName(47, menu1)}</h3>
<h4>${getMenuPrice(47, menu)}</h4>
<br></br>
<h3>{getMenuName(48, menu1)}</h3>
<h4>${getMenuPrice(48, menu)}</h4>
<br></br>
</div>
</div>
<div className="lhs">
<h3>{getMenuName(49, menu1)}</h3>
<h4>${getMenuPrice(49, menu)}</h4>
<br></br>
<h3>{getMenuName(50, menu1)}</h3>
<h4>1ct: ${getMenuPrice(50, menu)}</h4>
<br></br>
<h3>{getMenuName(24, menu1)}</h3>
<h4>1ct: ${getMenuPrice(24, menu)}</h4>
<br></br>
</div>
</div>
</div>
</div>
</div>
{/* <div className='bdy2'> */}
<div className="lowermenu">
<div className="sidewrapper">
<div className="sidesTitle">
<h1>Sides</h1>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
</div>
<div className="containerR1">
<img
className="menuImg"
src="/resource/sides.png"
></img>
<div className="lhs-side">
<h3>{getMenuName(12, menu1)}</h3>
<h4>
M: ${getMenuPrice(12, menu)}| L: $
{getMenuPrice(52, menu)}
</h4>
<br></br>
<h3>{getMenuName(53, menu1)}</h3>
<h4>${getMenuPrice(53, menu)}</h4>
</div>
<div className="lhs-side">
<h3>{getMenuName(55, menu1)}</h3>
<h4>${getMenuPrice(55, menu)}</h4>
<br></br>
<h3>{getMenuName(54, menu1)}</h3>
<h4>${getMenuPrice(54, menu)}</h4>
</div>
</div>
</div>
<div className="sidewrapper">
<div className="seasonal-items">
<h1>Seasonal Items</h1>
<svg width="400" height="110">
<rect width="50%" height="15%" />
</svg>
<div className="item-list">
{/* get items that were added */}
{items.map(function (i, idx) {
return (
<h3>
<li key={idx}>
{i.menu_item_name} .... $
{i.menu_item_price}
</li>
</h3>
);
})}
</div>
</div>
</div>
</div>
</div>
</div>
<br></br>
</>
);
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#App">App</a></li><li><a href="global.html#Cashier">Cashier</a></li><li><a href="global.html#CashierDrink">CashierDrink</a></li><li><a href="global.html#CashierHeader">CashierHeader</a></li><li><a href="global.html#CashierMeal">CashierMeal</a></li><li><a href="global.html#CashierSauce">CashierSauce</a></li><li><a href="global.html#CashierSeasonal">CashierSeasonal</a></li><li><a href="global.html#Customer">Customer</a></li><li><a href="global.html#CustomerDrink">CustomerDrink</a></li><li><a href="global.html#ExcessReport">ExcessReport</a></li><li><a href="global.html#HOST">HOST</a></li><li><a href="global.html#Home">Home</a></li><li><a href="global.html#Inventory">Inventory</a></li><li><a href="global.html#Login">Login</a></li><li><a href="global.html#Logout">Logout</a></li><li><a href="global.html#Manager">Manager</a></li><li><a href="global.html#MenuAdder">MenuAdder</a></li><li><a href="global.html#MenuItems">MenuItems</a></li><li><a href="global.html#Orders">Orders</a></li><li><a href="global.html#PrivateRouteCashier">PrivateRouteCashier</a></li><li><a href="global.html#PrivateRouteManager">PrivateRouteManager</a></li><li><a href="global.html#UserInputLogger">UserInputLogger</a></li><li><a href="global.html#getMenuEffect">getMenuEffect</a></li><li><a href="global.html#getMenuPrice">getMenuPrice</a></li><li><a href="global.html#handleComplete">handleComplete</a></li><li><a href="global.html#handleIdChange">handleIdChange</a></li><li><a href="global.html#handleInventory">handleInventory</a></li><li><a href="global.html#handleNameChange">handleNameChange</a></li><li><a href="global.html#handleNewOrder">handleNewOrder</a></li><li><a href="global.html#handlePriceChange">handlePriceChange</a></li><li><a href="global.html#handleSubmit">handleSubmit</a></li><li><a href="global.html#local">local</a></li><li><a href="global.html#root">root</a></li><li><a href="global.html#useEffect">useEffect</a></li><li><a href="global.html#useGoogleSignIn">useGoogleSignIn</a></li><li><a href="global.html#useLocalState">useLocalState</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Tue May 02 2023 22:48:22 GMT-0500 (Central Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>