From 199a0f53b191539069d39db3323088d342fc66af Mon Sep 17 00:00:00 2001 From: Gwynn Dandridge-Perry Date: Mon, 5 Sep 2022 13:14:05 -0700 Subject: [PATCH] fix: incorrect display of status in capture detail dialog (#821) --- src/components/CaptureDetailDialog.js | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/CaptureDetailDialog.js b/src/components/CaptureDetailDialog.js index f913b6fd0..2d5c752d1 100644 --- a/src/components/CaptureDetailDialog.js +++ b/src/components/CaptureDetailDialog.js @@ -109,12 +109,11 @@ function CaptureDetailDialog(props) { // map the keys from legacy to new api keys setRenderCapture({ status: - current.status || (current.active && current.approved ? 'approved' : current.active && !current.approved ? 'pending' - : 'rejected'), + : 'rejected') || current.status, id: current.id || current.uuid, reference_id: current.reference_id || current.id, grower_account_id: current.grower_account_id || current.planterId, @@ -135,14 +134,14 @@ function CaptureDetailDialog(props) { updated_at: current.updated_at || current.timeUpdated, }); } - if(isLoading) { + if (isLoading) { setIsLoading(false); } }, [cdContext.capture]); useEffect(() => { setIsLoading(true); - },[open]) + }, [open]); function handleClose() { setSnackbarOpen(false); @@ -229,7 +228,7 @@ function CaptureDetailDialog(props) { ].map((item) => ( {item.label} - + {item.link ? ( // a link is either a GrowerID (item.image == false) or OriginalImage (item.image == true) item.image ? ( @@ -243,8 +242,12 @@ function CaptureDetailDialog(props) { ) : ( ) + ) : item.value ? ( + item.value + ) : isLoading ? ( + ) : ( - item.value ? (item.value) : isLoading ? : '---' + '---' )} {item.value && item.copy && ( Country - {isLoading ? : capture?.lat && capture?.lon && countryInfo} + {isLoading ? ( + + ) : ( + capture?.lat && capture?.lon && countryInfo + )} @@ -268,14 +275,13 @@ function CaptureDetailDialog(props) { Verification Status - {capture.status === 'pending' ? ( + {/* the 'planted' status is legacy, we'll interpret as 'pending' */} + {capture.status === 'planted' || capture.status === 'pending' ? ( - ) : capture.status === 'approved' || - capture.status === 'planted' || - capture.status === 'active' ? ( + ) : capture.status === 'approved' || capture.status === 'active' ? (