diff --git a/frontend/src/features/Dashboard/components/DashboardForm/Comments/index.tsx b/frontend/src/features/Dashboard/components/DashboardForm/Comments/index.tsx index 71020f7a5..73b8f7aa0 100644 --- a/frontend/src/features/Dashboard/components/DashboardForm/Comments/index.tsx +++ b/frontend/src/features/Dashboard/components/DashboardForm/Comments/index.tsx @@ -2,7 +2,7 @@ import { dashboardActions } from '@features/Dashboard/slice' import { useAppDispatch } from '@hooks/useAppDispatch' import { Textarea } from '@mtes-mct/monitor-ui' import { debounce } from 'lodash' -import { forwardRef, useState } from 'react' +import { forwardRef, useCallback, useMemo, useState } from 'react' import styled from 'styled-components' import { Accordion } from '../Accordion' @@ -19,14 +19,21 @@ export const Comments = forwardRef( const dispatch = useAppDispatch() const [commentsValue, setCommentsValue] = useState(comments) - const onQuery = debounce((value: string | undefined) => { - dispatch(dashboardActions.setComments({ comments: value, key: dashboardKey })) - }, 500) + const onQuery = useMemo( + () => + debounce((value: string | undefined) => { + dispatch(dashboardActions.setComments({ comments: value, key: dashboardKey })) + }, 500), + [dashboardKey, dispatch] + ) - const updateComments = (value: string | undefined) => { - setCommentsValue(value) - onQuery(value) - } + const updateComments = useCallback( + (value: string | undefined) => { + setCommentsValue(value) + onQuery(value) + }, + [onQuery] + ) return ( Commentaires - {!!comments && getPrettyComments(comments).map(comment => {comment})} + {!!comments && + getPrettyComments(comments).map((comment, index) => ( + // eslint-disable-next-line react/no-array-index-key + + {comment} + + ))} ) diff --git a/frontend/src/features/Dashboard/components/Pdf/GeneratePdfButton.tsx b/frontend/src/features/Dashboard/components/Pdf/GeneratePdfButton.tsx index abf2774e5..06ba8b052 100644 --- a/frontend/src/features/Dashboard/components/Pdf/GeneratePdfButton.tsx +++ b/frontend/src/features/Dashboard/components/Pdf/GeneratePdfButton.tsx @@ -87,8 +87,8 @@ export function GeneratePdfButton({ dashboard }: GeneratePdfButtonProps) { } return ( - - Générer un brief + + {pdf.loading ? 'Chargement du brief' : 'Générer un brief'} ) } diff --git a/frontend/src/features/Dashboard/components/Pdf/Reportings/index.tsx b/frontend/src/features/Dashboard/components/Pdf/Reportings/index.tsx index 4e4e6072f..63e783e87 100644 --- a/frontend/src/features/Dashboard/components/Pdf/Reportings/index.tsx +++ b/frontend/src/features/Dashboard/components/Pdf/Reportings/index.tsx @@ -173,35 +173,37 @@ export function Reportings({ {reportings.length} sélectionnée(s) - - - - Signalements en cours - - - Observation + {reportings.length > 0 && ( + + + + Signalements en cours + + + Observation + + + Suspicion d'infraction + + + Rattaché à une mission + - - Suspicion d'infraction - - - Rattaché à une mission - - - - Signalements archivés - - Observation - - - Suspicion d'infraction - - - Rattaché à une mission + + Signalements archivés + + Observation + + + Suspicion d'infraction + + + Rattaché à une mission + - + )} {reportings.map(reporting => ( {reportingStatusFlag(reporting)}