1 | import {Button, Form, Modal, Row} from "react-bootstrap";
|
---|
2 | import React from "react";
|
---|
3 | import useFormData from "../Hooks/useFormData";
|
---|
4 | import useCreate from "../Hooks/useCreate";
|
---|
5 |
|
---|
6 | const ReviewModal = (props) => {
|
---|
7 | const dummy = {
|
---|
8 | tite: "",
|
---|
9 | numStars: "",
|
---|
10 | description: "",
|
---|
11 | }
|
---|
12 |
|
---|
13 | const {createEntity} = useCreate();
|
---|
14 |
|
---|
15 | const {formData, setFormData, onFormChange} = useFormData(dummy)
|
---|
16 |
|
---|
17 | return (
|
---|
18 | <>
|
---|
19 | <Modal show={props.showReview} onHide={props.handleCloseReview}>
|
---|
20 | <Modal.Header closeButton>
|
---|
21 | <Modal.Title>Внесување оценка по резервација</Modal.Title>
|
---|
22 | </Modal.Header>
|
---|
23 | <Modal.Body>
|
---|
24 | <Form>
|
---|
25 | <Row>
|
---|
26 | <Form.Floating className="mb-3">
|
---|
27 | <Form.Control
|
---|
28 | size="md"
|
---|
29 | type="text"
|
---|
30 | placeholder="Каде ќе патувате?:"
|
---|
31 | id="title"
|
---|
32 | name="title"
|
---|
33 | onChange={onFormChange}
|
---|
34 | value={formData.title}
|
---|
35 | ></Form.Control>
|
---|
36 | <label style={{left: '10px'}} htmlFor="location">Наслов:</label>
|
---|
37 | </Form.Floating>
|
---|
38 | </Row>
|
---|
39 | <Row>
|
---|
40 | <Form.Floating className="mb-3">
|
---|
41 | <Form.Control
|
---|
42 | size="md"
|
---|
43 | type="number"
|
---|
44 | max={5}
|
---|
45 | min={1}
|
---|
46 | placeholder="Каде ќе патувате?:"
|
---|
47 | id="numStars"
|
---|
48 | name="numStars"
|
---|
49 | onChange={onFormChange}
|
---|
50 | value={formData.numStars}
|
---|
51 | ></Form.Control>
|
---|
52 | <label style={{left: '10px'}} htmlFor="location">Број на ѕвезди:</label>
|
---|
53 | </Form.Floating>
|
---|
54 | </Row>
|
---|
55 |
|
---|
56 | <Row>
|
---|
57 | <Form.Floating className="mb-3">
|
---|
58 | <Form.Control
|
---|
59 | size="md"
|
---|
60 | as="textarea"
|
---|
61 | placeholder="Каде ќе патувате?:"
|
---|
62 | id="description"
|
---|
63 | name="description"
|
---|
64 | onChange={onFormChange}
|
---|
65 | value={formData.description}
|
---|
66 | ></Form.Control>
|
---|
67 | <label style={{left: '10px'}} htmlFor="location">Опис:</label>
|
---|
68 | </Form.Floating>
|
---|
69 | </Row>
|
---|
70 |
|
---|
71 | </Form>
|
---|
72 | </Modal.Body>
|
---|
73 | <Modal.Footer>
|
---|
74 | <Button variant="secondary" onClick={props.handleClose}>
|
---|
75 | Затвори
|
---|
76 | </Button>
|
---|
77 | <Button variant="primary" onClick={() => {
|
---|
78 | // console.log(props.data.hotelId)
|
---|
79 | const dataToPost = props.type === 'hotel' ? {
|
---|
80 | ...formData,
|
---|
81 | hotelId: props.data.hotelId,
|
---|
82 | userId: 1
|
---|
83 | } :
|
---|
84 | props.type === 'restaurant' ? {
|
---|
85 | ...formData,
|
---|
86 | restaurantId: props.data.restaurantId,
|
---|
87 | userId: 1
|
---|
88 | } : {
|
---|
89 | ...formData,
|
---|
90 | transportId: props.data.transportId,
|
---|
91 | userId: 1
|
---|
92 | }
|
---|
93 | createEntity('/review/add', dataToPost)
|
---|
94 | setFormData(dummy)
|
---|
95 | props.handleCloseReview()
|
---|
96 | }
|
---|
97 | }>
|
---|
98 | Зачувај
|
---|
99 | </Button>
|
---|
100 | </Modal.Footer>
|
---|
101 | </Modal>
|
---|
102 | </>
|
---|
103 | )
|
---|
104 | }
|
---|
105 |
|
---|
106 | export default ReviewModal; |
---|