Skip to content

Commit 2552a85

Browse files
committed
AddClient and ClientForm UI Completed.
1 parent 00f09e1 commit 2552a85

File tree

3 files changed

+87
-33
lines changed

3 files changed

+87
-33
lines changed

src/components/client/AddClient.js

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,65 @@
1-
import React from 'react';
1+
import React, {Component} from 'react';
22
import {Container, Row, Col, Card, CardBody, CardHeader} from 'reactstrap';
33
import {NavLink} from "react-router-dom";
4+
import ClientForm from "./ClientForm";
45

5-
const AddClient = () => {
6-
return (
7-
<Container>
8-
<Row>
9-
<Col sm="12">
10-
<div>
11-
<NavLink exact to='/' className="text-primary d-flex align-items-center">
12-
<i className="fas fa-arrow-circle-left mr-1"/>
13-
<p className="font-weight-bold mb-0">Back To Dashboard</p>
14-
</NavLink>
15-
</div>
16-
</Col>
17-
</Row>
18-
</Container>
19-
);
20-
};
6+
class AddClient extends Component {
7+
8+
state = {
9+
firstName: '',
10+
lastName: '',
11+
email: '',
12+
mobile: '',
13+
balance: ''
14+
};
15+
16+
handleChange = (e) => {
17+
this.setState({
18+
[e.target.id]: e.target.value
19+
})
20+
};
21+
22+
handleSubmit = (e) => {
23+
e.preventDefault();
24+
console.log(this.state);
25+
};
26+
27+
render() {
28+
return (
29+
<div>
30+
<Container>
31+
<Row>
32+
<Col sm="12">
33+
<div>
34+
<NavLink exact to='/' className="text-primary d-flex align-items-center">
35+
<i className="fas fa-arrow-circle-left mr-1"/>
36+
<p className="font-weight-bold mb-0">Back To Dashboard</p>
37+
</NavLink>
38+
</div>
39+
</Col>
40+
</Row>
41+
<Row className="mt-3">
42+
<Col sm="12">
43+
<Card>
44+
<CardHeader>Edit Settings</CardHeader>
45+
<CardBody>
46+
<ClientForm
47+
firstName={this.state.firstName}
48+
lastName={this.state.lastName}
49+
email={this.state.email}
50+
mobile={this.state.mobile}
51+
balance={this.state.balance}
52+
handleChange={this.handleChange}
53+
handleSubmit={this.handleSubmit}
54+
/>
55+
</CardBody>
56+
</Card>
57+
</Col>
58+
</Row>
59+
</Container>
60+
</div>
61+
);
62+
}
63+
}
2164

2265
export default AddClient;

src/components/client/ClientForm.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
import React from 'react';
2-
import {Container, Row, Col, Card, CardBody, CardHeader} from 'reactstrap';
3-
import {NavLink} from "react-router-dom";
2+
import {Form, FormGroup, Label, Input, Button} from 'reactstrap';
3+
4+
const ClientForm = ({firstName='', lastName='', email='', mobile='', balance='', handleChange, handleSubmit}) => {
45

5-
const ClientForm = () => {
66
return (
7-
<Container>
8-
<Row>
9-
<Col sm="12">
10-
<div>
11-
<NavLink exact to='/' className="text-primary d-flex align-items-center">
12-
<i className="fas fa-arrow-circle-left mr-1"/>
13-
<p className="font-weight-bold mb-0">Back To Dashboard</p>
14-
</NavLink>
15-
</div>
16-
</Col>
17-
</Row>
18-
</Container>
7+
<Form onSubmit={handleSubmit}>
8+
<FormGroup>
9+
<Label for="name">First Name</Label>
10+
<Input type="text" value={firstName} id="firstName" placeholder="First Name" pattern="[A-Za-z0-9_ ]{3,}" title="Minimum three letter name." onChange={handleChange} required/>
11+
</FormGroup>
12+
<FormGroup>
13+
<Label for="name">Last Name</Label>
14+
<Input type="text" value={lastName} id="lastName" placeholder="Last Name" pattern="[A-Za-z0-9_ ]{3,}" title="Minimum three letter name." onChange={handleChange} required/>
15+
</FormGroup>
16+
<FormGroup>
17+
<Label for="email">Email</Label>
18+
<Input type="email" value={email} id="email" placeholder="Email" onChange={handleChange}/>
19+
</FormGroup>
20+
<FormGroup>
21+
<Label for="name">Mobile Number</Label>
22+
<Input type="text" value={mobile} id="mobile" placeholder="Mobile Number" pattern="[0-9]{10}" title="Mobile Number must be of 10 digit." onChange={handleChange} required/>
23+
</FormGroup>
24+
<FormGroup>
25+
<Label for="name">Balance</Label>
26+
<Input type="text" value={balance} id="balance" placeholder="Balance" pattern="^\d+\.\d\d$" title="Valid balance is 10.00, 10.90 or 0.78." onChange={handleChange} required/>
27+
</FormGroup>
28+
<Button color="primary" size="sm" block>Submit</Button>
29+
</Form>
1930
);
2031
};
2132

src/components/routes/Router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Router = () => {
1414
<BrowserRouter>
1515
<div>
1616
<Header/>
17-
<div className="mt-5 pt-4">
17+
<div className="mt-5 pt-4 mb-5">
1818
<Switch>
1919
<Route exact path='/' component={Dashboard}/>
2020
<Route path='/login' component={SignIn}/>

0 commit comments

Comments
 (0)