From a3949690d8d9d823ccfd1c423662140f8f284fd1 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Mon, 28 Jun 2021 16:06:42 +0800 Subject: [PATCH 1/6] Pass personal policyID to InboxCallUser --- src/pages/RequestCallPage.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index d8a0d887259f..af395bc15cca 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -40,6 +40,15 @@ const propTypes = { partnerUserID: PropTypes.string, })), }).isRequired, + + /** The policies which the user has access to and which the report could be tied to */ + policies: PropTypes.shape({ + /** ID of the policy */ + policyID: PropTypes.string, + + /** The type of the policy */ + type: PropTypes.string, + }).isRequired, }; class RequestCallPage extends Component { @@ -70,7 +79,8 @@ class RequestCallPage extends Component { return; } - requestConciergeDMCall('', this.state.firstName, this.state.lastName, this.state.phoneNumber) + const personalPolicyID = _.find(this.props.policies, policy => policy.type === 'personal').policyID; + requestConciergeDMCall(personalPolicyID, this.state.firstName, this.state.lastName, this.state.phoneNumber) .then((result) => { this.setState({isLoading: false}); if (result.jsonCode === 200) { @@ -167,5 +177,8 @@ export default compose( user: { key: ONYXKEYS.USER, }, + policies: { + key: ONYXKEYS.COLLECTION.POLICY, + }, }), )(RequestCallPage); From 75c35a3a1313792a02bc9e26f81743d37f963987 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Mon, 28 Jun 2021 16:10:16 +0800 Subject: [PATCH 2/6] Update comment --- src/pages/RequestCallPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index af395bc15cca..79aafef3a103 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -41,7 +41,7 @@ const propTypes = { })), }).isRequired, - /** The policies which the user has access to and which the report could be tied to */ + /** The policies which the user has access to */ policies: PropTypes.shape({ /** ID of the policy */ policyID: PropTypes.string, From 5f1d87d17a67c976a4710ee941c4f28b60d2d785 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Mon, 28 Jun 2021 16:17:32 +0800 Subject: [PATCH 3/6] fix parameter access --- src/pages/RequestCallPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index 79aafef3a103..b49fab688aed 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -79,7 +79,7 @@ class RequestCallPage extends Component { return; } - const personalPolicyID = _.find(this.props.policies, policy => policy.type === 'personal').policyID; + const personalPolicyID = _.find(this.props.policies, policy => policy.type === 'personal').id; requestConciergeDMCall(personalPolicyID, this.state.firstName, this.state.lastName, this.state.phoneNumber) .then((result) => { this.setState({isLoading: false}); From c05ef168a1e41f8a0695a3d4f2a42b5cfe9a69b7 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Wed, 30 Jun 2021 16:40:16 +0800 Subject: [PATCH 4/6] Check if personal policy can be found before submitting form --- src/CONST.js | 1 + src/languages/en.js | 1 + src/languages/es.js | 1 + src/pages/RequestCallPage.js | 14 +++++++++----- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 39ef3103d848..c52f184a510e 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -321,6 +321,7 @@ const CONST = { POLICY: { TYPE: { FREE: 'free', + PERSONAL: 'personal', }, ROLE: { ADMIN: 'admin', diff --git a/src/languages/en.js b/src/languages/en.js index de8ca103e84c..7cdf68f3893f 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -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.', }, }; diff --git a/src/languages/es.js b/src/languages/es.js index f5570341b620..3cc9d3442539 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -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]', }, }; diff --git a/src/pages/RequestCallPage.js b/src/pages/RequestCallPage.js index b49fab688aed..37044a595512 100644 --- a/src/pages/RequestCallPage.js +++ b/src/pages/RequestCallPage.js @@ -74,23 +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')); this.setState({isLoading: false}); return; } - const personalPolicyID = _.find(this.props.policies, policy => policy.type === 'personal').id; - requestConciergeDMCall(personalPolicyID, 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); }); } From 2bde5c1ce2c6563676e47ff061f4dd4861bf1a19 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Thu, 1 Jul 2021 20:15:22 +0800 Subject: [PATCH 5/6] implement Growl.success --- src/libs/Growl.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libs/Growl.js b/src/libs/Growl.js index d16038480692..15d46c3402ec 100644 --- a/src/libs/Growl.js +++ b/src/libs/Growl.js @@ -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, }; From bc0d300011543f705f5b16a459a30b2a76d5c081 Mon Sep 17 00:00:00 2001 From: Jasper Huang Date: Wed, 7 Jul 2021 10:38:53 +0800 Subject: [PATCH 6/6] update translation --- src/languages/es.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.js b/src/languages/es.js index 8cc891584cca..5048f802c3f3 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -451,6 +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: '[awaiting copy before getting translation]', + 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.', }, };