Last active
January 29, 2019 04:22
-
-
Save bonham000/2d4a306b01aa5af00efb3c05c33c8c6e to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
import { compose } from "react-apollo"; | |
import { Button, TextInput } from "react-native"; | |
import { Screen } from "src/ui"; | |
import { UserQueryResponse } from "src/graphql/responses"; | |
import { Success, UpdateUserInfoMutationArgs } from "src/graphql/types"; | |
import { withUpdateUserInfoMutation, withUser } from "src/graphql/helpers"; | |
interface ComponentProps { | |
user: UserQueryResponse; | |
updateUserInfo: IMutation<UpdateUserInfoMutationArgs, Promise<Success>>; | |
} | |
interface ComponentState { | |
email: string; | |
} | |
export class EmailScreenComponent extends React.Component< | |
ComponentProps, | |
ComponentState | |
> { | |
constructor(props: ComponentProps) { | |
super(props); | |
this.state = { | |
email: this.props.user.user.email, | |
}; | |
} | |
render(): JSX.Element { | |
return ( | |
<Screen> | |
<TextInput | |
value={this.state.email} | |
onChangeText={email => this.setState({ email })} | |
/> | |
<Button | |
title="Save Email" | |
onPress={() => | |
this.props.updateUserInfo({ | |
variables: { email: this.state.email }, | |
}) | |
} | |
/> | |
</Screen> | |
); | |
} | |
} | |
export default compose( | |
withUser, | |
withUpdateUserInfoMutation, | |
)(EmailScreenComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment