source: RebuMKReact/src/Components/Register/registerDriver.js@ 364f27d

Last change on this file since 364f27d was 364f27d, checked in by MetodiMladenovski <meto.18@…>, 14 months ago

added projects and db scripts

  • Property mode set to 100644
File size: 5.2 KB
RevLine 
[364f27d]1import React from "react";
2import {useNavigate} from "react-router-dom";
3import CenteredContainer from "../UtilComponents/CenteredContainer";
4import '../UtilComponents/App.css'
5
6const registerDriver = (props) => {
7
8 // eslint-disable-next-line react-hooks/rules-of-hooks
9 const navigate = useNavigate();
10 // eslint-disable-next-line react-hooks/rules-of-hooks
11 const [formData, updateFormData] = React.useState({
12 firstName : "",
13 surname : "",
14 email : "",
15 password : "",
16 repeatedPassword: "",
17 pricePerKm : ""
18 })
19
20 const handleChange = (e) => {
21 updateFormData({
22 ...formData,
23 [e.target.name]: e.target.value.trim()
24 })
25 }
26
27 const onFormSubmit = (e) => {
28 e.preventDefault();
29 const firstName = formData.firstName
30 const surname = formData.surname
31 const email = formData.email
32 const password = formData.password
33 const repetedPassword = formData.repeatedPassword
34 const pricePerKm = formData.pricePerKm
35
36 if(password !== repetedPassword)
37 alert("Passwords don't match");
38
39 props.onRegisterDriver(firstName, surname, email, password, pricePerKm);
40 navigate("/login")
41 }
42
43 return(
44 <CenteredContainer>
45 <h3 style={{textAlign: "center", color: "darkcyan"}}>Register Driver</h3>
46 <br></br>
47 <form onSubmit={onFormSubmit}>
48 <div className="form-group">
49 <label htmlFor="firstName">First name</label>
50 <input type="text"
51 className="form-control"
52 id="firstName"
53 name="firstName"
54 required
55 placeholder="E.g: John"
56 style={{height: 100 + "%"}}
57 onChange={handleChange}
58 />
59 </div>
60 <br></br>
61 <div className="form-group">
62 <label htmlFor="surname">Surname</label>
63 <input type="text"
64 className="form-control"
65 id="surname"
66 name="surname"
67 required
68 placeholder="E.g: Doe"
69 style={{height: 100 + "%"}}
70 onChange={handleChange}
71 />
72 </div>
73 <br></br>
74 <div className="form-group">
75 <label htmlFor="email">Email</label>
76 <input type="text"
77 className="form-control"
78 id="email"
79 name="email"
80 placeholder="E.g: johndoe@email.com"
81 required
82 onChange={handleChange}
83 />
84 </div>
85 <br></br>
86 <div className="form-group">
87 <label htmlFor="password">Password</label>
88 <input type="password"
89 className="form-control"
90 id="password"
91 name="password"
92 placeholder="E.g: moreCharacters@123"
93 required
94 onChange={handleChange}
95 />
96 </div>
97 <br></br>
98 <div className="form-group">
99 <label htmlFor="repeatedPassword">Repeat Password</label>
100 <input type="password"
101 className="form-control"
102 id="repeatedPassword"
103 name="repeatedPassword"
104 placeholder="E.g: moreCharacters@123"
105 required
106 onChange={handleChange}
107 />
108 </div>
109 <br></br>
110 <div className="form-group">
111 <label htmlFor="pricePerKm">Price Per Kilometar</label>
112 <input type="number"
113 className="form-control"
114 id="pricePerKm"
115 name="pricePerKm"
116 placeholder="E.g: 50"
117 required
118 onChange={handleChange}
119 />
120 </div>
121 <br></br>
122 <div className="d-grid gap-2 col-6 mx-auto">
123 <button id="submit" type="submit" className="myButton btn btn-primary" style={{backgroundColor: "darkcyan", float: "center", borderColor: "black", color:'white'}}>Register</button>
124 </div>
125 </form>
126 </CenteredContainer>
127 )
128
129}
130
131export default registerDriver;
Note: See TracBrowser for help on using the repository browser.