-
+
+
+
+
setExpandedSmallAccordion(!isExpandedSmallAccordion)}
+ title={`${selectedLayerIds?.length ?? 0} ${pluralize('zone', selectedLayerIds?.length ?? 0)} ${pluralize(
+ 'sélectionée',
+ selectedLayerIds?.length ?? 0
+ )}`}
+ >
+ {Object.entries(selectedRegulatoryAreasByLayerName).map(([layerGroupName, layerIdsInGroup]) => (
+
+ ))}
+
)
}
diff --git a/frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx b/frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx
new file mode 100644
index 0000000000..b2715b3046
--- /dev/null
+++ b/frontend/src/features/Dashboard/components/DashboardForm/SmallAccordion.tsx
@@ -0,0 +1,76 @@
+import { Accent, Icon, IconButton } from '@mtes-mct/monitor-ui'
+import styled from 'styled-components'
+
+type AccordionProps = {
+ children: React.ReactNode
+ isExpanded: boolean
+ isReadOnly?: boolean
+ setExpandedAccordion: () => void
+ title: string
+}
+
+export function SmallAccordion({
+ children,
+ isExpanded,
+ isReadOnly = false,
+ setExpandedAccordion,
+ title
+}: AccordionProps) {
+ return (
+
+
+
+ {title}
+
+ {!isReadOnly && (
+
+ )}
+
+
+ {children}
+
+ )
+}
+
+const AccordionContainer = styled.div`
+ background-color: ${p => p.theme.color.blueGray25};
+ box-shadow: 0px 3px 6px #70778540;
+ cursor: pointer;
+`
+const StyledIconButton = styled(IconButton)<{ $isExpanded: boolean }>`
+ transform: ${({ $isExpanded }) => ($isExpanded ? 'rotate(180deg)' : 'rotate(0deg)')};
+ transition: transform 0.3s;
+`
+const AccordionHeader = styled.header`
+ color: ${p => p.theme.color.blueYonder};
+ display: flex;
+ font-weight: 500;
+ justify-content: space-between;
+ padding: 8px 24px;
+`
+const TitleContainer = styled.div`
+ align-items: center;
+ display: flex;
+ gap: 16px;
+`
+const Title = styled.span`
+ font-size: 16px;
+ font-weight: 500;
+`
+
+const HeaderSeparator = styled.div`
+ border-bottom: 2px solid ${p => p.theme.color.gainsboro};
+ padding: -24px;
+`
+const AccordionContent = styled.div<{ $isExpanded: boolean }>`
+ display: flex;
+ flex-direction: column;
+ max-height: ${({ $isExpanded }) => ($isExpanded ? '100vh' : '0px')};
+ overflow-x: hidden;
+ transition: 0.5s max-height;
+`
diff --git a/frontend/src/features/Dashboard/components/DashboardForm/index.tsx b/frontend/src/features/Dashboard/components/DashboardForm/index.tsx
index 04f627775f..f564c5f508 100644
--- a/frontend/src/features/Dashboard/components/DashboardForm/index.tsx
+++ b/frontend/src/features/Dashboard/components/DashboardForm/index.tsx
@@ -1,8 +1,8 @@
import { Dashboard } from '@features/Dashboard/types'
import { SideWindowContent } from '@features/SideWindow/style'
import { useAppDispatch } from '@hooks/useAppDispatch'
-import { useAppSelector } from '@hooks/useAppSelector'
import { Accent, Icon, IconButton } from '@mtes-mct/monitor-ui'
+import { useState } from 'react'
import styled from 'styled-components'
import { Accordion } from './Accordion'
@@ -12,18 +12,35 @@ import { dashboardActions } from '../../slice'
export function DashboardForm() {
const dispatch = useAppDispatch()
const dashboardId = 1 // TODO replace with real value
- const expandedAccordion = useAppSelector(state =>
- dashboardId ? state.dashboard.dashboards?.[dashboardId]?.openAccordion : undefined
+ const [expandedAccordionFirstColumn, setExpandedAccordionFirstColumn] = useState
(
+ undefined
+ )
+ const [expandedAccordionSecondColumn, setExpandedAccordionSecondColumn] = useState(
+ undefined
+ )
+ const [expandedAccordionThirdColumn, setExpandedAccordionThirdColumn] = useState(
+ undefined
)
const handleAccordionClick = (type: Dashboard.Block) => {
- if (expandedAccordion === type) {
- dispatch(dashboardActions.setDashboardAccordion())
-
- return
+ switch (type) {
+ case Dashboard.Block.REGULATORY_AREAS:
+ case Dashboard.Block.AMP:
+ case Dashboard.Block.VIGILANCE_AREAS:
+ setExpandedAccordionFirstColumn(expandedAccordionFirstColumn === type ? undefined : type)
+ dispatch(dashboardActions.setDashboardPanel())
+ break
+ case Dashboard.Block.TERRITORIAL_PRESSURE:
+ case Dashboard.Block.REPORTINGS:
+ setExpandedAccordionSecondColumn(expandedAccordionSecondColumn === type ? undefined : type)
+ break
+ case Dashboard.Block.CONTROL_UNITS:
+ case Dashboard.Block.COMMENTS:
+ setExpandedAccordionThirdColumn(expandedAccordionThirdColumn === type ? undefined : type)
+ break
+ default:
+ break
}
- dispatch(dashboardActions.setDashboardAccordion(type))
- dispatch(dashboardActions.setDashboardPanel())
}
const clickOnEye = () => {}
@@ -34,12 +51,12 @@ export function DashboardForm() {
handleAccordionClick(Dashboard.Block.REGULATORY_AREAS)}
/>
handleAccordionClick(Dashboard.Block.AMP)}
title="Zones AMP"
>
@@ -57,7 +74,7 @@ export function DashboardForm() {
TEST
handleAccordionClick(Dashboard.Block.VIGILANCE_AREAS)}
title="Zones de vigilance"
>
@@ -69,7 +86,7 @@ export function DashboardForm() {
handleAccordionClick(Dashboard.Block.TERRITORIAL_PRESSURE)}
title="Pression territoriale des contrôles et surveillances"
>
@@ -88,7 +105,7 @@ export function DashboardForm() {
}
- isExpanded={expandedAccordion === Dashboard.Block.REPORTINGS}
+ isExpanded={expandedAccordionSecondColumn === Dashboard.Block.REPORTINGS}
setExpandedAccordion={() => handleAccordionClick(Dashboard.Block.REPORTINGS)}
title="Signalements"
>
@@ -100,7 +117,7 @@ export function DashboardForm() {
handleAccordionClick(Dashboard.Block.CONTROL_UNITS)}
title="Unités"
>
@@ -118,7 +135,7 @@ export function DashboardForm() {
TEST
handleAccordionClick(Dashboard.Block.COMMENTS)}
title="Commentaires"
>
@@ -134,7 +151,6 @@ export function DashboardForm() {
const Container = styled(SideWindowContent)`
display: flex;
- overflow-y: hidden;
flex-direction: row;
`
@@ -142,8 +158,9 @@ const Column = styled.div`
display: flex;
flex: 1;
flex-direction: column;
- height: 100vh;
- overflow-y: auto;
+ height: calc(100vh- 48px - 40px); // 48px = navbar height, 40px = padding
+ overflow-y: scroll;
+ overflow-x: visible;
+ box-sizing: content-box;
padding: 12px;
- padding-bottom: 100px;
`
diff --git a/frontend/src/features/Dashboard/slice.ts b/frontend/src/features/Dashboard/slice.ts
index 450397a56b..3a83030d0b 100644
--- a/frontend/src/features/Dashboard/slice.ts
+++ b/frontend/src/features/Dashboard/slice.ts
@@ -9,7 +9,6 @@ type OpenPanel = {
type DashboardType = {
dashboard: any
- openAccordion: Dashboard.Block | undefined
openPanel: OpenPanel | undefined
[Dashboard.Block.REGULATORY_AREAS]: number[]
}
@@ -29,7 +28,6 @@ const INITIAL_STATE: DashboardState = {
1: {
// TODO: it's just for testing to delete
dashboard: {},
- openAccordion: undefined,
openPanel: undefined,
[Dashboard.Block.REGULATORY_AREAS]: []
}
@@ -64,17 +62,6 @@ export const dashboardSlice = createSlice({
state.dashboards[id][type] = selectedItems.filter(item => !itemIds.includes(item))
}
},
- setDashboardAccordion(state, action: PayloadAction) {
- const id = state.activeDashboardId
-
- if (!id) {
- return
- }
-
- if (state.dashboards[id]) {
- state.dashboards[id].openAccordion = action.payload
- }
- },
setDashboardPanel(state, action: PayloadAction) {
const id = state.activeDashboardId
diff --git a/frontend/src/features/VigilanceArea/components/VigilanceAreaForm/ImageViewer.tsx b/frontend/src/features/VigilanceArea/components/VigilanceAreaForm/ImageViewer.tsx
index e9a0a990bc..e20805b429 100644
--- a/frontend/src/features/VigilanceArea/components/VigilanceAreaForm/ImageViewer.tsx
+++ b/frontend/src/features/VigilanceArea/components/VigilanceAreaForm/ImageViewer.tsx
@@ -1,6 +1,7 @@
import { useEscapeKey } from '@hooks/useEscapeKey'
import { Accent, Icon, IconButton, THEME } from '@mtes-mct/monitor-ui'
import { useCallback, useState } from 'react'
+import { createPortal } from 'react-dom'
import styled from 'styled-components'
interface ImageViewerProps {
@@ -29,7 +30,7 @@ export function ImageViewer({ currentIndex, images, onClose }: ImageViewerProps)
onEscape: () => onClose()
})
- return (
+ return createPortal(
<>
@@ -72,7 +73,8 @@ export function ImageViewer({ currentIndex, images, onClose }: ImageViewerProps)
)}
- >
+ >,
+ document.body as HTMLElement
)
}