Passed
Pull Request — main (#345)
by Alejandro
03:34
created

src/utils/FormGroupContainer.tsx

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 30
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 0
eloc 25
mnd 0
bc 0
fnc 0
dl 0
loc 30
ccs 2
cts 3
cp 0.6667
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { FC } from 'react';
2
import { v4 as uuid } from 'uuid';
3
import { InputType } from 'reactstrap/lib/Input';
4
5
interface FormGroupContainer {
6
  value: string;
7
  onChange: (newValue: string) => void;
8
  id?: string;
9
  type?: InputType;
10
  required?: boolean;
11
}
12
13 3
export const FormGroupContainer: FC<FormGroupContainer> = (
14
  { children, value, onChange, id = uuid(), type = 'text', required = true },
15
) => (
16 12
  <div className="form-group">
17
    <label htmlFor={id} className="create-server__label">
18
      {children}:
19
    </label>
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
);
30