Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tableau de bord & Brief] Ajout d'un feedback sur le bouton de génération de brief #1893

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,14 +19,21 @@ export const Comments = forwardRef<HTMLDivElement, CommentsProps>(
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 (
<Accordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ export function Comments({ comments }: { comments: string | undefined }) {
<>
<Text style={layoutStyle.title}>Commentaires</Text>
<View style={{ flexDirection: 'row', gap: 10.5 }}>
{!!comments && getPrettyComments(comments).map(comment => <Text style={styles.comments}>{comment}</Text>)}
{!!comments &&
getPrettyComments(comments).map((comment, index) => (
// eslint-disable-next-line react/no-array-index-key
<Text key={index} style={styles.comments}>
{comment}
</Text>
))}
</View>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export function GeneratePdfButton({ dashboard }: GeneratePdfButtonProps) {
}

return (
<StyledLinkButton Icon={Icon.Document} onClick={handleDownload}>
Générer un brief
<StyledLinkButton disabled={pdf.loading} Icon={Icon.Document} onClick={handleDownload}>
{pdf.loading ? 'Chargement du brief' : 'Générer un brief'}
maximeperraultdev marked this conversation as resolved.
Show resolved Hide resolved
</StyledLinkButton>
)
}
Expand Down
52 changes: 27 additions & 25 deletions frontend/src/features/Dashboard/components/Pdf/Reportings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,35 +173,37 @@ export function Reportings({
<Text style={layoutStyle.selected}>{reportings.length} sélectionnée(s)</Text>
</View>
<View style={layoutStyle.cardWrapper}>
<View style={styles.legendCard}>
<View style={layoutStyle.row}>
<View style={{ flex: 1 }}>
<Text style={{ fontWeight: 'bold' }}>Signalements en cours</Text>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.blueGray} />
<Text>Observation</Text>
{reportings.length > 0 && (
<View style={styles.legendCard}>
<View style={layoutStyle.row}>
<View style={{ flex: 1 }}>
<Text style={{ fontWeight: 'bold' }}>Signalements en cours</Text>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.blueGray} />
<Text>Observation</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.maximumRed} /> <Text>Suspicion d&apos;infraction</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.mediumSeaGreen} /> <Text>Rattaché à une mission</Text>
</View>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.maximumRed} /> <Text>Suspicion d&apos;infraction</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<Flag color={THEME.color.mediumSeaGreen} /> <Text>Rattaché à une mission</Text>
</View>
</View>
<View style={{ flex: 1 }}>
<Text style={{ fontWeight: 'bold' }}>Signalements archivés</Text>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedObservation /> <Text>Observation</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedInfraction /> <Text>Suspicion d&apos;infraction</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedWithMission /> <Text>Rattaché à une mission</Text>
<View style={{ flex: 1 }}>
<Text style={{ fontWeight: 'bold' }}>Signalements archivés</Text>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedObservation /> <Text>Observation</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedInfraction /> <Text>Suspicion d&apos;infraction</Text>
</View>
<View style={[layoutStyle.row, { fontSize: 6.2, marginTop: 6 }]}>
<FlagArchivedWithMission /> <Text>Rattaché à une mission</Text>
</View>
</View>
</View>
</View>
</View>
)}
{reportings.map(reporting => (
<View key={reporting.id} style={[styles.reportingCard, { position: 'relative' }]}>
<View style={{ left: 3, position: 'absolute', top: 9 }}>{reportingStatusFlag(reporting)}</View>
Expand Down
Loading