Skip to content

Commit

Permalink
Frontend - don't fail when env theme is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih committed Mar 25, 2024
1 parent c98eb2f commit 93752d2
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 92 deletions.
4 changes: 2 additions & 2 deletions frontend/src/pam/mission/actions/action-control-env.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ const ActionControlEnv: React.FC<ActionControlPropsEnv> = ({action}) => {
<Stack.Item style={{width: '100%'}}>
<Label>Thématique de contrôle</Label>
<Text as="h3" weight="medium" color={THEME.color.gunMetal}>
{actionData?.themes[0].theme ?? 'inconnue'}
{actionData?.themes[0]?.theme ?? 'inconnue'}
</Text>
</Stack.Item>
<Stack.Item style={{width: '100%'}}>
<Label>Sous-thématiques de contrôle</Label>
<Text as="h3" weight="medium" color={THEME.color.gunMetal}>
{actionData?.themes[0].subThemes?.length
{actionData?.themes[0]?.subThemes?.length
? actionData?.themes[0].subThemes?.join(', ')
: 'inconnues'}
</Text>
Expand Down
180 changes: 90 additions & 90 deletions frontend/src/pam/mission/timeline/item/timeline-item-control-env.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,98 +10,98 @@ import { TimelineItemWrapper } from "./timeline-item.tsx";


const ActionEnvControl: React.FC<{ action: Action; onClick: any }> = ({action, onClick}) => {
const {actionId} = useParams()
const actionData = action.data as unknown as EnvActionControl
return (
<TimelineItemWrapper onClick={onClick} borderWhenSelected={action.id === actionId}>
<FlexboxGrid.Item
style={{
width: '100%',
padding: '1rem'
}}
>
<Stack direction="row" spacing="0.5rem">
<Stack.Item alignSelf="flex-start">
<Icon.ControlUnit color={THEME.color.charcoal} size={20}/>
</Stack.Item>
<Stack.Item alignSelf="flex-start" style={{width: '100%'}}>
<Stack direction="column" spacing="0.5rem" alignItems="flex-start" style={{width: '100%'}}>
<Stack.Item>
<Stack direction="row" spacing="0.25rem">
<Stack.Item>
<Text as="h3" weight="medium" color={THEME.color.gunMetal}>
Contrôle
</Text>
</Stack.Item>
<Stack.Item>
<Text as="h3" weight="bold" color={THEME.color.gunMetal} data-testid={"theme"}>
{actionData && 'themes' in actionData && actionData?.themes[0].theme ? actionData?.themes[0].theme : ''}
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item>
<Text as="h3" weight="normal" color={THEME.color.slateGray}>
<b>
{actionData && 'actionNumberOfControls' in actionData && actionData.actionNumberOfControls
? `${actionData.actionNumberOfControls} ${
actionData.actionNumberOfControls > 1 ? 'contrôles' : 'contrôle'
}`
: 'Nombre de contrôles inconnu'}
</b>
&nbsp;
{actionData &&
'actionNumberOfControls' in actionData &&
actionData.actionNumberOfControls &&
actionData.actionNumberOfControls > 1
? 'réalisés'
: 'réalisé'}{' '}
sur des cibles de type&nbsp;
<b>
{actionData && 'actionTargetType' in actionData && actionData.actionTargetType
? actionTargetTypeLabels[actionData.actionTargetType]?.libelle?.toLowerCase()
: 'inconnu'}
</b>
</Text>
</Stack.Item>
const {actionId} = useParams()
const actionData = action.data as unknown as EnvActionControl
return (
<TimelineItemWrapper onClick={onClick} borderWhenSelected={action.id === actionId}>
<FlexboxGrid.Item
style={{
width: '100%',
padding: '1rem'
}}
>
<Stack direction="row" spacing="0.5rem">
<Stack.Item alignSelf="flex-start">
<Icon.ControlUnit color={THEME.color.charcoal} size={20}/>
</Stack.Item>
<Stack.Item alignSelf="flex-start" style={{width: '100%'}}>
<Stack direction="column" spacing="0.5rem" alignItems="flex-start" style={{width: '100%'}}>
<Stack.Item>
<Stack direction="row" spacing="0.25rem">
<Stack.Item>
<Text as="h3" weight="medium" color={THEME.color.gunMetal}>
Contrôle
</Text>
</Stack.Item>
<Stack.Item>
<Text as="h3" weight="bold" color={THEME.color.gunMetal} data-testid={"theme"}>
{actionData && 'themes' in actionData && actionData?.themes[0]?.theme ? actionData?.themes[0]?.theme : ''}
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item>
<Text as="h3" weight="normal" color={THEME.color.slateGray}>
<b>
{actionData && 'actionNumberOfControls' in actionData && actionData.actionNumberOfControls
? `${actionData.actionNumberOfControls} ${
actionData.actionNumberOfControls > 1 ? 'contrôles' : 'contrôle'
}`
: 'Nombre de contrôles inconnu'}
</b>
&nbsp;
{actionData &&
'actionNumberOfControls' in actionData &&
actionData.actionNumberOfControls &&
actionData.actionNumberOfControls > 1
? 'réalisés'
: 'réalisé'}{' '}
sur des cibles de type&nbsp;
<b>
{actionData && 'actionTargetType' in actionData && actionData.actionTargetType
? actionTargetTypeLabels[actionData.actionTargetType]?.libelle?.toLowerCase()
: 'inconnu'}
</b>
</Text>
</Stack.Item>

<Stack.Item alignSelf="flex-start" style={{width: '100%'}}>
<Stack direction="row" spacing="1rem" style={{width: '100%'}}>
<Stack.Item style={{width: '70%'}}>
{actionData?.controlsToComplete !== undefined &&
actionData?.controlsToComplete?.length > 0 ? (
<ControlsToCompleteTag
amountOfControlsToComplete={actionData?.controlsToComplete?.length}
/>
) : (
<>
{
action.summaryTags?.map((tag: string) => (
<Tag key={tag}
accent={Accent.PRIMARY}
style={{marginRight: '0.5rem'}}>{tag}</Tag>
))
}
</>
)}
</Stack.Item>
<Stack.Item alignSelf="flex-end" style={{width: '30%'}}>
<Stack direction="column" alignItems="flex-end">
<Stack.Item alignSelf="flex-end">
<Text as="h4" color={THEME.color.slateGray} fontStyle={"italic"}>
ajouté par CACEM
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item alignSelf="flex-start" style={{width: '100%'}}>
<Stack direction="row" spacing="1rem" style={{width: '100%'}}>
<Stack.Item style={{width: '70%'}}>
{actionData?.controlsToComplete !== undefined &&
actionData?.controlsToComplete?.length > 0 ? (
<ControlsToCompleteTag
amountOfControlsToComplete={actionData?.controlsToComplete?.length}
/>
) : (
<>
{
action.summaryTags?.map((tag: string) => (
<Tag key={tag}
accent={Accent.PRIMARY}
style={{marginRight: '0.5rem'}}>{tag}</Tag>
))
}
</>
)}
</Stack.Item>
<Stack.Item alignSelf="flex-end" style={{width: '30%'}}>
<Stack direction="column" alignItems="flex-end">
<Stack.Item alignSelf="flex-end">
<Text as="h4" color={THEME.color.slateGray} fontStyle={"italic"}>
ajouté par CACEM
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
</FlexboxGrid.Item>
</TimelineItemWrapper>
)
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
</FlexboxGrid.Item>
</TimelineItemWrapper>
)
}

export default ActionEnvControl

0 comments on commit 93752d2

Please sign in to comment.