Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
144 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...app/src/components/EventCreateMutation.js → ...c/components/Event/EventCreateMutation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...src/components/EventCreateSubscription.js → ...mponents/Event/EventCreateSubscription.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
import {TextInput, Button, ButtonText} from 'react-native'; | ||
import {Formik} from 'formik'; | ||
import UserCreateMutation from './UserCreateMutation'; | ||
|
||
const UserCreate = () => { | ||
const handleSubmit = values => { | ||
const {title, date, description} = values; | ||
|
||
const input = { | ||
title, | ||
date, | ||
description, | ||
}; | ||
|
||
const onCompleted = id => { | ||
// Some implementation that requires the id from | ||
// the new User created | ||
alert(JSON.stringify(id)); | ||
|
||
// Redirect | ||
// this.props.navigation.navigate('UserList'); | ||
}; | ||
|
||
const onError = err => { | ||
console.error(err); | ||
}; | ||
|
||
UserCreateMutation.commit(input, onCompleted, onError); | ||
}; | ||
return ( | ||
<Formik | ||
initialValues={{title: '', date: '', description: ''}} | ||
onSubmit={values => handleSubmit(values)}> | ||
{({values, handleChange, handleSubmit}) => ( | ||
<> | ||
<TextInput | ||
placeholder="Name" | ||
onChangeText={handleChange('name')} | ||
value={values.title} | ||
/> | ||
<TextInput | ||
placeholder="email" | ||
onChangeText={handleChange('email')} | ||
value={values.date} | ||
/> | ||
<TextInput | ||
placeholder="password" | ||
onChangeText={handleChange('password')} | ||
value={values.description} | ||
/> | ||
<Button onPress={handleSubmit} title="Create User"></Button> | ||
</> | ||
)} | ||
</Formik> | ||
); | ||
}; | ||
|
||
export default UserCreate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {commitMutation, graphql} from 'react-relay'; | ||
import Environment from '../../../relay/Environment'; | ||
|
||
const mutation = graphql` | ||
mutation UserCreateMutation($input: UserRegisterWithEmailInput!) { | ||
UserCreate(input: $input) { | ||
token | ||
error | ||
} | ||
} | ||
`; | ||
|
||
function commit(input, onCompleted, onError) { | ||
return commitMutation(Environment, { | ||
mutation, | ||
variables: { | ||
input, | ||
}, | ||
onCompleted, | ||
onError, | ||
}); | ||
} | ||
|
||
export default {commit}; |