Skip to content

Commit

Permalink
Various fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Mar 5, 2024
1 parent 71911b0 commit 5c2f60e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
26 changes: 9 additions & 17 deletions frontend/src/features/Reporting/components/ReportingForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useGetLegacyControlUnitsQuery } from '@api/legacyControlUnit'
import { COLORS } from '@constants/constants'
import { useGetControlUnitsQuery } from '@features/ControlUnit/controlUnitApi'
import { CreateOrEditReportingSchema } from '@features/Reporting/components/ReportingForm/schemas'
import {
getFormFields,
Expand Down Expand Up @@ -42,7 +42,7 @@ export function ReportingForm({
}: ReportingFormProps) {
const dispatch = useMainAppDispatch()
const infractions = useMainAppSelector(state => state.infraction.infractions)
const controlUnitsQuery = useGetLegacyControlUnitsQuery(undefined)
const controlUnitsQuery = useGetControlUnitsQuery(undefined)

const infractionsAsOptions = useMemo(
() =>
Expand Down Expand Up @@ -118,7 +118,7 @@ export function ReportingForm({
<>
<StyledForm $hasWhiteBackground={hasWhiteBackground}>
<Fieldset className="Field-MultiRadio">
<StyledLabel htmlFor="type">Type</StyledLabel>
<Legend>Type</Legend>
<RadioGroup
appearance="picker"
defaultValue={ReportingTypeCharacteristics.INFRACTION_SUSPICION.code}
Expand All @@ -144,7 +144,7 @@ export function ReportingForm({
</RadioGroup>
</Fieldset>
<Fieldset className="Field-MultiRadio">
<StyledLabel htmlFor="reportingActor">Origine</StyledLabel>
<Legend>Origine</Legend>
<RadioGroup
appearance="picker"
defaultValue={ReportingOriginActor.OPS.code}
Expand Down Expand Up @@ -233,18 +233,14 @@ export function ReportingForm({
}

const StyledFormikSelect = styled(FormikSelect)`
margin-top: 16px;
width: 410px;
`

const StyledFormikTextInput = styled(FormikTextInput)`
box-sizing: border-box;
margin-top: 16px;
width: 410px;
`

const StyledFormikTextarea = styled(FormikTextarea)`
margin-top: 16px;
width: 410px;
`

Expand All @@ -256,24 +252,20 @@ const CancelButton = styled(Button)`
margin: 24px 0px 0px 0px;
`

const StyledLabel = styled(Legend)<{
htmlFor: string | undefined
}>`
margin-top: 12px;
`

const StyledForm = styled(Form)<{
$hasWhiteBackground: boolean
}>`
* {
box-sizing: border-box !important;
}
margin: 0px 16px 16px 16px;
.rs-picker-toggle {
background: ${p => (p.$hasWhiteBackground ? COLORS.gainsboro : COLORS.white)} !important;
> .Element-Field,
> .Element-Fieldset {
margin-top: 12px;
}
margin: 0px 16px 16px 16px;
.rs-radio-group {
margin-top: 1px;
margin-bottom: 5px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { customDayjs } from '@mtes-mct/monitor-ui'
import { ControlUnit, customDayjs } from '@mtes-mct/monitor-ui'

import type { LegacyControlUnit } from '../../../../../domain/types/legacyControlUnit'
import type { Reporting } from '../../../../../domain/types/reporting'
import type { Option } from '@mtes-mct/monitor-ui'

export const mapControlUnitsToUniqueSortedIdsAsOptions = (
controlUnits: LegacyControlUnit.LegacyControlUnit[]
): Option<number>[] =>
export const mapControlUnitsToUniqueSortedIdsAsOptions = (controlUnits: ControlUnit.ControlUnit[]): Option<number>[] =>
Array.from(controlUnits)
.sort((a, b) => Number(b.name) - Number(a.name))
.map(controlUnit => ({
label: `${controlUnit.name} (${controlUnit.administration})`,
label: `${controlUnit.name} (${controlUnit.administration.name})`,
value: controlUnit.id
}))

Expand Down

0 comments on commit 5c2f60e

Please sign in to comment.