Sign up request
This commit is contained in:
parent
9ef748a703
commit
90bfb2e978
@ -7,16 +7,32 @@ export default class SignIn extends React.Component<any, any> {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.state = {
|
||||
clips: []
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
this.updateUsername = this.updateUsername.bind(this);
|
||||
this.updatePassword = this.updatePassword.bind(this);
|
||||
this.signInFunction = this.signInFunction.bind(this);
|
||||
}
|
||||
|
||||
async signInFunction() {
|
||||
}
|
||||
|
||||
updateUsername(event: any) {
|
||||
this.setState({username: event.target.value});
|
||||
}
|
||||
|
||||
updatePassword(event: any) {
|
||||
this.setState({password: event.target.value});
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<Text>Sign In</Text>
|
||||
<TextInput placeholder="Input" />
|
||||
<Button title="Sign In" onPress={() => this.props.navigation.navigate('ClipList')} />
|
||||
<TextInput placeholder="Pseudo" value={this.state.username} onChange={this.updateUsername}/>
|
||||
<TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword}/>
|
||||
<Button title="Sign In" onPress={this.signInFunction} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
import axios from 'axios';
|
||||
import React from 'react';
|
||||
import { View, Text, Button, TextInput } from 'react-native';
|
||||
|
||||
@ -9,40 +8,43 @@ export default class SignUp extends React.Component<any, any> {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.state = {
|
||||
clips: [],
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
this.updateUsername = this.updateUsername.bind(this);
|
||||
this.updatePassword = this.updatePassword.bind(this);
|
||||
this.signIn = this.signIn.bind(this);
|
||||
this.signUpFunction = this.signUpFunction.bind(this);
|
||||
}
|
||||
|
||||
async signIn() {
|
||||
const { data, status } = await axios.put("http://notifysync.simailadjalim.fr/user",
|
||||
{ email: this.state.username, password: this.state.password });
|
||||
if (status === 200) {
|
||||
const { data, status } = await axios.post("http://notifysync.simailadjalim.fr/user",
|
||||
{ email: this.state.username, password: this.state.password });
|
||||
this.props.navigation.navigate('ClipList');
|
||||
}
|
||||
async signUpFunction() {
|
||||
fetch('https://notifysync.simailadjalim.fr/user', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: this.state.username,
|
||||
password: this.state.password
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
updateUsername(event: any){
|
||||
this.setState({username: event.target.value});
|
||||
updateUsername(event: any) {
|
||||
this.setState({ username: event.target.value });
|
||||
}
|
||||
|
||||
updatePassword(event: any){
|
||||
this.setState({password: event.target.value});
|
||||
updatePassword(event: any) {
|
||||
this.setState({ password: event.target.value });
|
||||
}
|
||||
|
||||
render(): React.ReactNode {
|
||||
return (
|
||||
<View>
|
||||
<Text>Sign Up</Text>
|
||||
<TextInput placeholder="Pseudo" value={this.state.username} onChange={this.updateUsername}/>
|
||||
<TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword}/>
|
||||
<Button title="Sign Up" onPress={this.signIn} />
|
||||
<TextInput placeholder="Pseudo" value={this.state.username} onChange={this.updateUsername} />
|
||||
<TextInput placeholder="Mot de Passe" value={this.state.password} onChange={this.updatePassword} />
|
||||
<Button title="Sign Up" onPress={this.signUpFunction} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user