|
|
|
@@ -0,0 +1,40 @@ |
|
|
|
import React from "react"; |
|
|
|
import PropTypes from "prop-types"; |
|
|
|
|
|
|
|
function CheckBoxInput(props) { |
|
|
|
let wrapperClass = "form-group"; |
|
|
|
if (props.error.length > 0) { |
|
|
|
wrapperClass += "has-error"; |
|
|
|
} |
|
|
|
return ( |
|
|
|
<div className={wrapperClass}> |
|
|
|
<label htmlFor={props.id}>{props.label}</label> |
|
|
|
<div className="field"> |
|
|
|
<input |
|
|
|
id={props.id} |
|
|
|
type="checkbox" |
|
|
|
onChange={props.onChange} |
|
|
|
name={props.name} |
|
|
|
className="form-control" |
|
|
|
checked={props.value} |
|
|
|
/> |
|
|
|
</div> |
|
|
|
{props.error && <div className="alert alert-danger">{props.error}</div>} |
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
CheckBoxInput.propTypes = { |
|
|
|
id: PropTypes.string.isRequired, |
|
|
|
name: PropTypes.string.isRequired, |
|
|
|
label: PropTypes.string.isRequired, |
|
|
|
onChange: PropTypes.func.isRequired, |
|
|
|
checked: PropTypes.string, |
|
|
|
error: PropTypes.string, |
|
|
|
}; |
|
|
|
|
|
|
|
CheckBoxInput.defaultProps = { |
|
|
|
error: "", |
|
|
|
}; |
|
|
|
|
|
|
|
export default CheckBoxInput; |