source: frontend/src/Dashboard/AddNewReservation.js@ d76b7ee

Last change on this file since d76b7ee was d76b7ee, checked in by Danilo <danilo.najkov@…>, 2 years ago

prototype final

  • Property mode set to 100644
File size: 5.1 KB
Line 
1import React,{useState,useEffect} from 'react'
2import {DatePicker, Form, Input, Modal, notification, Radio, Select} from "antd";
3import axios from "axios";
4import env from "../env";
5
6const AddNewReservation = ({ setModalSaveLoading, setModalVisible, fetchData}) => {
7
8 const saveNewReservation = (data) => {
9 setModalSaveLoading(true)
10 const sendObj = {...data,startDate: data.startDate.format('YYYY-MM-DDThh:mm:ss')+'Z', persons: parseInt(data.persons)}
11 console.log(sendObj)
12 axios.post(env.api+"Reservations",sendObj).then(el => {
13 setModalSaveLoading(false)
14 setModalVisible(false)
15 if(fetchData) fetchData()
16 Modal.success({title:'Испратено', content:'Вашата резервација е испратена.'})
17 }).catch(er=>{
18 setModalSaveLoading(false)
19 notification['error']({
20 message: 'Се случи проблем при додавање резервација. Ве молиме пробајте повторно подоцна',
21 });
22
23 console.log(er);
24 });
25 }
26
27
28 return(
29 <div>
30 <Form onFinish={saveNewReservation}
31 id={'newResForm'}
32 onFinishFailed={()=>
33 notification['error']({
34 message: 'Ве молиме поправете ги сите грешки пред зачувување!',
35 })}>
36 <i style={{color:'gray'}}>Датум и време за вашата резервација</i>
37 <Form.Item
38 label="Почеток"
39 name="startDate"
40 rules={[
41 {
42 required: true,
43 message: 'Ве молиме внесете датум и време!',
44 },
45 ]}
46 >
47 <DatePicker showTime showNow={false} format={'DD.MM HH:mm'} placeholder={'Избери датум и време'} style={{width:'100%'}}/>
48 </Form.Item>
49 <i style={{color:'gray'}}>Внесете број на гости за резервацијата</i>
50 <Form.Item
51 label="Број на гости"
52 name="persons"
53 rules={[
54 {
55 required: true,
56 message: 'Ве молиме внесете број на гости!',
57 },
58 ]}
59 >
60 <Input placeholder={'Внесете број'} type={'number'}/>
61 </Form.Item>
62 <i style={{color:'gray'}}>Изберете место и тип на резервација</i>
63 <Form.Item
64 label="Место"
65 name="reservationPlace"
66 rules={[
67 {
68 required: true,
69 message: 'Ве молиме изберете место!',
70 },
71 ]}
72 >
73 <Select>
74 <Select.Option value={0}>Внатре</Select.Option>
75 <Select.Option value={1}>Надвор</Select.Option>
76 </Select>
77 </Form.Item>
78 <Form.Item
79 label="Тип"
80 name="reservationType"
81 rules={[
82 {
83 required: true,
84 message: 'Ве молиме изберете тип!',
85 },
86 ]}
87 >
88 <Select>
89 <Select.Option value={0}>Кратко</Select.Option>
90 <Select.Option value={1}>Долго</Select.Option>
91 <Select.Option value={2}>Настан</Select.Option>
92 </Select>
93 </Form.Item>
94 <i style={{color:'gray'}}>Контакт информации</i>
95 <Form.Item
96 label="Име"
97 name="contactName"
98 rules={[
99 {
100 required: true,
101 message: 'Ве молиме внесете име!',
102 },
103 ]}
104 >
105 <Input/>
106 </Form.Item>
107 <Form.Item
108 label="Телефонски број"
109 name="contactNumber"
110 rules={[
111 {
112 required: true,
113 message: 'Ве молиме внесете број за контакт!',
114 },
115 ]}
116 >
117 <Input placeholder={'пр. 070123456'}/>
118 </Form.Item>
119
120 </Form>
121 </div>
122 )
123}
124
125export default AddNewReservation;
Note: See TracBrowser for help on using the repository browser.