Last change
on this file since 0f5aa27 was 07f4e8b, checked in by darsov2 <62809499+darsov2@…>, 8 months ago |
prefinal fixes
|
-
Property mode
set to
100644
|
File size:
1.8 KB
|
Rev | Line | |
---|
[e6c2521] | 1 | import React, {useState} from "react";
|
---|
| 2 | import {Col, Container, Row, Carousel} from "react-bootstrap";
|
---|
| 3 | import MenuItem from "./MenuItem";
|
---|
| 4 |
|
---|
| 5 | const 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 |
|
---|
[07f4e8b] | 25 |
|
---|
| 26 |
|
---|
[e6c2521] | 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>
|
---|
[07f4e8b] | 38 | <MenuItem images={ props.images.filter(x => {
|
---|
| 39 | console.log(x)
|
---|
| 40 | return x.menu.menuId === menuItem.menuId
|
---|
| 41 | })} data={menuItem}/>
|
---|
[e6c2521] | 42 | </Col>
|
---|
| 43 | )
|
---|
| 44 | })}
|
---|
| 45 | </Row>
|
---|
| 46 | )
|
---|
| 47 | })}
|
---|
| 48 | </Carousel.Item>)
|
---|
| 49 | })}
|
---|
| 50 | </Carousel>
|
---|
| 51 | </>)
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | export default Menu; |
---|
Note:
See
TracBrowser
for help on using the repository browser.