File tree Expand file tree Collapse file tree 4 files changed +104
-22
lines changed
Components/Navbar/Components/Register
Pages/CreateListing/Components/CreateListingForm Expand file tree Collapse file tree 4 files changed +104
-22
lines changed Original file line number Diff line number Diff line change
1
+ import * as React from 'react'
2
+ import { Form , Field } from 'formik'
3
+
4
+ import { FormikInput } from 'src/Components/FomikInput'
5
+ import { Button } from 'src/Components/Button'
6
+ import { Br } from 'src/Components/Br'
7
+ import { Text } from './style'
8
+
9
+ interface Props {
10
+ changePage : ( ) => void
11
+ submit : ( ) => void
12
+ }
13
+
14
+ export const RegisterUI : React . SFC < Props > = ( { changePage, submit } ) => (
15
+ < Form >
16
+ < Field
17
+ name = "email"
18
+ placeholder = "Email"
19
+ label = "Email"
20
+ component = { FormikInput }
21
+ />
22
+
23
+ < Field
24
+ name = "password"
25
+ placeholder = "Password"
26
+ label = "Password"
27
+ type = "password"
28
+ component = { FormikInput }
29
+ />
30
+
31
+ < Button fullWidth onClick = { submit } >
32
+ Register
33
+ </ Button >
34
+
35
+ < Br />
36
+
37
+ < Text onClick = { changePage } > Login</ Text >
38
+ </ Form >
39
+ )
Original file line number Diff line number Diff line change 1
1
import * as React from 'react'
2
+ import { Formik } from 'formik'
2
3
3
- import { Input } from 'src/Components/Input'
4
- import { Button } from 'src/Components/Button'
5
- import { Br } from 'src/Components/Br'
6
- import { Text } from './style'
4
+ import { RegisterMutation } from 'src/Graphql/Register'
5
+ import { RegisterUI } from './Register'
6
+
7
+ interface FieldProps {
8
+ email : string
9
+ password : string
10
+ }
7
11
8
12
interface Props {
9
13
changePage : ( ) => void
10
14
}
11
15
12
- export const Register : React . SFC < Props > = ( { changePage } ) => (
13
- < >
14
- < Input onChange = { ( ) => null } type = "text" placeholder = "Email" />
15
-
16
- < Input onChange = { ( ) => null } type = "text" placeholder = "Name" />
17
-
18
- < Input onChange = { ( ) => null } type = "text" placeholder = "Surname" />
19
-
20
- < Input onChange = { ( ) => null } type = "password" placeholder = "Password" />
21
-
22
- < Button fullWidth > Register</ Button >
23
-
24
- < Br />
25
-
26
- < Text onClick = { changePage } > Login</ Text >
27
- </ >
28
- )
16
+ export class Register extends React . Component < Props , { } > {
17
+ public render ( ) {
18
+ const { changePage } = this . props
19
+
20
+ return (
21
+ < RegisterMutation >
22
+ { ( { register } ) => (
23
+ < Formik < FieldProps >
24
+ initialValues = { { email : '' , password : '' } }
25
+ onSubmit = { async ( values : FieldProps ) =>
26
+ await register ( {
27
+ variables : { ...values }
28
+ } )
29
+ }
30
+ >
31
+ { ( { submitForm } ) => (
32
+ < RegisterUI
33
+ changePage = { changePage }
34
+ submit = { submitForm }
35
+ />
36
+ ) }
37
+ </ Formik >
38
+ ) }
39
+ </ RegisterMutation >
40
+ )
41
+ }
42
+ }
Original file line number Diff line number Diff line change
1
+ import * as React from 'react'
2
+ import { Mutation } from 'react-apollo'
3
+ import gql from 'graphql-tag'
4
+
5
+ const registerMutation = gql `
6
+ mutation Register($email: String!, $password: String!) {
7
+ register(input: { email: $email, password: $password }) {
8
+ ok
9
+ }
10
+ }
11
+ `
12
+
13
+ interface WithRegister {
14
+ register : any
15
+ }
16
+
17
+ interface Props {
18
+ children : ( data : WithRegister ) => React . ReactNode
19
+ }
20
+
21
+ export class RegisterMutation extends React . PureComponent < Props > {
22
+ public render ( ) {
23
+ return (
24
+ < Mutation mutation = { registerMutation } >
25
+ { mutate => this . props . children ( { register : mutate } ) }
26
+ </ Mutation >
27
+ )
28
+ }
29
+ }
Original file line number Diff line number Diff line change 1
1
import * as React from 'react'
2
2
import { Formik , Form } from 'formik'
3
3
4
+ import { CreateListingMutation } from 'src/Graphql/CreateListing'
4
5
import { Wizard } from 'src/Components/Wizard'
5
6
import { Stepper } from 'src/Components/Stepper'
6
7
import { Button } from 'src/Components/Button'
@@ -9,7 +10,6 @@ import { RoomInfoForm } from '../RoomInfoForm'
9
10
import { LocationForm } from '../LocationForm'
10
11
11
12
import { Container , Wrapper , Buttons } from './style'
12
- import { CreateListingMutation } from '../../../../Graphql/CreateListing'
13
13
14
14
interface FieldValues {
15
15
name : string
You can’t perform that action at this time.
0 commit comments