-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add placeholders to inspection report
- Loading branch information
Showing
9 changed files
with
176 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
frontend/src/components/Pages/InspectionReportPage/InspectionReportImage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { useInspectionsContext } from 'components/Contexts/InpectionsContext' | ||
import { Task } from 'models/Task' | ||
import { StyledInspection, StyledInspectionImage } from './InspectionStyles' | ||
import { tokens } from '@equinor/eds-tokens' | ||
import { CircularProgress, Typography } from '@equinor/eds-core-react' | ||
import styled from 'styled-components' | ||
import { ValidInspectionReportInspectionTypes } from 'models/Inspection' | ||
import { useLanguageContext } from 'components/Contexts/LanguageContext' | ||
|
||
const StyledSmallImagePlaceholder = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
align-items: flex-start; | ||
padding: 16px 8px; | ||
height: 100%; | ||
` | ||
const StyledLargeImagePlaceholder = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding: 16px; | ||
gap: 16px; | ||
` | ||
const StyledCircularProgress = styled.div` | ||
display: flex; | ||
align-items: center; | ||
align-self: center; | ||
padding: 16px; | ||
height: 100%; | ||
` | ||
|
||
const LargeImageErrorPlaceholder = ({ errorMessage }: { errorMessage: string }) => { | ||
const { TranslateText } = useLanguageContext() | ||
|
||
return ( | ||
<StyledLargeImagePlaceholder> | ||
<Typography variant="h3" color={tokens.colors.text.static_icons__tertiary.hex}> | ||
{TranslateText(errorMessage)} | ||
</Typography> | ||
</StyledLargeImagePlaceholder> | ||
) | ||
} | ||
|
||
const SmallImageErrorPlaceholder = ({ errorMessage }: { errorMessage: string }) => { | ||
const { TranslateText } = useLanguageContext() | ||
|
||
return ( | ||
<StyledSmallImagePlaceholder> | ||
<Typography color={tokens.colors.text.static_icons__tertiary.hex}>{TranslateText(errorMessage)}</Typography> | ||
</StyledSmallImagePlaceholder> | ||
) | ||
} | ||
|
||
const LargeImagePendingPlaceholder = () => { | ||
const { TranslateText } = useLanguageContext() | ||
|
||
return ( | ||
<StyledLargeImagePlaceholder> | ||
<Typography variant="h3" color={tokens.colors.text.static_icons__tertiary.hex}> | ||
{TranslateText('Waiting for inspection result')} | ||
</Typography> | ||
<CircularProgress size={48} /> | ||
</StyledLargeImagePlaceholder> | ||
) | ||
} | ||
|
||
const SmallImagePendingPlaceholder = () => { | ||
return ( | ||
<StyledCircularProgress> | ||
<CircularProgress /> | ||
</StyledCircularProgress> | ||
) | ||
} | ||
|
||
const InspectionImageWithPlaceholder = ({ task, isLargeImage }: { task: Task; isLargeImage: boolean }) => { | ||
const { fetchImageData } = useInspectionsContext() | ||
const { data, isPending, isError } = fetchImageData(task.inspection.isarInspectionId) | ||
|
||
if (!ValidInspectionReportInspectionTypes.includes(task.inspection.inspectionType)) { | ||
const errorMsg = 'Inspection type not supported' | ||
return isLargeImage ? ( | ||
<LargeImageErrorPlaceholder errorMessage={errorMsg} /> | ||
) : ( | ||
<SmallImageErrorPlaceholder errorMessage={errorMsg} /> | ||
) | ||
} else if (isError) { | ||
const errorMsg = 'No inspection could be found' | ||
return isLargeImage ? ( | ||
<LargeImageErrorPlaceholder errorMessage={errorMsg} /> | ||
) : ( | ||
<SmallImageErrorPlaceholder errorMessage={errorMsg} /> | ||
) | ||
} else if (isPending) { | ||
return isLargeImage ? <LargeImagePendingPlaceholder /> : <SmallImagePendingPlaceholder /> | ||
} else | ||
return isLargeImage ? ( | ||
<StyledInspection $otherContentHeight={'174px'} src={data} /> | ||
) : ( | ||
<StyledInspectionImage src={data} /> | ||
) | ||
} | ||
|
||
export const LargeDialogInspectionImage = ({ task }: { task: Task }) => { | ||
return <InspectionImageWithPlaceholder task={task} isLargeImage={true} /> | ||
} | ||
|
||
export const SmallInspectionImage = ({ task }: { task: Task }) => { | ||
return <InspectionImageWithPlaceholder task={task} isLargeImage={false} /> | ||
} |
9 changes: 0 additions & 9 deletions
9
frontend/src/components/Pages/InspectionReportPage/InspectionReportUtilities.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters