Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NO QA] Pass personal policyID to InboxCallUser #3773

Merged
merged 8 commits into from
Jul 7, 2021
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 @@ -455,5 +455,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 @@ -419,5 +419,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: '[awaiting copy before getting translation]',
},
};
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 @@ -65,22 +74,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'));
jasperhuangg marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -167,5 +181,8 @@ export default compose(
user: {
key: ONYXKEYS.USER,
},
policies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
}),
)(RequestCallPage);