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

View File

@@ -143,7 +143,7 @@ const Address = (props) => {
) )
}; };
const Main = ({ user, onAddressAdded, onAddressRemoved, readOnly }) => { const Main = ({ user, onAddressAdded, onAddressRemoved, onContactAdded, readOnly }) => {
return ( return (
<div className="row"> <div className="row">
<div className="col-xl-12"> <div className="col-xl-12">
@@ -158,7 +158,7 @@ const Main = ({ user, onAddressAdded, onAddressRemoved, readOnly }) => {
/> />
</div> </div>
<div className="col-xl-6"> <div className="col-xl-6">
<ContactInfo user={user} readOnly={readOnly} /> <ContactInfo user={user} readOnly={readOnly} onContactAdded={onContactAdded} />
</div> </div>
</div> </div>
); );
@@ -685,6 +685,7 @@ const ContactInfo = (props) => {
title={"Member Contact"} title={"Member Contact"}
buttonValue={"Add Contact"} buttonValue={"Add Contact"}
showDescription={false} showDescription={false}
onNewContact={props.onContactAdded}
/> />
} }
</div> </div>
@@ -823,6 +824,7 @@ class User extends React.Component {
this.getUser = this.getUser.bind(this); this.getUser = this.getUser.bind(this);
this.handleAddressAdded = this.handleAddressAdded.bind(this); this.handleAddressAdded = this.handleAddressAdded.bind(this);
this.handleAddressRemoved = this.handleAddressRemoved.bind(this); this.handleAddressRemoved = this.handleAddressRemoved.bind(this);
this.handleContactAdded = this.handleContactAdded.bind(this);
} }
componentDidMount() { componentDidMount() {
@@ -840,6 +842,22 @@ class User extends React.Component {
.catch(console.error); .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) { handleAddressAdded(address) {
const user_uuid = this.props.params.user_uuid; const user_uuid = this.props.params.user_uuid;
const self = this; const self = this;
@@ -890,6 +908,7 @@ class User extends React.Component {
user={user} user={user}
onAddressAdded={this.handleAddressAdded} onAddressAdded={this.handleAddressAdded}
onAddressRemoved={this.handleAddressRemoved} onAddressRemoved={this.handleAddressRemoved}
onContactAdded={this.handleContactAdded}
readOnly={readOnly} readOnly={readOnly}
/> />
</QueueAnim> </QueueAnim>

View File

@@ -47,9 +47,7 @@ class SignUp extends React.Component {
"role": { name: "", key: "SP", desc: "" }, "role": { name: "", key: "SP", desc: "" },
"profiles": [], "profiles": [],
"types": [], "types": [],
"organizations": [], "organizations": []
showValidationErrors : false,
validationErrors: []
} }
this.buttonValidated = this.buttonValidated.bind(this); this.buttonValidated = this.buttonValidated.bind(this);
@@ -228,42 +226,12 @@ class SignUp extends React.Component {
localStorage.removeItem('loggedUser'); localStorage.removeItem('loggedUser');
location.href = '/#/login'; location.href = '/#/login';
}).catch(function (err) { }).catch(function (err) {
if (err.response.status === 422){ alert('Error to log in: ' + err.message);
//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);
}
console.error(err); console.error(err);
}); });
} }
handleDismiss(){
this.setState(Object.assign(this.state, { showErrorMessage: false }));
}
render() { 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 ( return (
<div className="body-inner"> <div className="body-inner">
@@ -366,10 +334,6 @@ class SignUp extends React.Component {
<div className="form-group"> <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> <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>
<div className="divider" />
<div className="form-group">
{validationErrors}
</div>
</fieldset> </fieldset>
</form> </form>
</div> </div>