Skip to content

Commit

Permalink
Préavis - Le champ note n'est pas visible dans la partie ext (#3512)
Browse files Browse the repository at this point in the history
## Linked issues

- Le champ note des préavis n'est pas visible dans la partie `ext`

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron authored Aug 9, 2024
2 parents a9fd3ed + 08834e6 commit 3b16061
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions frontend/src/features/Logbook/LogbookMessage.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export namespace LogbookMessage {

interface MessageBase {}
export interface PnoMessage extends MessageBase {
authorTrigram: string | undefined
catchOnboard: Catch[] | undefined
catchToLand: Catch[] | undefined
economicZone: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ export function Form({ detail, initialFormValues }: FormProps) {
<FormikEffect onChange={!isInvalidated ? (updateNote as any) : noop} />

<FieldGroup>
<FormikTextarea label="Points d'attention identifiés par le CNSP" name="note" readOnly={isInvalidated} />
<FormikTextarea
label="Points d'attention identifiés par le CNSP"
name="note"
readOnly={!isSuperUser || isInvalidated}
/>
</FieldGroup>

<AuthorTrigramInput label="Par" name="authorTrigram" readOnly={isInvalidated} />
{isSuperUser && <AuthorTrigramInput label="Par" name="authorTrigram" readOnly={isInvalidated} />}
</>
</Formik>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { assertNotNullish } from '@utils/assertNotNullish'

import { Footer } from './Footer'
import { Form } from './Form'
import { useIsSuperUser } from '../../../../auth/hooks/useIsSuperUser'
import { PriorNotificationCard } from '../PriorNotificationCard'

export function LogbookPriorNotificationForm() {
const dispatch = useMainAppDispatch()
const isSuperUser = useIsSuperUser()
const displayedError = useMainAppSelector(
state => state.displayedError[DisplayedErrorKey.SIDE_WINDOW_PRIOR_NOTIFICATION_FORM_ERROR]
)
Expand Down Expand Up @@ -45,7 +47,9 @@ export function LogbookPriorNotificationForm() {
<Form detail={openedPriorNotificationDetail} initialFormValues={editedLogbookPriorNotificationFormValues} />
}
detail={openedPriorNotificationDetail}
footerChildren={<Footer detail={openedPriorNotificationDetail} onVerifyAndSend={verifyAndSend} />}
footerChildren={
isSuperUser ? <Footer detail={openedPriorNotificationDetail} onVerifyAndSend={verifyAndSend} /> : null
}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { useGetPriorNotificationsQuery, useGetPriorNotificationsToVerifyQuery }
import { priorNotificationActions } from '../../slice'
import { LogbookPriorNotificationForm } from '../LogbookPriorNotificationForm'
import { ManualPriorNotificationForm } from '../ManualPriorNotificationForm'
import { PriorNotificationCard } from '../PriorNotificationCard'

import type { AllSeafrontGroup, NoSeafrontGroup, SeafrontGroup } from '@constants/seafront'

Expand Down Expand Up @@ -238,12 +237,6 @@ export function PriorNotificationList({ isFromUrl }: PriorNotificationListProps)
</Body>
</Page>

{openedPriorNotificationComponentType === OpenedPriorNotificationType.Card && (
<PriorNotificationCard
key={openedPriorNotificationDetail?.fingerprint}
detail={openedPriorNotificationDetail}
/>
)}
{openedPriorNotificationComponentType === OpenedPriorNotificationType.LogbookForm && (
<LogbookPriorNotificationForm key={openedPriorNotificationDetail?.fingerprint} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('PriorNotificationCard/utils.getHtmlContent()', () => {
isManuallyCreated: true,
isSentByFailoverSoftware: false,
message: {
authorTrigram: undefined,
catchOnboard: [
{
conversionFactor: undefined,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/features/PriorNotification/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export enum OpenedPriorNotificationType {
Card = 'Card',
LogbookForm = 'LogbookForm',
ManualForm = 'ManualForm'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Level } from '@mtes-mct/monitor-ui'
import { handleThunkError } from '@utils/handleThunkError'
import { displayedErrorActions } from 'domain/shared_slices/DisplayedError'
import { displayOrLogError } from 'domain/use_cases/error/displayOrLogError'
import { pick } from 'lodash'

import { OpenedPriorNotificationType } from '../constants'
import { priorNotificationApi } from '../priorNotificationApi'
Expand All @@ -24,7 +25,7 @@ export const openPriorNotificationCard =
try {
dispatch(displayedErrorActions.unset(DisplayedErrorKey.SIDE_WINDOW_PRIOR_NOTIFICATION_CARD_ERROR))
dispatch(priorNotificationActions.closePriorNotificationCardAndForm())
dispatch(priorNotificationActions.openPriorNotification(OpenedPriorNotificationType.Card))
dispatch(priorNotificationActions.openPriorNotification(OpenedPriorNotificationType.LogbookForm))

const priorNotificationDetail = await dispatch(
priorNotificationApi.endpoints.getPriorNotificationDetail.initiate({
Expand Down Expand Up @@ -55,6 +56,8 @@ export const openPriorNotificationCard =
}

dispatch(priorNotificationActions.setOpenedPriorNotificationDetail(priorNotificationDetail))
const priorNotificationData = pick(priorNotificationDetail.logbookMessage.message, ['note', 'authorTrigram'])
dispatch(priorNotificationActions.setEditedLogbookPriorNotificationFormValues(priorNotificationData))
} catch (err) {
if (err instanceof FrontendApiError) {
dispatch(
Expand Down

0 comments on commit 3b16061

Please sign in to comment.