Completed
Push — master ( e26cdc...da6d7a )
by Alejandro
17s queued 11s
created

src/utils/HorizontalFormGroup.js

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 33
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 0
eloc 29
mnd 0
bc 0
fnc 0
dl 0
loc 33
ccs 4
cts 5
cp 0.8
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from 'react';
2
import { v4 as uuid } from 'uuid';
3
import PropTypes from 'prop-types';
4
5 3
const propTypes = {
6
  children: PropTypes.node.isRequired,
7
  value: PropTypes.string.isRequired,
8
  onChange: PropTypes.func.isRequired,
9
  id: PropTypes.string,
10
  type: PropTypes.string,
11
  required: PropTypes.bool,
12
};
13
14 3
export const HorizontalFormGroup = ({ children, value, onChange, id = uuid(), type = 'text', required = true }) => (
15 12
  <div className="form-group row">
16
    <label htmlFor={id} className="col-lg-1 col-md-2 col-form-label create-server__label">
17
      {children}:
18
    </label>
19
    <div className="col-lg-11 col-md-10">
20
      <input
21
        className="form-control"
22
        type={type}
23
        id={id}
24
        value={value}
25
        required={required}
26
        onChange={(e) => onChange(e.target.value)}
27
      />
28
    </div>
29
  </div>
30
);
31
32
HorizontalFormGroup.propTypes = propTypes;
33