Skip to content
Snippets Groups Projects

Basic form api and implement cookie entrypoint

Merged Defendi Alberto requested to merge dev into master
Files
17
 
import React, { FC } from 'react';
 
import { TextField } from '@material-ui/core';
 
import { Control, Controller, FieldValues } from 'react-hook-form';
 
 
type Props = {
 
/**
 
* Name of the elemement. ex. email, password
 
*/
 
name: string;
 
label: string;
 
error: boolean;
 
errorMessage: string;
 
/**
 
* react-hook-form control
 
*/
 
control: Control<FieldValues> | undefined;
 
rules: Partial<unknown>;
 
};
 
 
export const InputField: FC<Props> = (props: Props) => {
 
const { name, label, error, errorMessage, control, rules } = props;
 
return (
 
<Controller
 
name={name}
 
control={control}
 
rules={rules}
 
render={({ onChange, value }) => (
 
<TextField
 
variant="outlined"
 
margin="normal"
 
required
 
fullWidth
 
id={name}
 
label={label}
 
name={name}
 
onChange={onChange}
 
value={value}
 
autoComplete={name}
 
autoFocus
 
error={error}
 
helperText={error && errorMessage}
 
/>
 
)}
 
/>
 
);
 
};
Loading