source: frontend/src/Components/Forms/AddRestaurantForm.js@ 5528b99

Last change on this file since 5528b99 was 5528b99, checked in by darsov2 <62809499+darsov2@…>, 6 months ago

revert

  • Property mode set to 100644
File size: 3.3 KB
Line 
1import React, { useEffect } from "react";
2import { Form, Button, Container } from "react-bootstrap";
3import { GiConfirmed } from "react-icons/gi";
4import useCreateRestaurant from "../Hooks/Restaurant/useCreateRestaurant";
5import useFormData from "../Hooks/useFormData";
6import useGet from "../Hooks/useGet";
7
8const AddRestaurantForm = (props) => {
9
10 const { createRestaurant } = useCreateRestaurant();
11 var dummy = {
12 restaurantName: "",
13 restaurantLocation: "",
14 cousineType: "",
15 restaurantDescription: "",
16 restaurantEdbs: "111",
17 }
18
19 const edit = props.restaurant != null
20
21 const { formData, onFormChange, onCheckBoxChange, setFormData } = useFormData(edit ? props.restaurant : dummy);
22
23 console.log(formData)
24
25 return (
26 <>
27 <Container
28 className="rounded-5 m-5 my-auto mx-auto py-2 px-5"
29 style={{ backgroundColor: "#ffffff" }}
30 >
31 <Form>
32 <Form.Group className="mb-3" controlId="restaurantName">
33 <Form.Label>Име на ресторант</Form.Label>
34 <Form.Control
35 type="text"
36 name="restaurantName"
37 placeholder="Внесете го името на ресторантот"
38 value={formData.restaurantName}
39 onChange={onFormChange}
40 />
41 </Form.Group>
42
43 <Form.Group className="mb-3" controlId="restaurantLocation">
44 <Form.Label>Локација на ресторант</Form.Label>
45 <Form.Control
46 type="text"
47 name="restaurantLocation"
48 placeholder="Внесете ја локацијата на ресторантот"
49 value={formData.restaurantLocation}
50 onChange={onFormChange}
51 />
52 </Form.Group>
53
54 <Form.Group className="mb-3" controlId="restaurantDescription">
55 <Form.Label>Опис</Form.Label>
56 <Form.Control
57 as="textarea"
58 name="restaurantDescription"
59 placeholder="Внесете опис на ресторантот"
60 value={formData.restaurantDescription}
61 onChange={onFormChange}
62 />
63 </Form.Group>
64
65 <Form.Group className="mb-3" controlId="restaurantCuisine">
66 <Form.Label>Тип кујна</Form.Label>
67 <Form.Control
68 type="text"
69 name="cousineType"
70 placeholder="Внесете го типот на кујна"
71 value={formData.cousineType}
72 onChange={onFormChange}
73 />
74 </Form.Group>
75
76 <Form.Group className="my-1 justify-content-center">
77 <Button
78 type="submit"
79 style={{ backgroundColor: "#159895" }}
80 size="md"
81 onClick={(e) => {
82 e.preventDefault()
83 createRestaurant(formData, edit);
84 props.refresh((prevState) => {
85 return prevState + 1;
86 })
87 }}
88 >
89 <span className="ikona my-1">
90 <GiConfirmed />
91 </span>
92 <span className="ikona mx-3">Поднеси апликација</span>
93 </Button>
94 </Form.Group>
95 </Form>
96 </Container>
97 </>
98 );
99};
100
101export default AddRestaurantForm;
Note: See TracBrowser for help on using the repository browser.