source: frontend/src/Components/Registration/RegistrationForm.js@ 0f5aa27

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

images upload/download impl, other fixes

  • Property mode set to 100644
File size: 9.3 KB
Line 
1import { useState } from "react";
2import React from "react";
3import { Container, Form, Button, FormControl, FormLabel, Row, Col, InputGroup } from "react-bootstrap";
4import { AiFillLock, AiOutlineMail, AiOutlinePhone, AiOutlineKey } from "react-icons/ai"
5import useFormData from "../Hooks/useFormData";
6import useCreateHotel from "../Hooks/Hotel/useCreateHotel";
7import useCreateUser from "../Hooks/User/useCreateUser";
8
9
10const RegistrationForm = () => {
11 const [validated, setValidated] = useState(false)
12
13 const handleSubmit = (event) => {
14 const form = event.currentTarget;
15 if (form.checkValidity() === false) {
16 event.preventDefault();
17 event.stopPropagation();
18 }
19 event.preventDefault();
20 createUser(formData)
21
22 setValidated(true);
23 };
24
25 const { createUser } = useCreateUser();
26
27 const { formData, onFormChange, onCheckBoxChange, setFormData } = useFormData({
28 name: "",
29 surname: "",
30 email: "",
31 password: "",
32 birthDate: Date.now(),
33 address: "",
34 contact: "111",
35 });
36
37 return (
38 <Container className="rounded-5 m-5 my-auto mx-auto py-5 px-5" style={{backgroundColor: "#ffffff"}}>
39 <Form noValidate validated={validated} onSubmit={handleSubmit}>
40 <Row className="mb-3">
41 <Form.Group as={Col} md="4" controlId="validationCustom01">
42 <Form.Label>Име</Form.Label>
43 <Form.Control
44 required
45 type="text"
46 placeholder="Име"
47 name="name"
48 value={formData.name}
49 onChange={onFormChange}
50 />
51 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
52 <Form.Control.Feedback type="invalid">
53 Име е задолжително
54 </Form.Control.Feedback>
55 </Form.Group>
56 <Form.Group as={Col} md="4" controlId="validationCustom02">
57 <Form.Label>Презиме</Form.Label>
58 <Form.Control
59 required
60 type="text"
61 placeholder="Презиме"
62 name="surname"
63 value={formData.surname}
64 onChange={onFormChange}
65 />
66 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
67 <Form.Control.Feedback type="invalid">
68 Презиме е задолжително
69 </Form.Control.Feedback>
70 </Form.Group>
71 <Form.Group as={Col} md="4" controlId="validationCustomUsername">
72 <Form.Label>Датум на раѓање</Form.Label>
73 <InputGroup hasValidation>
74 <Form.Control
75 size="md"
76 type="date"
77 placeholder="Датум"
78 name="birthDate"
79 value={formData.birthDate}
80 onChange={onFormChange}
81 required
82 ></Form.Control>
83 <Form.Control.Feedback type="invalid">
84 Датум на раѓање е задолжителен
85 </Form.Control.Feedback>
86 </InputGroup>
87 </Form.Group>
88 </Row>
89 <Row className="mb-3">
90 <Form.Group as={Col} md="4" controlId="validationCustom01">
91 <Form.Label>Држава</Form.Label>
92 <Form.Control
93 required
94 type="text"
95 placeholder="Држава"
96
97 />
98 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
99 <Form.Control.Feedback type="invalid">
100 Држава е задолжително
101 </Form.Control.Feedback>
102 </Form.Group>
103 <Form.Group as={Col} md="4" controlId="validationCustom01">
104 <Form.Label>Град</Form.Label>
105 <Form.Control
106 required
107 type="text"
108 placeholder="Град"
109
110 />
111 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
112 <Form.Control.Feedback type="invalid">
113 Град е задолжителен
114 </Form.Control.Feedback>
115 </Form.Group>
116 <Form.Group as={Col} md="4" controlId="validationCustom01">
117 <Form.Label>Поштенски код</Form.Label>
118 <Form.Control
119 required
120 type="text"
121 placeholder="Поштенски код"
122
123 />
124 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
125 <Form.Control.Feedback type="invalid">
126 Поштенски код е задолжителен
127 </Form.Control.Feedback>
128 </Form.Group>
129 </Row>
130 <Row className="mb-3">
131 <Form.Group as={Col} controlId="validationCustom01">
132 <Form.Label>Адреса</Form.Label>
133 <Form.Control
134 required
135 type="text"
136 placeholder="Адреса"
137 name="address"
138 value={formData.address}
139 onChange={onFormChange}
140 />
141 <Form.Control.Feedback>Во ред!</Form.Control.Feedback>
142 <Form.Control.Feedback type="invalid">
143 Адреса е задолжително
144 </Form.Control.Feedback>
145 </Form.Group>
146 </Row>
147 <Row className="mb-3">
148 <Form.Group as={Col} md="6" controlId="validationCustomUsername">
149 <Form.Label>Е-маил</Form.Label>
150 <InputGroup hasValidation>
151 <InputGroup.Text id="inputGroupPrepend"><span className="ikona "><AiOutlineMail/></span></InputGroup.Text>
152 <Form.Control
153 type="email"
154 placeholder="Е-маил"
155 aria-describedby="inputGroupPrepend"
156 name="email"
157 value={formData.email}
158 onChange={onFormChange}
159 required
160 />
161 <Form.Control.Feedback type="invalid">
162 Е-маил е задолжителен
163 </Form.Control.Feedback>
164 </InputGroup>
165 </Form.Group>
166 <Form.Group as={Col} md="6" controlId="validationCustomUsername">
167 <Form.Label>Телефон</Form.Label>
168 <InputGroup hasValidation>
169 <InputGroup.Text id="inputGroupPrepend"><span className="ikona "><AiOutlinePhone/></span></InputGroup.Text>
170 <Form.Control
171 type="text"
172 placeholder="Телефон"
173 aria-describedby="inputGroupPrepend"
174 name="contact"
175 value={formData.contact}
176 onChange={onFormChange}
177 />
178 </InputGroup>
179 </Form.Group>
180 </Row>
181 <hr></hr>
182 <Row className="mb-3">
183 <Form.Group as={Col} md="6" controlId="validationCustomUsername">
184 <Form.Label>Лозинка</Form.Label>
185 <InputGroup hasValidation>
186 <InputGroup.Text id="inputGroupPrepend"><span className="ikona "><AiOutlineKey/></span></InputGroup.Text>
187 <Form.Control
188 type="text"
189 placeholder="Лозинка"
190 aria-describedby="inputGroupPrepend"
191 name="password"
192 value={formData.password}
193 onChange={onFormChange}
194 required
195 />
196 <Form.Control.Feedback type="invalid">
197 Лозинката мора да содржи најмалку 8 карактери, една голема буква, еден број и еден специјален знак
198 </Form.Control.Feedback>
199 </InputGroup>
200 </Form.Group>
201 <Form.Group as={Col} md="6" controlId="validationCustomUsername">
202 <Form.Label>Повторена лозинка</Form.Label>
203 <InputGroup hasValidation>
204 <InputGroup.Text id="inputGroupPrepend"><span className="ikona "><AiOutlineKey/></span></InputGroup.Text>
205 <Form.Control
206 type="password"
207 placeholder="Лозинка"
208 aria-describedby="inputGroupPrepend"
209 required
210 />
211 <Form.Control.Feedback type="invalid">
212 Лозинките не се совпаѓаат
213 </Form.Control.Feedback>
214 </InputGroup>
215 </Form.Group>
216 </Row>
217 <hr></hr>
218 <Form.Group className="mb-3">
219 <Form.Check
220 required
221 label="Се согласувам со правилата и условите за користење"
222 feedback="Мора да се согласите пред да продолжите"
223 feedbackType="invalid"
224 />
225 </Form.Group>
226 <Button type="submit" style={{backgroundColor: "#159895"}} size="md">
227 <span className="ikona mx-3">Регистрирај се</span>
228 </Button>
229 </Form>
230 </Container>
231 );
232};
233
234export default RegistrationForm;
Note: See TracBrowser for help on using the repository browser.