Compare commits

..

1 Commits

Author SHA1 Message Date
GotPPay
b329b4eeb6 handle adding contact information 2018-05-11 19:03:34 +02:00
3 changed files with 24 additions and 63 deletions

View File

@@ -33,8 +33,6 @@ import Instance from '../../../../../../../components/Connection';
import Checkbox from 'material-ui/Checkbox';
import Popover from 'material-ui/Popover';
const ADDRESS_TYPE_HOME = "home";
let DateTimeFormat;
@@ -471,16 +469,6 @@ class VerticalNonLinear extends React.Component {
if (user.useruuid !== loggedUser.useruuid) {
Instance.getRawConn().get(`/v1/nemt/users/member/${user.useruuid}`)
.then(function (res) {
let userHomeAddress = null;
res.data.addresses.forEach(address => {
if (address.address_type === ADDRESS_TYPE_HOME) {
userHomeAddress = address;
}
});
if (userHomeAddress != null) {
userHomeAddress.name = "Home";
state.handlePickupChanged(userHomeAddress, state);
}
state.setState(Object.assign(state.state, { user: res.data, showUserSelection: true, userSelectionText: `${res.data.member} - ${res.data.name}` }));
})
.catch(err => {
@@ -906,17 +894,7 @@ class VerticalNonLinear extends React.Component {
if (this.state.showUserSelection && this.state.users.length > 0) {
const handleAutocomplete = (u) => {
let userHomeAddress = null;
u.addresses.forEach(address => {
if (address.address_type === ADDRESS_TYPE_HOME) {
userHomeAddress = address;
}
});
if (userHomeAddress != null) {
userHomeAddress.name = "Home";
state.handlePickupChanged(userHomeAddress,state);
}
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
state.setState(Object.assign(state.state, { user: u, userSelectionText: u.userdata }));
}
const datasourceConfig = { text: 'userdata', value: 'useruuid' }
userSelection = (

View File

@@ -143,7 +143,7 @@ const Address = (props) => {
)
};
const Main = ({ user, onAddressAdded, onAddressRemoved, readOnly }) => {
const Main = ({ user, onAddressAdded, onAddressRemoved, onContactAdded, readOnly }) => {
return (
<div className="row">
<div className="col-xl-12">
@@ -158,7 +158,7 @@ const Main = ({ user, onAddressAdded, onAddressRemoved, readOnly }) => {
/>
</div>
<div className="col-xl-6">
<ContactInfo user={user} readOnly={readOnly} />
<ContactInfo user={user} readOnly={readOnly} onContactAdded={onContactAdded} />
</div>
</div>
);
@@ -685,6 +685,7 @@ const ContactInfo = (props) => {
title={"Member Contact"}
buttonValue={"Add Contact"}
showDescription={false}
onNewContact={props.onContactAdded}
/>
}
</div>
@@ -823,6 +824,7 @@ class User extends React.Component {
this.getUser = this.getUser.bind(this);
this.handleAddressAdded = this.handleAddressAdded.bind(this);
this.handleAddressRemoved = this.handleAddressRemoved.bind(this);
this.handleContactAdded = this.handleContactAdded.bind(this);
}
componentDidMount() {
@@ -840,6 +842,22 @@ class User extends React.Component {
.catch(console.error);
}
handleContactAdded(contact) {
const user_uuid = this.props.params.user_uuid;
const self = this;
var contactObj = {
"type": contact.type,
"contact": contact.contact,
}
Instance.getRawConn().post(`/v1/nemt/users/portal/${user_uuid}/contact`, contactObj)
.then(res => {
this.getUser(user_uuid);
})
.catch(console.error);
}
handleAddressAdded(address) {
const user_uuid = this.props.params.user_uuid;
const self = this;
@@ -890,6 +908,7 @@ class User extends React.Component {
user={user}
onAddressAdded={this.handleAddressAdded}
onAddressRemoved={this.handleAddressRemoved}
onContactAdded={this.handleContactAdded}
readOnly={readOnly}
/>
</QueueAnim>

View File

@@ -47,9 +47,7 @@ class SignUp extends React.Component {
"role": { name: "", key: "SP", desc: "" },
"profiles": [],
"types": [],
"organizations": [],
showValidationErrors : false,
validationErrors: []
"organizations": []
}
this.buttonValidated = this.buttonValidated.bind(this);
@@ -228,42 +226,12 @@ class SignUp extends React.Component {
localStorage.removeItem('loggedUser');
location.href = '/#/login';
}).catch(function (err) {
if (err.response.status === 422){
//Unprocessable Entity (validation failed)
state.setState(Object.assign(state.state, {
showValidationErrors:true,
validationErrors:err.response.data.data
}));
}else{
alert('Error to log in: ' + err.message);
}
alert('Error to log in: ' + err.message);
console.error(err);
});
}
handleDismiss(){
this.setState(Object.assign(this.state, { showErrorMessage: false }));
}
render() {
let validationErrors = null;
if (this.state.showValidationErrors){
validationErrors = (
<ul>
{this.state.validationErrors.map(errorMessage=>{
const oneValidationMessage = (<li>{errorMessage.message}</li>);
const oneValidationMessageWithTab = (<span><li style={{marginLeft:2 + "em"}}>{errorMessage.message}</li></span>);
if (errorMessage.field_name === "password-tab"){
return oneValidationMessageWithTab;
} else{
return oneValidationMessage;
}
})}
</ul>
);
}
return (
<div className="body-inner">
@@ -366,10 +334,6 @@ class SignUp extends React.Component {
<div className="form-group">
<p className="text-small">By clicking on sign up, you agree to <a href="javascript:;"><i>terms</i></a> and <a href="javascript:;"><i>privacy policy</i></a></p>
</div>
<div className="divider" />
<div className="form-group">
{validationErrors}
</div>
</fieldset>
</form>
</div>