Working validation from the server using CallOuts

This commit is contained in:
Belen Curcio
2018-08-16 16:21:52 -03:00
parent e4ebb2553f
commit 94ad23ce9b
10 changed files with 50 additions and 31 deletions
+7 -3
View File
@@ -28,20 +28,24 @@ interface FormProps {
export interface SignInForm {
onSubmit: OnSubmit<FormProps>;
setView: (view: View) => void;
errorMessage: string;
error: string | null;
}
const SignIn: StatelessComponent<SignInForm> = props => {
console.log(props);
return (
<Form onSubmit={props.onSubmit}>
{({ handleSubmit, submitting }) => (
<form autoComplete="off" onSubmit={handleSubmit}>
{props.errorMessage && <CallOut>{props.errorMessage}</CallOut>}
<Flex itemGutter direction="column" className={styles.root}>
<Typography variant="heading1" align="center">
Sign in to join the conversation
</Typography>
{props.error && (
<CallOut color="error" fullWidth>
{props.error}
</CallOut>
)}
<Field
name="email"
validate={composeValidators(required, validateEmail)}
+7 -3
View File
@@ -34,13 +34,13 @@ interface FormProps {
export interface SignUpForm {
onSubmit: OnSubmit<FormProps>;
setView: (view: View) => void;
errorMessage: string;
error: string | null;
}
const SignUp: StatelessComponent<SignUpForm> = props => {
return (
<Form onSubmit={props.onSubmit}>
{props.errorMessage && <CallOut>{props.errorMessage}</CallOut>}
{!!props.error && <CallOut>{props.error}</CallOut>}
{({ handleSubmit, submitting }) => (
<form autoComplete="off" onSubmit={handleSubmit}>
<Flex itemGutter direction="column" className={styles.root}>
@@ -48,7 +48,11 @@ const SignUp: StatelessComponent<SignUpForm> = props => {
<Typography variant="heading1" align="center">
Sign up to join the conversation
</Typography>
{props.error && (
<CallOut color="error" fullWidth>
{props.error}
</CallOut>
)}
<Field
name="email"
validate={composeValidators(required, validateEmail)}