From f31b0aa68a8395586461cfebe46c98cf72a5bfc7 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 4 Dec 2023 16:46:20 +0700 Subject: [PATCH 1/6] Display Ereceipt for distance request in offline mode --- src/pages/home/report/ReportAttachments.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index c580da7887a2..16524ec68c88 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -23,7 +23,8 @@ const propTypes = { function ReportAttachments(props) { const reportID = _.get(props, ['route', 'params', 'reportID']); const report = ReportUtils.getReport(reportID); - const source = decodeURI(_.get(props, ['route', 'params', 'source'])); + const decodedSource = decodeURI(_.get(props, ['route', 'params', 'source'])); + const source = Number(decodedSource) || decodedSource; const onCarouselAttachmentChange = useCallback( (attachment) => { From cd66bb1a4f6eb67bebdbdeac30965449c4d766a3 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 4 Dec 2023 19:38:41 +0700 Subject: [PATCH 2/6] add comment --- src/pages/home/report/ReportAttachments.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index 16524ec68c88..94e54482b4bc 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -23,6 +23,9 @@ const propTypes = { function ReportAttachments(props) { const reportID = _.get(props, ['route', 'params', 'reportID']); const report = ReportUtils.getReport(reportID); + + // Native file has source is number, but decodeURI return a string. + // So we need to cast the source as a number here to make the compare function work well in the carousel const decodedSource = decodeURI(_.get(props, ['route', 'params', 'source'])); const source = Number(decodedSource) || decodedSource; From 60e0f3e6cda4636641d5dfd5e05410d36be4685b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 4 Dec 2023 19:39:36 +0700 Subject: [PATCH 3/6] edit comment --- src/pages/home/report/ReportAttachments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index 94e54482b4bc..b478e00c266b 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -25,7 +25,7 @@ function ReportAttachments(props) { const report = ReportUtils.getReport(reportID); // Native file has source is number, but decodeURI return a string. - // So we need to cast the source as a number here to make the compare function work well in the carousel + // So we need to cast the source as a number here to make the compare function in the carousel work well for all cases const decodedSource = decodeURI(_.get(props, ['route', 'params', 'source'])); const source = Number(decodedSource) || decodedSource; From 4954b2f809d2ad3f9b33b895069b281e44af19b0 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 4 Dec 2023 20:27:37 +0700 Subject: [PATCH 4/6] add proptype --- .../AttachmentCarousel/attachmentCarouselPropTypes.js | 2 +- src/pages/home/report/ReportAttachments.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Attachments/AttachmentCarousel/attachmentCarouselPropTypes.js b/src/components/Attachments/AttachmentCarousel/attachmentCarouselPropTypes.js index 7543e8d9c099..72a554de68be 100644 --- a/src/components/Attachments/AttachmentCarousel/attachmentCarouselPropTypes.js +++ b/src/components/Attachments/AttachmentCarousel/attachmentCarouselPropTypes.js @@ -5,7 +5,7 @@ import reportPropTypes from '@pages/reportPropTypes'; const propTypes = { /** source is used to determine the starting index in the array of attachments */ - source: PropTypes.string, + source: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), /** Callback to update the parent modal's state with a source and name from the attachments array */ onNavigate: PropTypes.func, diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index b478e00c266b..dcc08648027e 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -24,7 +24,7 @@ function ReportAttachments(props) { const reportID = _.get(props, ['route', 'params', 'reportID']); const report = ReportUtils.getReport(reportID); - // Native file has source is number, but decodeURI return a string. + // Native file has source is number, but decodeURI return a string. // So we need to cast the source as a number here to make the compare function in the carousel work well for all cases const decodedSource = decodeURI(_.get(props, ['route', 'params', 'source'])); const source = Number(decodedSource) || decodedSource; From 90319aed20d9569fe67244cc0fe412df98eab57d Mon Sep 17 00:00:00 2001 From: dukenv0307 <129500732+dukenv0307@users.noreply.github.com> Date: Mon, 4 Dec 2023 23:56:56 +0700 Subject: [PATCH 5/6] Update src/pages/home/report/ReportAttachments.js Co-authored-by: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> --- src/pages/home/report/ReportAttachments.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportAttachments.js b/src/pages/home/report/ReportAttachments.js index dcc08648027e..8ecbb036a756 100644 --- a/src/pages/home/report/ReportAttachments.js +++ b/src/pages/home/report/ReportAttachments.js @@ -24,8 +24,7 @@ function ReportAttachments(props) { const reportID = _.get(props, ['route', 'params', 'reportID']); const report = ReportUtils.getReport(reportID); - // Native file has source is number, but decodeURI return a string. - // So we need to cast the source as a number here to make the compare function in the carousel work well for all cases + // In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource const decodedSource = decodeURI(_.get(props, ['route', 'params', 'source'])); const source = Number(decodedSource) || decodedSource; From 6267893301dcfde83a9c393e2d79eb8c3c134e21 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Tue, 5 Dec 2023 00:00:05 +0700 Subject: [PATCH 6/6] fix warning --- src/components/AttachmentModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index 356e75b1e1bb..83a1126756c7 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -46,7 +46,7 @@ import withWindowDimensions, {windowDimensionsPropTypes} from './withWindowDimen const propTypes = { /** Optional source (URL, SVG function) for the image shown. If not passed in via props must be specified when modal is opened. */ - source: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), + source: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.number]), /** Optional callback to fire when we want to preview an image and approve it for use. */ onConfirm: PropTypes.func,