@@ -18,10 +18,11 @@ import {
1818 LargeImagePendingPlaceholder ,
1919} from 'pages/InspectionReportPage/InspectionReportImage'
2020import styled from 'styled-components'
21+ import { useInspectionId } from 'pages/InspectionReportPage/SetInspectionIdHook'
2122
2223interface InspectionDialogViewProps {
23- selectedTask : Task
24- onClose : ( ) => void
24+ selectedAnalysisId : string
25+ tasks : Task [ ]
2526}
2627const StyledImage = styled . img < { $otherContentHeight ?: string } > `
2728 max-height: calc(60vh - ${ ( props ) => props . $otherContentHeight } );
@@ -38,60 +39,77 @@ const AnalysisImage = ({ inspectionId }: { inspectionId: string }) => {
3839 return < StyledImage $otherContentHeight = "0px" src = { data } />
3940}
4041
41- export const AnalysisResultDialogView = ( { selectedTask , onClose } : InspectionDialogViewProps ) => {
42+ export const AnalysisResultDialogView = ( { selectedAnalysisId , tasks } : InspectionDialogViewProps ) => {
4243 const { TranslateText } = useLanguageContext ( )
44+ const { switchSelectedAnalysisId } = useInspectionId ( )
45+
46+ const onClose = ( ) => switchSelectedAnalysisId ( undefined )
47+
48+ const currentTask = tasks . find ( ( t ) => t . inspection . id == selectedAnalysisId )
49+
50+ if ( ! currentTask ) {
51+ return (
52+ < StyledDialog open = { true } isDismissable onClose = { onClose } >
53+ < StyledDialogContent >
54+ < StyledDialogInspectionView >
55+ < LargeImageErrorPlaceholder errorMessage = "No analysis could be found" />
56+ </ StyledDialogInspectionView >
57+ </ StyledDialogContent >
58+ </ StyledDialog >
59+ )
60+ }
4361
4462 return (
4563 < StyledDialog open = { true } isDismissable onClose = { onClose } >
4664 < StyledDialogContent >
4765 < StyledDialogHeader >
4866 < Typography variant = "accordion_header" group = "ui" >
49- { TranslateText ( 'Analysis result for task' ) + ' ' + ( selectedTask . taskOrder + 1 ) }
67+ { TranslateText ( 'Analysis result for task' ) + ' ' + ( currentTask . taskOrder + 1 ) }
5068 </ Typography >
5169 < StyledCloseButton variant = "ghost" onClick = { onClose } >
5270 < Icon name = { Icons . Clear } size = { 24 } />
5371 </ StyledCloseButton >
5472 </ StyledDialogHeader >
5573 < StyledDialogInspectionView >
5674 < div >
57- { selectedTask . inspection . analysisResult ?. storageAccount ? (
58- < AnalysisImage inspectionId = { selectedTask . inspection . isarInspectionId } />
75+ { currentTask . inspection . analysisResult ?. storageAccount ? (
76+ < AnalysisImage inspectionId = { currentTask . inspection . isarInspectionId } />
5977 ) : (
6078 < > { /* No image to display*/ } </ >
6179 ) }
6280 < StyledBottomContent >
6381 < StyledInfoContent >
6482 < Typography variant = "caption" > { TranslateText ( 'Tag' ) + ':' } </ Typography >
65- < Typography variant = "body_short" > { selectedTask . tagId } </ Typography >
83+ < Typography variant = "body_short" > { currentTask . tagId } </ Typography >
6684 </ StyledInfoContent >
67- { selectedTask . description && (
85+ { currentTask . description && (
6886 < StyledInfoContent >
6987 < Typography variant = "caption" > { TranslateText ( 'Description' ) + ':' } </ Typography >
70- < Typography variant = "body_short" > { selectedTask . description } </ Typography >
88+ < Typography variant = "body_short" > { currentTask . description } </ Typography >
7189 </ StyledInfoContent >
7290 ) }
73- { selectedTask . endTime && (
91+ { currentTask . endTime && (
7492 < StyledInfoContent >
7593 < Typography variant = "caption" > { TranslateText ( 'Timestamp' ) + ':' } </ Typography >
7694 < Typography variant = "body_short" >
77- { formatDateTime ( selectedTask . endTime , 'dd.MM.yy - HH:mm' ) }
95+ { formatDateTime ( currentTask . endTime , 'dd.MM.yy - HH:mm' ) }
7896 </ Typography >
7997 </ StyledInfoContent >
8098 ) }
81- { selectedTask . inspection . analysisResult ?. warning && (
99+ { currentTask . inspection . analysisResult ?. warning && (
82100 < StyledInfoContent >
83101 < Typography variant = "caption" > { TranslateText ( 'Warning' ) + ':' } </ Typography >
84102 < Typography variant = "body_short" >
85- { selectedTask . inspection . analysisResult . warning }
103+ { currentTask . inspection . analysisResult . warning }
86104 </ Typography >
87105 </ StyledInfoContent >
88106 ) }
89- { selectedTask . inspection . analysisResult ?. confidence &&
90- selectedTask . inspection . analysisResult ?. unit && (
107+ { currentTask . inspection . analysisResult ?. confidence &&
108+ currentTask . inspection . analysisResult ?. unit && (
91109 < StyledInfoContent >
92110 < Typography variant = "caption" > { TranslateText ( 'Confidence' ) + ':' } </ Typography >
93111 < Typography variant = "body_short" >
94- { selectedTask . inspection . analysisResult . confidence + '%' }
112+ { currentTask . inspection . analysisResult . confidence + '%' }
95113 </ Typography >
96114 </ StyledInfoContent >
97115 ) }
0 commit comments