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

Préavis & CR de contrôle - Améliorations #3731

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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 @@ -25,7 +25,9 @@ export function Infraction({ data, index, onDelete, onEdit }: InfractionProps) {
<TagGroup>
<Tag accent={Accent.PRIMARY}>{MissionAction.INFRACTION_TYPE_LABEL[data.infractionType]}</Tag>
{data.infractionType !== MissionAction.InfractionType.PENDING && (
<Tag accent={Accent.PRIMARY}>NATINF : {data.label ?? data.natinf}</Tag>
<StyledTag accent={Accent.PRIMARY} title={data.label ?? String(data.natinf)}>
NATINF : {data.label ?? data.natinf}
</StyledTag>
)}
</TagGroup>

Expand Down Expand Up @@ -57,6 +59,14 @@ export function Infraction({ data, index, onDelete, onEdit }: InfractionProps) {
)
}

const StyledTag = styled(Tag)`
overflow: hidden;
text-overflow: ellipsis;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On gère déjà ça dans monitor-ui normalement non ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white-space: nowrap;
max-width: 400px;
display: inline-block;
`

const InnerWrapper = styled.div`
> div {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import { FormikNumberInput } from '@mtes-mct/monitor-ui'
import { HIDDEN_ERROR } from '@features/Mission/components/MissionForm/constants'
import { FieldError, FormikNumberInput } from '@mtes-mct/monitor-ui'
import { useFormikContext } from 'formik'
import styled from 'styled-components'

import type { MissionActionFormValues } from '@features/Mission/components/MissionForm/types'

export function FormikSpeciesQuantitySeized() {
const { values } = useFormikContext<MissionActionFormValues>()
const { errors, values } = useFormikContext<MissionActionFormValues>()

return (
!!values.hasSomeSpeciesSeized && (
<StyledFormikNumberInput isRequired label="Quantités saisies (kg)" name="speciesQuantitySeized" />
)
<>
{!!values.hasSomeSpeciesSeized && (
<StyledFormikNumberInput
isErrorMessageHidden
isRequired
label="Quantités saisies (kg)"
name="speciesQuantitySeized"
/>
)}
{typeof errors.speciesQuantitySeized === 'string' && errors.speciesQuantitySeized !== HIDDEN_ERROR && (
<FieldError>{errors.speciesQuantitySeized}</FieldError>
)}
</>
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useGetFleetSegmentsQuery } from '@features/FleetSegment/apis'
import { FrontendError } from '@libs/FrontendError'
import { Field, Label, SingleTag, TagGroup } from '@mtes-mct/monitor-ui'
import { Accent, Field, Label, SingleTag, Tag, TagGroup } from '@mtes-mct/monitor-ui'
import { sortByAscendingValue } from '@utils/sortByAscendingValue'
import { useFormikContext } from 'formik'
import { remove as ramdaRemove, uniq } from 'ramda'
import { useCallback, useMemo } from 'react'
import { uniq } from 'ramda'
import { useMemo } from 'react'
import styled from 'styled-components'

import { useGetMissionActionFormikUsecases } from '../../hooks/useGetMissionActionFormikUsecases'
Expand All @@ -30,26 +29,6 @@ export function VesselFleetSegmentsField({ label }: VesselFleetSegmentsFieldProp
updateSegments({ ...values, faoAreas: nextFaoAreas })
}

const removeFleetSegment = useCallback(
(fleetSegmentIndex: number | undefined) => {
if (!values.segments) {
throw new FrontendError('`segments` is undefined')
}

if (fleetSegmentIndex === undefined) {
throw new FrontendError('`fleetSegmentIndex` is undefined')
}

const nextFleetSegments = ramdaRemove(fleetSegmentIndex, 1, values.segments)
const normalizedNextSegments = nextFleetSegments.length > 0 ? nextFleetSegments : undefined

setFieldValue('segments', normalizedNextSegments)
},

// eslint-disable-next-line react-hooks/exhaustive-deps
[values.segments]
)

const faoAreaTags = () => {
if (!values.faoAreas) {
return []
Expand All @@ -67,14 +46,11 @@ export function VesselFleetSegmentsField({ label }: VesselFleetSegmentsFieldProp
const fleetSegmentTags = useMemo(
() =>
values.segments
? values.segments.map(({ segment, segmentName }, index) => (
<SingleTag
key={segment}
onDelete={() => removeFleetSegment(index)}
>{`${segment} - ${segmentName}`}</SingleTag>
? values.segments.map(({ segment, segmentName }) => (
<Tag key={segment} accent={Accent.PRIMARY}>{`${segment} - ${segmentName}`}</Tag>
))
: [],
[values.segments, removeFleetSegment]
[values.segments]
)

if (isLoading) {
Expand All @@ -95,14 +71,14 @@ export function VesselFleetSegmentsField({ label }: VesselFleetSegmentsFieldProp
{faoAreaTags.length > 0 && (
<Field>
<Label>Zones de pêche de la marée (issues des FAR)</Label>
<TagGroup>{faoAreaTags()}</TagGroup>
<StyledTagGroup>{faoAreaTags()}</StyledTagGroup>
</Field>
)}

{fleetSegmentTags.length > 0 && (
<Field>
<Label>Segment de flotte de la marée</Label>
<TagGroup>{fleetSegmentTags}</TagGroup>
<StyledTagGroup>{fleetSegmentTags}</StyledTagGroup>
</Field>
)}
</>
Expand All @@ -111,6 +87,10 @@ export function VesselFleetSegmentsField({ label }: VesselFleetSegmentsFieldProp
)
}

const StyledTagGroup = styled(TagGroup)`
padding-top: 8px;
`

const Helper = styled.p`
color: ${p => p.theme.color.slateGray};
font-style: italic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ export function FormikFishingCatchesMultiSelect({ isReadOnly }: FormikFishingCat

return (
<>
<Select
key={String(values.fishingCatches?.length)}
customSearch={customSearch}
disabled={!speciesAsOptions}
error={validationError}
label="Espèces à bord et à débarquer"
name="fishingCatches"
onChange={add}
options={speciesAsOptions ?? []}
optionValueKey="code"
readOnly={isReadOnly}
searchable
virtualized
/>

<Wrapper>
{values.fishingCatches.map((fishingCatch, index) => (
<Fragment key={fishingCatch.specyCode}>
Expand Down Expand Up @@ -163,6 +148,21 @@ export function FormikFishingCatchesMultiSelect({ isReadOnly }: FormikFishingCat
</Fragment>
))}
</Wrapper>

<Select
key={String(values.fishingCatches?.length)}
customSearch={customSearch}
disabled={!speciesAsOptions}
error={validationError}
label="Espèces à bord et à débarquer"
name="fishingCatches"
onChange={add}
options={speciesAsOptions ?? []}
optionValueKey="code"
readOnly={isReadOnly}
searchable
virtualized
/>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,16 @@ import {
ExpectedArrivalPeriod,
FILTER_STATUSES_AS_OPTIONS
} from './constants'
import { useIsSuperUser } from '../../../../auth/hooks/useIsSuperUser'
import { priorNotificationActions } from '../../slice'

import type { FilterStatus } from './types'
import type { Promisable } from 'type-fest'

export type FilterBarProps = {
onQueryChange: (nextQuery: string | undefined) => Promisable<void>
searchQuery: string | undefined
}
export function FilterBar() {
const dispatch = useMainAppDispatch()
const isSuperUser = useIsSuperUser()
const { newWindowContainerRef } = useNewWindow()
const listFilterValues = useMainAppSelector(store => store.priorNotification.listFilterValues)
const dispatch = useMainAppDispatch()

const { fleetSegmentsAsOptions } = useGetFleetSegmentsAsOptions()
const { gearsAsTreeOptions } = useGetGearsAsTreeOptions()
Expand Down Expand Up @@ -219,16 +216,18 @@ export function FilterBar() {
style={{ minWidth: 224 }}
value={listFilterValues.lastControlPeriod}
/>
<RichBooleanCheckbox
falseOptionLabel="Sans signalement"
isInline
isLabelHidden
label="Signalements"
name="hasOneOrMoreReportings"
onChange={updateHasOneOrMoreReportings}
trueOptionLabel="Avec signalements"
value={listFilterValues.hasOneOrMoreReportings}
/>
{isSuperUser && (
<RichBooleanCheckbox
falseOptionLabel="Sans signalement"
isInline
isLabelHidden
label="Signalements"
name="hasOneOrMoreReportings"
onChange={updateHasOneOrMoreReportings}
trueOptionLabel="Avec signalements"
value={listFilterValues.hasOneOrMoreReportings}
/>
)}
</Row>

<Row>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { type Option, Select } from '@mtes-mct/monitor-ui'
import { useGetForeignFmcsQuery } from '@api/foreignFmc'
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
import { type Option, Select, THEME } from '@mtes-mct/monitor-ui'
import { useEffect, useMemo, useRef, useState } from 'react'
import { SelectPicker } from 'rsuite'
import styled from 'styled-components'

import { useGetForeignFmcsQuery } from '../../../api/foreignFmc'
import { COLORS } from '../../../constants/constants'
import { NOTIFICATION_TYPE } from '../../../domain/entities/beaconMalfunction/constants'
import { sendNotification } from '../../../domain/use_cases/beaconMalfunction/sendNotification'
import { useMainAppDispatch } from '../../../hooks/useMainAppDispatch'

import type { CSSProperties } from 'react'

Expand All @@ -19,9 +18,7 @@ export function SendNotification({ beaconMalfunction }) {
const [isShowingForeignFmcList, setIsShowingForeignFmcList] = useState<boolean>(false)
/* eslint-enable sort-keys-fix/sort-keys-fix */
const notificationTypes: Array<keyof typeof NOTIFICATION_TYPE> = [
'MALFUNCTION_AT_PORT_INITIAL_NOTIFICATION',
louptheron marked this conversation as resolved.
Show resolved Hide resolved
'MALFUNCTION_AT_PORT_REMINDER',
'MALFUNCTION_AT_SEA_INITIAL_NOTIFICATION',
'MALFUNCTION_AT_SEA_REMINDER',
'MALFUNCTION_NOTIFICATION_TO_FOREIGN_FMC'
]
Expand All @@ -47,7 +44,7 @@ export function SendNotification({ beaconMalfunction }) {
if (selectMenuRef.current?.previousSibling) {
;(selectMenuRef.current.previousSibling as HTMLElement).style.setProperty(
'background',
COLORS.charcoal,
THEME.color.charcoal,
'important'
)
;(selectMenuRef.current.previousSibling as HTMLElement).style.setProperty(
Expand All @@ -61,7 +58,7 @@ export function SendNotification({ beaconMalfunction }) {
'.rs-picker-toggle-placeholder'
)
if (toggleElement?.style) {
toggleElement.style.setProperty('color', COLORS.gainsboro, 'important')
toggleElement.style.setProperty('color', THEME.color.gainsboro, 'important')
toggleElement.style.setProperty('font-size', '13', 'important')
}
}
Expand Down
Loading