source: frontend/src/Components/Forms/AddItemMenuForm.js@ efaa053

Last change on this file since efaa053 was 0f5aa27, checked in by darsov2 <62809499+darsov2@…>, 10 months ago

ouath, mailing impl

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