From 840d6ae424dccace69cbac67db63df03cf8845cf Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 29 Jul 2021 05:25:55 +0530 Subject: [PATCH 1/4] fix: urls for user details --- src/ROUTES.js | 18 ++++++++++++++++++ src/libs/Navigation/linkingConfig.js | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index bbe1883d441..6cea11fdd54 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -96,4 +96,22 @@ export default { isParticipantsRoute: Boolean(lodashGet(pathSegments, 2)), }; }, + + /** + * React Navigation is failing to parse urls with dot in the path segment. + * This method enable pasring of urls with dot in path Segment + * @param {String} path - Path for the config + * @returns {Object} + */ + getEmailRouteLinkingConfig: path => ({ + path, + parse: { + login: l => (l + ? decodeURIComponent(l).replace('@dot@', '.').replace(encodeURIComponent('@dot@'), '@dot@') + : undefined), + }, + stringify: { + login: l => (l ? l.replace('@dot@', encodeURIComponent('@dot@')).replace('.', '@dot@') : undefined), + }, + }), }; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index cf3c57b07ac..7ed0079800e 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -91,13 +91,13 @@ export default { }, Details: { screens: { - Details_Root: ROUTES.DETAILS_WITH_LOGIN, + Details_Root: ROUTES.getEmailRouteLinkingConfig(ROUTES.DETAILS_WITH_LOGIN), }, }, Participants: { screens: { ReportParticipants_Root: ROUTES.REPORT_PARTICIPANTS, - ReportParticipants_Details: ROUTES.REPORT_PARTICIPANT, + ReportParticipants_Details: ROUTES.getEmailRouteLinkingConfig(ROUTES.REPORT_PARTICIPANT), }, }, IOU_Request: { From c49304c84127abc27c9443ccf1a72618981ea221 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 3 Aug 2021 01:56:31 +0530 Subject: [PATCH 2/4] remove unnecessary escaping --- src/ROUTES.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index 6cea11fdd54..0cf90b06c8c 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -106,12 +106,10 @@ export default { getEmailRouteLinkingConfig: path => ({ path, parse: { - login: l => (l - ? decodeURIComponent(l).replace('@dot@', '.').replace(encodeURIComponent('@dot@'), '@dot@') - : undefined), + login: l => (l ? decodeURIComponent(l).replace('@dot@', '.') : undefined), }, stringify: { - login: l => (l ? l.replace('@dot@', encodeURIComponent('@dot@')).replace('.', '@dot@') : undefined), + login: l => (l ? l.replace('.', '@dot@') : undefined), }, }), }; From 9c871a508baae4ac0eb95d399529dec1d882eadb Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Tue, 3 Aug 2021 04:14:37 +0530 Subject: [PATCH 3/4] use query params for login routes --- src/ROUTES.js | 23 +++---------------- src/libs/Navigation/linkingConfig.js | 4 ++-- .../home/report/ReportActionItemSingle.js | 2 +- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index 0cf90b06c8c..3b8add8f920 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -55,12 +55,11 @@ export default { SEARCH: 'search', SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode', DETAILS: 'details', - DETAILS_WITH_LOGIN: 'details/:login', - getDetailsRoute: login => `details/${login}`, + getDetailsRoute: login => `details?login=${login}`, REPORT_PARTICIPANTS: 'r/:reportID/participants', getReportParticipantsRoute: reportID => `r/${reportID}/participants`, - REPORT_PARTICIPANT: 'r/:reportID/participants/:login', - getReportParticipantRoute: (reportID, login) => `r/${reportID}/participants/${login}`, + REPORT_PARTICIPANT: 'r/:reportID/participants/details', + getReportParticipantRoute: (reportID, login) => `r/${reportID}/participants/details?login=${login}`, REPORT_WITH_ID_DETAILS: 'r/:reportID/details', getReportDetailsRoute: reportID => `r/${reportID}/details`, VALIDATE_LOGIN: 'v', @@ -96,20 +95,4 @@ export default { isParticipantsRoute: Boolean(lodashGet(pathSegments, 2)), }; }, - - /** - * React Navigation is failing to parse urls with dot in the path segment. - * This method enable pasring of urls with dot in path Segment - * @param {String} path - Path for the config - * @returns {Object} - */ - getEmailRouteLinkingConfig: path => ({ - path, - parse: { - login: l => (l ? decodeURIComponent(l).replace('@dot@', '.') : undefined), - }, - stringify: { - login: l => (l ? l.replace('.', '@dot@') : undefined), - }, - }), }; diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 7ed0079800e..a6ba11123df 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -91,13 +91,13 @@ export default { }, Details: { screens: { - Details_Root: ROUTES.getEmailRouteLinkingConfig(ROUTES.DETAILS_WITH_LOGIN), + Details_Root: ROUTES.DETAILS, }, }, Participants: { screens: { ReportParticipants_Root: ROUTES.REPORT_PARTICIPANTS, - ReportParticipants_Details: ROUTES.getEmailRouteLinkingConfig(ROUTES.REPORT_PARTICIPANT), + ReportParticipants_Details: ROUTES.REPORT_PARTICIPANT, }, }, IOU_Request: { diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index 84befd28f4c..2df76401ffa 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -39,7 +39,7 @@ const defaultProps = { }; const showUserDetails = (email) => { - Navigation.navigate(`${ROUTES.DETAILS}/${email}`); + Navigation.navigate(ROUTES.getDetailsRoute(email)); }; const ReportActionItemSingle = ({ From 4474fea03493a4fb03b1305809b6b4eb7cda83d4 Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Wed, 4 Aug 2021 12:24:13 +0530 Subject: [PATCH 4/4] esacpe chars in param --- src/ROUTES.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.js b/src/ROUTES.js index 3b8add8f920..71145f71864 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -55,11 +55,14 @@ export default { SEARCH: 'search', SET_PASSWORD_WITH_VALIDATE_CODE: 'setpassword/:accountID/:validateCode', DETAILS: 'details', - getDetailsRoute: login => `details?login=${login}`, + getDetailsRoute: login => `details?login=${encodeURIComponent(login)}`, REPORT_PARTICIPANTS: 'r/:reportID/participants', getReportParticipantsRoute: reportID => `r/${reportID}/participants`, REPORT_PARTICIPANT: 'r/:reportID/participants/details', - getReportParticipantRoute: (reportID, login) => `r/${reportID}/participants/details?login=${login}`, + getReportParticipantRoute: ( + reportID, + login, + ) => `r/${reportID}/participants/details?login=${encodeURIComponent(login)}`, REPORT_WITH_ID_DETAILS: 'r/:reportID/details', getReportDetailsRoute: reportID => `r/${reportID}/details`, VALIDATE_LOGIN: 'v',