Adding SignUp Form Functionality

This commit is contained in:
Belen Curcio
2018-08-13 13:25:51 -03:00
parent 6648dfe492
commit b4480f4bf7
3 changed files with 131 additions and 45 deletions
+102 -37
View File
@@ -1,6 +1,13 @@
import * as React from "react";
import { StatelessComponent } from "react";
import * as styles from "./SignIn.css";
import React, { StatelessComponent } from "react";
import { Field, Form } from "react-final-form";
import { OnSubmit } from "talk-framework/lib/form";
import {
composeValidators,
required,
validateEmail,
validatePassword,
} from "talk-framework/lib/validation";
import {
Button,
@@ -9,43 +16,101 @@ import {
InputLabel,
TextField,
Typography,
ValidationMessage,
} from "talk-ui/components";
const SignIn: StatelessComponent = props => {
import * as styles from "./SignIn.css";
interface FormProps {
email: string;
password: string;
}
export interface SignInForm {
onSubmit: OnSubmit<FormProps>;
}
const SignIn: StatelessComponent<SignInForm> = props => {
return (
<Flex itemGutter direction="column" className={styles.root}>
<Typography variant="heading1" align="center">
Sign in to join the conversation
</Typography>
<FormField>
<InputLabel>Email Address</InputLabel>
<TextField />
</FormField>
<FormField>
<InputLabel>Password</InputLabel>
<TextField />
<span className={styles.forgotPassword}>
<Button variant="underlined" color="primary" size="small">
Forgot your password?
</Button>
</span>
</FormField>
<div className={styles.footer}>
<Button variant="filled" color="primary" size="large" fullWidth>
Sign in and join the conversation
</Button>
<Flex
itemGutter="half"
justifyContent="center"
className={styles.subFooter}
>
<Typography>Don't have an account?</Typography>
<Button variant="underlined" size="small" color="primary">
Sign Up
</Button>
</Flex>
</div>
</Flex>
<Form onSubmit={props.onSubmit}>
{({ handleSubmit, submitting }) => (
<form autoComplete="off" onSubmit={handleSubmit}>
<Flex itemGutter direction="column" className={styles.root}>
<Typography variant="heading1" align="center">
Sign in to join the conversation
</Typography>
<Field
name="email"
validate={composeValidators(required, validateEmail)}
>
{({ input, meta }) => (
<FormField>
<InputLabel>Email Address</InputLabel>
<TextField
name={input.name}
onChange={input.onChange}
value={input.value}
placeholder="Email Address"
/>
{meta.touched &&
(meta.error || meta.submitError) && (
<ValidationMessage>
{meta.error || meta.submitError}
</ValidationMessage>
)}
</FormField>
)}
</Field>
<Field
name="password"
validate={composeValidators(required, validatePassword)}
>
{({ input, meta }) => (
<FormField>
<InputLabel>Password</InputLabel>
<TextField
name={input.name}
onChange={input.onChange}
value={input.value}
placeholder="Password"
type="password"
/>
{meta.touched &&
(meta.error || meta.submitError) && (
<ValidationMessage>
{meta.error || meta.submitError}
</ValidationMessage>
)}
<span className={styles.forgotPassword}>
<Button variant="underlined" color="primary" size="small">
Forgot your password?
</Button>
</span>
</FormField>
)}
</Field>
<div className={styles.footer}>
<Button variant="filled" color="primary" size="large" fullWidth>
Sign in and join the conversation
</Button>
<Flex
itemGutter="half"
justifyContent="center"
className={styles.subFooter}
>
<Typography>Don't have an account?</Typography>
<Button variant="underlined" size="small" color="primary">
Sign Up
</Button>
</Flex>
</div>
</Flex>
</form>
)}
</Form>
);
};
+1 -1
View File
@@ -37,7 +37,7 @@ export interface SignUpForm {
const SignUp: StatelessComponent<SignUpForm> = props => {
return (
<Form onSubmit={props.onSubmit}>
{({ handleSubmit, submitting, invalid }) => (
{({ handleSubmit, submitting }) => (
<form autoComplete="off" onSubmit={handleSubmit}>
<Flex itemGutter direction="column" className={styles.root}>
<Flex direction="column">