-
Notifications
You must be signed in to change notification settings - Fork 0
Created Add_Driver UI [#171205845] #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import React, { useState } from 'react'; | ||
| import { Button, InputGroup, Input} from 'reactstrap'; | ||
| import 'bootstrap/dist/css/bootstrap.min.css'; | ||
| import './component.css'; | ||
|
|
||
| function Add_Driver() { | ||
| const [driverFirstName, setDriverFirstName] = useState(''); | ||
| const [driverLastName, setDriverLastName] = useState(''); | ||
| const [driverEmailId, setDriverEmailId] = useState(''); | ||
| const [driverContactNo1, setDriverContactNo1] = useState(''); | ||
| const [driverContactNo2, setDriverContactNo2] = useState(''); | ||
| const [driverLicenseNo, setDriverLicenseNo] = useState(''); | ||
|
|
||
| // Submit Event for Add Driver Button | ||
| const submit = () => { | ||
| const user = { | ||
| first_name: driverFirstName, | ||
| last_name: driverLastName, | ||
| email_id: driverEmailId, | ||
| contact_no_1: driverContactNo1, | ||
| contact_no_2: driverContactNo2, | ||
| license_no: driverLicenseNo, | ||
| }; | ||
| fetch('http://localhost:4000/users', { | ||
| method: 'POST', | ||
| headers: { | ||
| Accept: 'application/cab-tab.com; version=1', | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(user), | ||
| }).then((response) => { console.log(response); }); | ||
| }; | ||
|
Comment on lines
+24
to
+32
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should generic handler for api calling, ApiHelper which would contain wrapper over fetch. |
||
|
|
||
| return ( | ||
| <div> | ||
| <div className="card col-sm-7"> | ||
| <div className="card__container"> | ||
| <div> | ||
| <h1 className="card__title">Add Driver to Organization</h1> | ||
| </div> | ||
| <br /> | ||
| <div className="row"> | ||
| <InputGroup className="col-sm-6"> | ||
| <Input | ||
| placeholder="Driver's First Name" | ||
| type="text" | ||
| name="driver_first_name" | ||
| value={driverFirstName} | ||
| onChange={(e) => setDriverFirstName(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| <br /> | ||
| <InputGroup className="col-sm-6"> | ||
| <Input | ||
| placeholder="Driver's Last Name" | ||
| type="text" | ||
| name="driver_last_name" | ||
| value={driverLastName} | ||
| onChange={(e) => setDriverLastName(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| </div> | ||
| <br /> | ||
|
|
||
| <div className="row"> | ||
| <InputGroup className="col-sm-6"> | ||
| <Input | ||
| placeholder="Driver's Contact Number 1" | ||
| type="number" | ||
| name="driver_contact_1" | ||
| value={driverContactNo1} | ||
| onChange={(e) => setDriverContactNo1(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| <InputGroup className="col-sm-6"> | ||
| <Input | ||
| placeholder="Driver's Contact Number 2" | ||
| type="number" | ||
| name="driver_contact_2" | ||
| value={driverContactNo2} | ||
| onChange={(e) => setDriverContactNo2(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| </div> | ||
| <br /> | ||
|
|
||
| <div className="row"> | ||
| <InputGroup className="col-sm-12"> | ||
| <Input | ||
| placeholder="Driver's Email ID" | ||
| type="email" | ||
| name="driver_email_id" | ||
| value={driverEmailId} | ||
| onChange={(e) => setDriverEmailId(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| </div> | ||
| <br /> | ||
|
|
||
| <div className="row"> | ||
| <InputGroup className="col-sm-12"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it require to wrap input into input group all time |
||
| <Input | ||
| placeholder="Driver's License Number" | ||
| type="text" | ||
| name="driver_license_no" | ||
| value={driverLicenseNo} | ||
| onChange={(e) => setDriverLicenseNo(e.target.value)} | ||
| /> | ||
| </InputGroup> | ||
| </div> | ||
| <br /> | ||
| <Button className="add__btn" color="success" size="sm" onClick={submit}>Add</Button> | ||
| <br /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| export default Add_Driver; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make it one object say driverDetailObject and add generic handler.