-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormSection.jsx
37 lines (33 loc) · 1.13 KB
/
FormSection.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import '../App.css';
import React from 'react';
import InvalidInput from './InvalidInput'
import ValidInput from './ValidInput'
import { Form, FormGroup, Label, Input, FormText, Button} from 'reactstrap';
class FormSection extends React.Component {
render() {
const {value, valid} = this.props
return(
<Form>
<FormGroup>
<Label for="exampleEmail">
Phone Number
</Label>
{ value.length === 0 &&
<React.Fragment>
<Input autoFocus="autofocus" value={value} onChange={this.props.handleChange} />
<FormText>Number Count : {value.length || 0}</FormText>
</React.Fragment>
}
{ value.length > 0 && valid === true &&
<ValidInput {...this.props} message="Sweet! You are good to go"/>
}
{ value.length > 0 && valid === false &&
<InvalidInput {...this.props} message="Oh noes! check the number again"/>
}
</FormGroup>
<Button color="success" disabled={!valid} onClick={this.props.handleSubmit}>Send</Button>
</Form>
)
}
}
export default FormSection