source: frontend/src/Components/RestaurantDetails/Menu.js

Last change on this file was 07f4e8b, checked in by darsov2 <62809499+darsov2@…>, 5 months ago

prefinal fixes

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import React, {useState} from "react";
2import {Col, Container, Row, Carousel} from "react-bootstrap";
3import MenuItem from "./MenuItem";
4
5const Menu = (props) => {
6 const menu = props.menu
7
8 console.log(menu)
9 const partitionBy3 = (arr) => {
10 const rowPartitions = Array.from({length: Math.ceil(arr.length / 5)}, (v, i) =>
11 arr.slice(i * 5, i * 5 + 5)
12 );
13 return Array.from({length: Math.ceil(rowPartitions.length / 2)}, (v, i) =>
14 rowPartitions.slice(i * 2, i * 2 + 2)
15 );
16 }
17
18 const [ind, setIndex] = useState(0);
19
20 const handleSelect = (selectedIndex) => {
21 setIndex(selectedIndex);
22 };
23
24
25
26
27 return (<>
28 <Carousel activeIndex={ind} onSelect={handleSelect} indicators={false}>
29 {partitionBy3(menu).map((slides, index) => {
30 return (
31 <Carousel.Item key={index}>
32 {slides.map((row) => {
33 return (
34 <Row>
35 {row.map((menuItem) => {
36 return (
37 <Col>
38 <MenuItem images={ props.images.filter(x => {
39 console.log(x)
40 return x.menu.menuId === menuItem.menuId
41 })} data={menuItem}/>
42 </Col>
43 )
44 })}
45 </Row>
46 )
47 })}
48 </Carousel.Item>)
49 })}
50 </Carousel>
51 </>)
52}
53
54export default Menu;
Note: See TracBrowser for help on using the repository browser.