[e6c2521] | 1 | import React from "react";
|
---|
| 2 | import { useState } from "react";
|
---|
| 3 | import { Col, Container, Row, Image, Modal, Button } from "react-bootstrap";
|
---|
| 4 | import Form from "react-bootstrap/Form";
|
---|
| 5 | import useCreate from "../Hooks/useCreate";
|
---|
| 6 | import Table from "./Table";
|
---|
| 7 | import tab from "../Tab/Tab";
|
---|
| 8 | const TableRow = (props) => {
|
---|
| 9 | const {createEntity} = useCreate()
|
---|
| 10 | const [getData, setData] = useState(0);
|
---|
| 11 | const [show, setShow] = useState(false);
|
---|
| 12 |
|
---|
| 13 | const handleClose = () => setShow(false);
|
---|
| 14 | const handleShow = () => setShow(true);
|
---|
| 15 | const table = props.table
|
---|
| 16 | console.log(props)
|
---|
| 17 | console.log(table)
|
---|
| 18 | return (
|
---|
| 19 | <>
|
---|
| 20 | <tr>
|
---|
| 21 | <td>
|
---|
| 22 | <Table data={table}></Table>
|
---|
| 23 | </td>
|
---|
| 24 | <td>
|
---|
| 25 | <Form.Select aria-label="Default select example" name={'numberOfBeds'}
|
---|
| 26 | onChange={(e) => {
|
---|
| 27 | setData(e.target.value);
|
---|
| 28 | }}>
|
---|
| 29 | <option></option>
|
---|
| 30 | {[...Array(props.data.find(x => x.restaurantTable.tableId === table.tableId).numTables).keys()].map(x => {
|
---|
| 31 | return (
|
---|
| 32 | <option value={x+1} >{x + 1}</option>
|
---|
| 33 | )
|
---|
| 34 | })}
|
---|
| 35 | </Form.Select>
|
---|
| 36 | </td>
|
---|
| 37 | <td>
|
---|
| 38 | <Button
|
---|
| 39 | onClick={handleShow}
|
---|
| 40 | className="m-2"
|
---|
| 41 | size="md"
|
---|
| 42 | style={{backgroundColor: "#159895"}}
|
---|
| 43 | >
|
---|
| 44 | Резервирај
|
---|
| 45 | </Button>
|
---|
| 46 | </td>
|
---|
| 47 | </tr>
|
---|
| 48 |
|
---|
| 49 | <Modal show={show} onHide={handleClose}>
|
---|
| 50 | <Modal.Header closeButton>
|
---|
| 51 | <Modal.Title>Потврда на резервација</Modal.Title>
|
---|
| 52 | </Modal.Header>
|
---|
| 53 | <Modal.Body>
|
---|
| 54 | <h3>Резервација на маса во ресторан</h3>
|
---|
| 55 | <h3>На ден:<b>{' ' + props.params.date}</b></h3>
|
---|
| 56 | <h3>Време од:<b>{' ' + props.params.hourFrom}</b></h3>
|
---|
| 57 | <h3>Време до:<b>{' ' + props.params.hourTo}</b></h3>
|
---|
| 58 | <h3>Маса за {table.noSeats} луѓе</h3>
|
---|
| 59 | </Modal.Body>
|
---|
| 60 | <Modal.Footer>
|
---|
| 61 | <Button variant="secondary" onClick={handleClose}>
|
---|
| 62 | Close
|
---|
| 63 | </Button>
|
---|
| 64 | <Button variant="primary" onClick={() => {
|
---|
| 65 | createEntity('restaurant/reserve', {
|
---|
| 66 | restaurantTableId: table.tableId,
|
---|
| 67 | userId: 1,
|
---|
| 68 | restaurantAvailibleId: props.availableId,
|
---|
| 69 | hourFrom: props.params.hourFrom,
|
---|
| 70 | hourTo: props.params.hourTo,
|
---|
| 71 | date: props.params.date
|
---|
| 72 | })
|
---|
| 73 | handleClose();
|
---|
| 74 | }}>
|
---|
| 75 | Резервирај
|
---|
| 76 | </Button>
|
---|
| 77 | </Modal.Footer>
|
---|
| 78 | </Modal>
|
---|
| 79 | </>
|
---|
| 80 | )
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | export default TableRow |
---|