Files
shlink-web-client/src/utils/FormGroupContainer.tsx
Alejandro Celaya 4d969b994e Improved server form
2020-12-12 11:43:16 +01:00

30 lines
715 B
TypeScript

import { FC } from 'react';
import { v4 as uuid } from 'uuid';
import { InputType } from 'reactstrap/lib/Input';
interface FormGroupContainer {
value: string;
onChange: (newValue: string) => void;
id?: string;
type?: InputType;
required?: boolean;
}
export const FormGroupContainer: FC<FormGroupContainer> = (
{ children, value, onChange, id = uuid(), type = 'text', required = true },
) => (
<div className="form-group">
<label htmlFor={id} className="create-server__label">
{children}:
</label>
<input
className="form-control"
type={type}
id={id}
value={value}
required={required}
onChange={(e) => onChange(e.target.value)}
/>
</div>
);