From 09b88ca1d38d179021089bc96ca2aa5db43055af Mon Sep 17 00:00:00 2001 From: Gwynn DP Date: Wed, 17 Nov 2021 17:35:12 -0800 Subject: [PATCH] fix(capture-match): display candidate images and reduce # of vertical scroll containers: --- .../CaptureMatching/CandidateImages.js | 18 ++++++---- .../CaptureMatching/CaptureImage.js | 2 +- .../CaptureMatching/CaptureMatchingView.js | 35 ++++++++++--------- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/components/CaptureMatching/CandidateImages.js b/src/components/CaptureMatching/CandidateImages.js index 8f4f2d4f8..a95d6e1fe 100644 --- a/src/components/CaptureMatching/CandidateImages.js +++ b/src/components/CaptureMatching/CandidateImages.js @@ -9,7 +9,10 @@ import theme from '../common/theme'; const useStyles = makeStyles({ containerBox: { - margin: theme.spacing(5), + marginTop: 0, + marginRight: theme.spacing(5), + marginBottom: theme.spacing(5), + marginLeft: theme.spacing(5), paddingBottom: theme.spacing(2), background: '#fff', borderRadius: '4px', @@ -20,8 +23,7 @@ const useStyles = makeStyles({ }, imgContainer: { - width: '350px', - height: 'auto', + height: '100%', padding: '5px', objectFit: 'cover', paddingBottom: '10px', @@ -32,10 +34,11 @@ const useStyles = makeStyles({ display: 'flex', flexDirection: 'row', overflowX: 'auto', + overflowY: 'hidden', }, imageScroll: { - height: '100vh', + height: '76vh', overflow: 'scroll', }, @@ -63,11 +66,15 @@ function CandidateImages({ candidateImgData, sameTreeHandler }) { setShowBox([...showBox, i]); }; + console.log('candidates', candidateImgData); + console.log('showBox', showBox); + console.log('candidateImgData[0].captures', candidateImgData[0].captures); + return ( {candidateImgData.map((tree, i) => { return ( - + {tree.captures.map((capture) => { - // console.log(tree.captures) return ( ; useEffect(() => { console.log('loading candidate images'); async function fetchCandidateTrees(captureId) { + console.log('fetchCandidateTrees()'); // TODO: handle errors and give user feedback setLoading(true); const data = await fetch(`${CAPTURE_API}/${captureId}/potential_trees`, { @@ -60,8 +57,8 @@ function CaptureMatchingView() { // Authorization: session.token, }, }).then((res) => res.json()); - console.log('candidates', data); - setCandidateImgData(data.trees); + setCandidateImgData(data); + setTreesCount(data.length); setLoading(false); } @@ -72,7 +69,8 @@ function CaptureMatchingView() { currentPage > 0 && currentPage <= captureImages.length ) { - const captureId = captureImages[currentPage - 1].captureId; + const captureId = captureImages[currentPage - 1].id; + console.log('captureId', captureId); if (captureId) { fetchCandidateTrees(captureId); } @@ -89,7 +87,6 @@ function CaptureMatchingView() { // Authorization: session.token, }, }).then((res) => res.json()); - // console.log('setCaptureImages', data); setCaptureImages(data); setLoading(false); } @@ -115,7 +112,7 @@ function CaptureMatchingView() { // Same Tree Capture function const sameTreeHandler = (treeId) => { // TODO: handle errors and give user feedback - const captureId = captureImages[currentPage - 1].captureId; + const captureId = captureImages[currentPage - 1].id; fetch(`${CAPTURE_API}/${captureId}`, { method: 'PATCH', headers: { @@ -145,7 +142,11 @@ function CaptureMatchingView() { }, []); return ( - <> + @@ -162,7 +163,7 @@ function CaptureMatchingView() { /> - + - + ); }