update api

This commit is contained in:
henrydays 2019-03-04 23:57:08 +00:00
parent c634a00490
commit 31e221cb6e
5 changed files with 72 additions and 51 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

View File

@ -184,36 +184,6 @@ _update=()=>{
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Icon name="ios-laptop" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Job}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-mail" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Email}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-phone-portrait" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Mobile}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-map" style={styles.userBioLogo} size={25}/>
<Text style={styles.userBioText}>{this.props.user.Address}, {this.props.user.City}</Text>
</View>
<Divider style={{ backgroundColor: 'black' }} />
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TouchableOpacity><Text style={styles.userCurriculum}>O meu Curriculo</Text></TouchableOpacity>
</View>
</View>

View File

@ -45,6 +45,8 @@ class Profile extends Component {
super(props);
this.state = {
name:this.props.user.Name,
userDetails:{},
token: false,
tokenData: '',
loggedIn: false,
@ -56,7 +58,7 @@ class Profile extends Component {
formValid: true,
jobs: this.props.user.Job,
jobs: this.props.user.Company,
jobsError: false,
jobsErrorMessage: '',
@ -68,7 +70,7 @@ class Profile extends Component {
phoneError: false,
phoneErrorMessage: '',
address: this.props.user.Adress,
address: this.props.user.Address,
addressError: false,
addressErrorMessage: '',
@ -85,9 +87,12 @@ class Profile extends Component {
};
_validateData = (jobs, email, phone, address, city) => {
_validateData = (name,jobs, email, phone, address, city) => {
let valid = null;
v = Validate('name',name );
let v = Validate('email', email);
this.setState({emailError: v[0], emailErrorMessage: v[1]});
@ -133,14 +138,31 @@ class Profile extends Component {
saveData() {
const {jobs, email, phone, address, city, formValid} = this.state;
const {name,jobs, email, phone, address, city, formValid} = this.state;
this._validateData(jobs, email, phone, address, city);
this._validateData(name,jobs, email, phone, address, city);
console.log(formValid);
if (formValid)
if (formValid){
console.log("data valid");
this.props.updateUser(this.props.userDetails.token,{
Name: this.state.name,
// LastName: "Último",
Company: jobs,
// Job: jobs,
Address: address,
City: city,
// PostalCode: "3000-010",
Mobile: phone,
Avatar: "base64"
} ); this.props.getUserInfo(this.props.userDetails.token);
}
else
console.log("data not valid");
@ -158,11 +180,21 @@ class Profile extends Component {
</View>
<View>
<TouchableOpacity onPress={() => this.saveData()}>
<Icon name="ios-save" size={30}/>
<Icon name="ios-save" size={30}/><Text>Save</Text>
</TouchableOpacity>
</View>
</View>
<View style={styles.userBio}>
<View style={styles.userBioRow}>
<Icon name="ios-person" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(n) => {
this.setState({name:n })
}}
value={this.state.name}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-laptop" style={styles.userBioLogo} size={25}/>
@ -174,17 +206,7 @@ class Profile extends Component {
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-mail" style={styles.userBioLogo} size={25}/>
<TextInput style={styles.userBioText}
onChangeText={(email) => {
this.setState({email: email})
}}
value={this.state.email}/>
</View>
<Divider style={{backgroundColor: 'black'}}/>
<View style={styles.userBioRow}>
<Icon name="ios-phone-portrait" style={styles.userBioLogo} size={25}/>
@ -339,7 +361,8 @@ mapStateToProps = (state, props) => {
return {
token: state.apiReducer.token,
user: state.apiReducer.user
user: state.apiReducer.user,
userDetails: state.apiReducer.userDetails,
}
};

View File

@ -11,6 +11,33 @@ import { compose } from 'redux';
const axios = require('axios');
axios.defaults.baseURL = 'http://enei2019.uingress.com/internal/api'
//http://enei2019.uingress.com/internal/api/Attendee/Edit
export function updateUser(token, user){
axios.defaults.headers.common = {'Authorization': `bearer ${token.access_token}`}
console.log("asdasdasdasd")
return (dispatch)=>{
axios.post('/Attendee/Edit', user).then(a=>{
console.log(a);
alert("guardado com sucesso")
dispatch({
type: UPDATE_USER
// guests: response.data
});
}).catch(b=>{
alert("Erro a guardar os dados")
});
}
}
export const waitChangeGuest= ()=>{
return (dispatch)=>{
@ -33,7 +60,7 @@ export const connectionState = (status) => {
///Attendee/AvailableGuestlists
axios.defaults.baseURL = 'http://enei2019.uingress.com/internal/api'
export function getAvailableGuestlists(token){

View File

@ -5,7 +5,8 @@ export {checkUser,
getAvailableGuestlists,
changeGuestList,
waitChangeGuest,
getAvailableSessions
getAvailableSessions,
updateUser,
} from "./api"
export {