Skip to content

Commit

Permalink
Fix variable types for inspection overview
Browse files Browse the repository at this point in the history
  • Loading branch information
mrica-equinor committed Nov 1, 2023
1 parent 682ec73 commit c503816
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const InspectionRow = ({
</Typography>
</Table.Cell>
<Table.Cell>{mission.comment}</Table.Cell>
<Table.Cell>{mission.area.areaName}</Table.Cell>
<Table.Cell>{mission.area ? mission.area.areaName : '-'}</Table.Cell>
<Table.Cell>{lastCompleted}</Table.Cell>
<Table.Cell>{inspection.deadline ? formatDateString(inspection.deadline.toISOString()) : ''}</Table.Cell>
<Table.Cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ function MissionDefinitionPageBody({ missionDefinition, updateMissionDefinition
const { TranslateText } = useLanguageContext()
let navigate = useNavigate()

const displayInspectionFrequency = (inspectionFrequency: string) => {
if (inspectionFrequency === null) return TranslateText('No inspection frequency set')
const displayInspectionFrequency = (inspectionFrequency: string | undefined) => {
if (inspectionFrequency === undefined) return TranslateText('No inspection frequency set')
const timeArray = inspectionFrequency.split(':')
const days: number = +timeArray[0]
const hours: number = +timeArray[1]
Expand All @@ -101,10 +101,22 @@ function MissionDefinitionPageBody({ missionDefinition, updateMissionDefinition
left={TranslateText('Inspection frequency')}
right={displayInspectionFrequency(missionDefinition.inspectionFrequency)}
/>
<KeyValuePairDisplay left={TranslateText('Area')} right={missionDefinition.area.areaName} />
<KeyValuePairDisplay left={TranslateText('Deck')} right={missionDefinition.area.deckName} />
<KeyValuePairDisplay left={TranslateText('Plant')} right={missionDefinition.area.plantCode} />
<KeyValuePairDisplay left={TranslateText('Installation')} right={missionDefinition.area.installationCode} />
<KeyValuePairDisplay
left={TranslateText('Area')}
right={missionDefinition.area ? missionDefinition.area.areaName : '-'}
/>
<KeyValuePairDisplay
left={TranslateText('Deck')}
right={missionDefinition.area ? missionDefinition.area.deckName : '-'}
/>
<KeyValuePairDisplay
left={TranslateText('Plant')}
right={missionDefinition.area ? missionDefinition.area.plantCode : '-'}
/>
<KeyValuePairDisplay
left={TranslateText('Installation')}
right={missionDefinition.area ? missionDefinition.area.installationCode : '-'}
/>
<KeyValuePairDisplay
left={TranslateText('Mission source')}
right={TranslateText(missionDefinition.sourceType)}
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/models/MissionDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export interface CondensedMissionDefinition {
id: string
name: string
installationCode: string
comment: string
inspectionFrequency: string
comment?: string
inspectionFrequency: string | undefined
lastRun: Mission
area: Area
area?: Area
isDeprecated: boolean
sourceType: string
}
Expand All @@ -24,10 +24,10 @@ export interface MissionDefinition {
tasks: Task[]
name: string
installationCode: string
comment: string
inspectionFrequency: string
comment?: string
inspectionFrequency: string | undefined
lastRun: Mission
area: Area
area?: Area
isDeprecated: boolean
sourceType: string
}
2 changes: 1 addition & 1 deletion frontend/src/utils/StringFormatting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const formatBackendDateTimeToDate = (date: Date) => {
}

export const getInspectionDeadline = (
inspectionFrequency: string | null,
inspectionFrequency: string | undefined,
lastRunTime: Date | null
): Date | undefined => {
if (!inspectionFrequency || !lastRunTime) return undefined
Expand Down

0 comments on commit c503816

Please sign in to comment.