Skip to content
Snippets Groups Projects
Verified Commit 1bab70b5 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Rename props

parent 6610767b
No related branches found
No related tags found
2 merge requests!19Working email validation and hiding controller logic to InputField,!13Basic form api and implement cookie entrypoint
Pipeline #11660 failed
...@@ -3,19 +3,25 @@ import { TextField } from '@material-ui/core'; ...@@ -3,19 +3,25 @@ import { TextField } from '@material-ui/core';
import { Control, Controller, FieldValues } from 'react-hook-form'; import { Control, Controller, FieldValues } from 'react-hook-form';
type Props = { type Props = {
id: string; /**
* Name of the elemement. ex. email, password
*/
name: string;
label: string; label: string;
error: boolean; error: boolean;
errorMessage: string; errorMessage: string;
/**
* react-hook-form control
*/
control: Control<FieldValues> | undefined; control: Control<FieldValues> | undefined;
rules: Partial<unknown>; rules: Partial<unknown>;
}; };
export const InputField: FC<Props> = (props: Props) => { export const InputField: FC<Props> = (props: Props) => {
const { id, label, error, errorMessage, control, rules } = props; const { name, label, error, errorMessage, control, rules } = props;
return ( return (
<Controller <Controller
name={id} name={name}
control={control} control={control}
rules={rules} rules={rules}
render={({ onChange, value }) => ( render={({ onChange, value }) => (
...@@ -24,12 +30,12 @@ export const InputField: FC<Props> = (props: Props) => { ...@@ -24,12 +30,12 @@ export const InputField: FC<Props> = (props: Props) => {
margin="normal" margin="normal"
required required
fullWidth fullWidth
id={id} id={name}
label={label} label={label}
name={id} name={name}
onChange={onChange} onChange={onChange}
value={value} value={value}
autoComplete={id} autoComplete={name}
autoFocus autoFocus
error={error} error={error}
helperText={error && errorMessage} helperText={error && errorMessage}
......
...@@ -62,7 +62,7 @@ export const SignInForm: FC = () => { ...@@ -62,7 +62,7 @@ export const SignInForm: FC = () => {
data-testid="Form" data-testid="Form"
> >
<InputField <InputField
id="email" name="email"
control={control} control={control}
rules={{ rules={{
validate: (value: string) => validate: (value: string) =>
...@@ -78,7 +78,7 @@ export const SignInForm: FC = () => { ...@@ -78,7 +78,7 @@ export const SignInForm: FC = () => {
/> />
<InputField <InputField
id="password" name="password"
control={control} control={control}
rules={{ rules={{
minLength: 8, minLength: 8,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment