Skip to content

Commit

Permalink
Merge pull request #3773 from Expensify/jasper-requestCallPersonalPolicy
Browse files Browse the repository at this point in the history
[NO QA] Pass personal policyID to InboxCallUser
  • Loading branch information
Jag96 authored Jul 7, 2021
2 parents 38830cf + bc0d300 commit c956587
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/CONST.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,6 @@ export default {
growlMessageOnSave: 'Call requested.',
growlMessageInvalidPhone: 'That doesn’t look like a valid phone number. Try again with the country code.\ne.g. +15005550006',
growlMessageEmptyName: 'Please provide both a first and last name so our Guides know how to address you!',
growlMessageNoPersonalPolicy: 'I wasn’t able to find a personal policy to associate this Guides call with, please check your connection and try again.',
},
};
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,5 +451,6 @@ export default {
growlMessageOnSave: 'Llamada solicitada.',
growlMessageInvalidPhone: 'El teléfono no es valido. Intentalo de nuevo agregando el código de país. P. ej.: +15005550006',
growlMessageEmptyName: 'Por favor ingresa tu nombre completo',
growlMessageNoPersonalPolicy: 'No he podido encontrar una póliza personal con la que asociar esta llamada a las Guías, compruebe su conexión e inténtelo de nuevo.',
},
};
11 changes: 11 additions & 0 deletions src/libs/Growl.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ function error(bodyText, duration = CONST.GROWL.DURATION) {
show(bodyText, CONST.GROWL.ERROR, duration);
}

/**
* Show success growl
*
* @param {String} bodyText
* @param {Number} [duration]
*/
function success(bodyText, duration = CONST.GROWL.DURATION) {
show(bodyText, CONST.GROWL.SUCCESS, duration);
}

export default {
show,
error,
success,
};
25 changes: 21 additions & 4 deletions src/pages/RequestCallPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ const propTypes = {
partnerUserID: PropTypes.string,
})),
}).isRequired,

/** The policies which the user has access to */
policies: PropTypes.shape({
/** ID of the policy */
policyID: PropTypes.string,

/** The type of the policy */
type: PropTypes.string,
}).isRequired,
};

class RequestCallPage extends Component {
Expand All @@ -61,22 +70,27 @@ class RequestCallPage extends Component {
onSubmit() {
this.setState({isLoading: true});
if (!this.state.firstName.length || !this.state.lastName.length) {
Growl.show(this.props.translate('requestCallPage.growlMessageEmptyName'), CONST.GROWL.ERROR);
Growl.success(this.props.translate('requestCallPage.growlMessageEmptyName'));
this.setState({isLoading: false});
return;
}

requestConciergeDMCall('', this.state.firstName, this.state.lastName, this.state.phoneNumber)
const personalPolicy = _.find(this.props.policies, policy => policy.type === CONST.POLICY.TYPE.PERSONAL);
if (!personalPolicy) {
Growl.error(this.props.translate('requestCallPage.growlMessageNoPersonalPolicy'), 3000);
return;
}
requestConciergeDMCall(personalPolicy.id, this.state.firstName, this.state.lastName, this.state.phoneNumber)
.then((result) => {
this.setState({isLoading: false});
if (result.jsonCode === 200) {
Growl.show(this.props.translate('requestCallPage.growlMessageOnSave'), CONST.GROWL.SUCCESS);
Growl.success(this.props.translate('requestCallPage.growlMessageOnSave'));
fetchOrCreateChatReport([this.props.session.email, CONST.EMAIL.CONCIERGE], true);
return;
}

// Phone number validation is handled by the API
Growl.show(result.message, CONST.GROWL.ERROR, 3000);
Growl.error(result.message, 3000);
});
}

Expand Down Expand Up @@ -195,5 +209,8 @@ export default compose(
user: {
key: ONYXKEYS.USER,
},
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
}),
)(RequestCallPage);

0 comments on commit c956587

Please sign in to comment.