From 571df76c792a8a1adfe5ae11e55e827be102b930 Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Tue, 4 Feb 2025 10:51:48 +0100 Subject: [PATCH] Fix URLs after using RTK params --- .github/workflows/cicd.yml | 2 +- .../light/outputs/LogbookMessageDataOutput.kt | 52 +++++++++---------- .../api/outputs/LogbookMessageDataOutput.kt | 45 ++++++++-------- .../BaseLogbookMessageDataOutput.kt | 30 +++++++++++ .../regulation_table/table.spec.ts | 2 +- .../vessel_sidebar/control_buttons.spec.ts | 4 +- .../vessel_sidebar/ers_vms.spec.ts | 10 ++-- .../vessel_sidebar/logbook.spec.ts | 12 ++--- .../vessel_sidebar/offline_management.spec.ts | 20 ++++--- .../beacon_malfunction/board.spec.ts | 10 ++-- .../form.spec.ts | 6 +-- .../mission_form/sea_control.spec.ts | 10 ++-- .../filter_bar.spec.ts | 2 +- frontend/src/api/alert.ts | 6 +-- frontend/src/api/api.ts | 2 +- frontend/src/domain/entities/vessel/types.ts | 2 +- frontend/src/domain/types/GeoJSON.ts | 16 +++--- .../useCases/getVesselBeaconMalfunctions.ts | 2 +- .../PriorNotification/priorNotificationApi.ts | 6 +-- frontend/src/features/Regulation/slice.ts | 2 +- frontend/src/features/Regulation/types.ts | 2 +- frontend/src/features/Reporting/types.ts | 4 +- frontend/src/features/Vessel/Vessel.types.ts | 2 + .../Vessel/components/VesselLoader.tsx | 16 +++--- .../schemas/VesselLastPositionLightSchema.ts | 11 ++++ frontend/src/features/Vessel/vesselApi.ts | 1 - frontend/src/features/Vessel/vesselNavApi.ts | 8 +-- frontend/src/store/index.ts | 2 +- frontend/src/types.test.ts | 2 +- frontend/src/utils/nullify.ts | 2 +- frontend/src/utils/undefinedize.ts | 2 +- 31 files changed, 168 insertions(+), 125 deletions(-) create mode 100644 backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt create mode 100644 frontend/src/features/Vessel/schemas/VesselLastPositionLightSchema.ts diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 8c6cf2bae4..c0430f69ad 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -259,7 +259,7 @@ jobs: uses: actions/checkout@v4 - name: Download image - uses: ishworkh/docker-image-artifact-download@v1 + uses: ishworkh/container-image-artifact-upload@v2.0.0 with: image: monitorfish-app:${{ env.VERSION }} diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt index 8528a35ab1..d3f6f828d2 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/light/outputs/LogbookMessageDataOutput.kt @@ -4,33 +4,32 @@ import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessage import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookOperationType import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.Acknowledgment import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.LogbookMessageValue +import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.interfaces.BaseLogbookMessageDataOutput import java.time.ZonedDateTime data class LogbookMessageDataOutput( - val reportId: String? = null, - val operationNumber: String?, - val tripNumber: String? = null, - val referencedReportId: String? = null, - var isCorrected: Boolean? = false, - val operationType: LogbookOperationType, - val operationDateTime: ZonedDateTime? = null, - val activityDateTime: ZonedDateTime? = null, - val reportDateTime: ZonedDateTime? = null, - val integrationDateTime: ZonedDateTime? = null, - val internalReferenceNumber: String? = null, - val externalReferenceNumber: String? = null, - val ircs: String? = null, - val vesselName: String? = null, - /** ISO Alpha-3 country code. **/ - val flagState: String? = null, - val imo: String? = null, - val messageType: String? = null, - var acknowledgment: Acknowledgment? = null, - var deleted: Boolean? = false, - val message: LogbookMessageValue? = null, - var rawMessage: String? = null, - val isSentByFailoverSoftware: Boolean, -) { + override val reportId: String?, + override val operationNumber: String?, + override val tripNumber: String?, + override val referencedReportId: String?, + override val isCorrectedByNewerMessage: Boolean, + override val operationType: LogbookOperationType, + override val operationDateTime: ZonedDateTime?, + override val activityDateTime: ZonedDateTime?, + override val reportDateTime: ZonedDateTime?, + override val integrationDateTime: ZonedDateTime?, + override val internalReferenceNumber: String?, + override val externalReferenceNumber: String?, + override val ircs: String?, + override val vesselName: String?, + override val flagState: String?, + override val imo: String?, + override val messageType: String?, + override val acknowledgment: Acknowledgment?, + override val isDeleted: Boolean, + override val message: LogbookMessageValue?, + override val isSentByFailoverSoftware: Boolean, +): BaseLogbookMessageDataOutput { companion object { fun fromLogbookMessage(logbookMessage: LogbookMessage) = LogbookMessageDataOutput( @@ -38,9 +37,9 @@ data class LogbookMessageDataOutput( referencedReportId = logbookMessage.referencedReportId, externalReferenceNumber = logbookMessage.externalReferenceNumber, ircs = logbookMessage.ircs, - isCorrected = logbookMessage.isCorrectedByNewerMessage, + isCorrectedByNewerMessage = logbookMessage.isCorrectedByNewerMessage, acknowledgment = logbookMessage.acknowledgment, - deleted = logbookMessage.isDeleted, + isDeleted = logbookMessage.isDeleted, operationDateTime = logbookMessage.operationDateTime, activityDateTime = logbookMessage.activityDateTime, reportDateTime = logbookMessage.reportDateTime, @@ -54,7 +53,6 @@ data class LogbookMessageDataOutput( imo = logbookMessage.imo, messageType = logbookMessage.messageType, message = logbookMessage.message, - rawMessage = null, isSentByFailoverSoftware = logbookMessage.isSentByFailoverSoftware, ) } diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt index 17de7b78ff..80f4d39802 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/LogbookMessageDataOutput.kt @@ -4,34 +4,35 @@ import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookMessage import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookOperationType import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.Acknowledgment import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.LogbookMessageValue +import fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.interfaces.BaseLogbookMessageDataOutput import java.time.ZonedDateTime data class LogbookMessageDataOutput( - val reportId: String?, - val operationNumber: String?, - val tripNumber: String?, - val referencedReportId: String?, - val operationDateTime: ZonedDateTime?, - val activityDateTime: ZonedDateTime?, - val reportDateTime: ZonedDateTime?, - val integrationDateTime: ZonedDateTime?, - val internalReferenceNumber: String?, - val externalReferenceNumber: String?, - val ircs: String?, - val vesselName: String?, - val flagState: String?, - val imo: String?, + override val reportId: String?, + override val operationNumber: String?, + override val tripNumber: String?, + override val referencedReportId: String?, + override val operationDateTime: ZonedDateTime?, + override val activityDateTime: ZonedDateTime?, + override val reportDateTime: ZonedDateTime?, + override val integrationDateTime: ZonedDateTime?, + override val internalReferenceNumber: String?, + override val externalReferenceNumber: String?, + override val ircs: String?, + override val vesselName: String?, + override val flagState: String?, + override val imo: String?, + override val acknowledgment: Acknowledgment?, + override val isCorrectedByNewerMessage: Boolean, + override val isDeleted: Boolean, + override val isSentByFailoverSoftware: Boolean, + override val message: LogbookMessageValue?, + override val messageType: String?, + override val operationType: LogbookOperationType, val rawMessage: String?, - val acknowledgment: Acknowledgment?, - val isCorrectedByNewerMessage: Boolean, - val isDeleted: Boolean, - val isSentByFailoverSoftware: Boolean, - val message: LogbookMessageValue?, - val messageType: String?, - val operationType: LogbookOperationType, val tripGears: List?, val tripSegments: List?, -) { +): BaseLogbookMessageDataOutput { companion object { fun fromLogbookMessage(logbookMessage: LogbookMessage): LogbookMessageDataOutput { val tripGears = diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt new file mode 100644 index 0000000000..c78337e811 --- /dev/null +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/infrastructure/api/outputs/interfaces/BaseLogbookMessageDataOutput.kt @@ -0,0 +1,30 @@ +package fr.gouv.cnsp.monitorfish.infrastructure.api.outputs.interfaces + +import fr.gouv.cnsp.monitorfish.domain.entities.logbook.LogbookOperationType +import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.Acknowledgment +import fr.gouv.cnsp.monitorfish.domain.entities.logbook.messages.LogbookMessageValue +import java.time.ZonedDateTime + +interface BaseLogbookMessageDataOutput { + val reportId: String? + val operationNumber: String? + val tripNumber: String? + val referencedReportId: String? + val operationDateTime: ZonedDateTime? + val activityDateTime: ZonedDateTime? + val reportDateTime: ZonedDateTime? + val integrationDateTime: ZonedDateTime? + val internalReferenceNumber: String? + val externalReferenceNumber: String? + val ircs: String? + val vesselName: String? + val flagState: String? + val imo: String? + val acknowledgment: Acknowledgment? + val isCorrectedByNewerMessage: Boolean + val isDeleted: Boolean + val isSentByFailoverSoftware: Boolean + val message: LogbookMessageValue? + val messageType: String? + val operationType: LogbookOperationType +} diff --git a/frontend/cypress/e2e/back_office/regulation_table/table.spec.ts b/frontend/cypress/e2e/back_office/regulation_table/table.spec.ts index 780e052d8d..3ae4915da3 100644 --- a/frontend/cypress/e2e/back_office/regulation_table/table.spec.ts +++ b/frontend/cypress/e2e/back_office/regulation_table/table.spec.ts @@ -7,7 +7,7 @@ context('BackOffice > Regulation Table > Table', () => { cy.wait(1000) }) - it('regulatory zones are displayed by layer name and law schemas', () => { + it('regulatory zones are displayed by layer name and law types', () => { cy.get('[data-cy="backoffice-search-regulation"]').type('dra') cy.get('[data-cy="Reg. NAMO"]').eq(0).click() cy.get('[data-cy="backoffice-search-regulation"]').type('{backspace}{backspace}{backspace}') diff --git a/frontend/cypress/e2e/main_window/vessel_sidebar/control_buttons.spec.ts b/frontend/cypress/e2e/main_window/vessel_sidebar/control_buttons.spec.ts index 3ea802417e..adf645b5fa 100644 --- a/frontend/cypress/e2e/main_window/vessel_sidebar/control_buttons.spec.ts +++ b/frontend/cypress/e2e/main_window/vessel_sidebar/control_buttons.spec.ts @@ -124,8 +124,8 @@ context('Vessel sidebar controls buttons', () => { // Then cy.wait('@getPositions').then(({ request }) => { - expect(request.url).contains(`${startDateAsDayjs.format('DD')}T00:00:00.000Z`) - expect(request.url).contains(`${endDateAsDayjs.format('DD')}T23:59:59.000Z`) + expect(request.url).contains(encodeURIComponent(`${startDateAsDayjs.format('DD')}T00:00:00.000Z`)) + expect(request.url).contains(encodeURIComponent(`${endDateAsDayjs.format('DD')}T23:59:59.000Z`)) }) cy.wait(200) diff --git a/frontend/cypress/e2e/main_window/vessel_sidebar/ers_vms.spec.ts b/frontend/cypress/e2e/main_window/vessel_sidebar/ers_vms.spec.ts index fa11a54ab3..b4b4d55cd4 100644 --- a/frontend/cypress/e2e/main_window/vessel_sidebar/ers_vms.spec.ts +++ b/frontend/cypress/e2e/main_window/vessel_sidebar/ers_vms.spec.ts @@ -91,8 +91,9 @@ context('Vessel sidebar ers/vms tab', () => { // Go to the detail of a beacon malfunction and go back to resume cy.intercept( 'GET', - 'bff/v1/vessels/find?vesselId=1&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=' + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS' + + '&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', ).as('openVessel') openVesselBySearch('Pheno') cy.wait('@openVessel') @@ -110,8 +111,9 @@ context('Vessel sidebar ers/vms tab', () => { // Search for another vessel cy.intercept( 'GET', - 'bff/v1/vessels/find?vesselId=2&internalReferenceNumber=U_W0NTFINDME&externalReferenceNumber=TALK2ME' + - '&IRCS=QGDF&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=' + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=TALK2ME' + + '&internalReferenceNumber=U_W0NTFINDME&IRCS=QGDF&trackDepth=TWELVE_HOURS' + + '&vesselId=2&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', ).as('openVesselTwo') cy.intercept('GET', '/bff/v1/vessels/beacon_malfunctions*').as('vesselTwoBeaconMalfunctions') cy.get('*[data-cy^="vessel-search-selected-vessel-close-title"]', { timeout: 10000 }).click() diff --git a/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts b/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts index 93be32fe08..c054c306eb 100644 --- a/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts +++ b/frontend/cypress/e2e/main_window/vessel_sidebar/logbook.spec.ts @@ -152,9 +152,9 @@ context('Vessel sidebar logbook tab', () => { .its('response.url') .should( 'have.string', - '/bff/v1/vessels/positions?internalReferenceNumber=FAK000999999' + - '&externalReferenceNumber=DONTSINK&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=CUSTOM' + - '&afterDateTime=2019-02-16T21:05:00.000Z&beforeDateTime=2019-10-15T13:01:00.000Z' + encodeURIComponent('/bff/v1/vessels/positions?afterDateTime=2019-02-16T21:05:00.000Z' + + '&beforeDateTime=2019-10-15T13:01:00.000Z&externalReferenceNumber=DONTSINK&internalReferenceNumber=FAK000999999' + + '&IRCS=CALLME&trackDepth=CUSTOM&vesselIdentifier=INTERNAL_REFERENCE_NUMBER') ) cy.get('*[data-cy^="fishing-activity-name"]').should('exist').should('have.length', 4) @@ -171,9 +171,9 @@ context('Vessel sidebar logbook tab', () => { .its('response.url') .should( 'have.string', - '/bff/v1/vessels/positions?internalReferenceNumber=FAK000999999' + - '&externalReferenceNumber=DONTSINK&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER' + - '&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=' + encodeURIComponent('/bff/v1/vessels/positions?&afterDateTime=&beforeDateTime=' + + '&externalReferenceNumber=DONTSINK&internalReferenceNumber=FAK000999999' + + '&IRCS=CALLME&trackDepth=TWELVE_HOURS&vesselIdentifier=INTERNAL_REFERENCE_NUMBER') ) cy.get('*[data-cy^="fishing-activity-name"]').should('not.exist') // Go back to the default track depth diff --git a/frontend/cypress/e2e/main_window/vessel_sidebar/offline_management.spec.ts b/frontend/cypress/e2e/main_window/vessel_sidebar/offline_management.spec.ts index c452fc1d81..2af0fc5d8c 100644 --- a/frontend/cypress/e2e/main_window/vessel_sidebar/offline_management.spec.ts +++ b/frontend/cypress/e2e/main_window/vessel_sidebar/offline_management.spec.ts @@ -13,8 +13,9 @@ context('Offline management', () => { // Given cy.intercept( 'GET', - 'bff/v1/vessels/find?vesselId=1&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=', + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS' + + '&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', { statusCode: 400 } ).as('openVessel') openVesselBySearch('Pheno') @@ -82,8 +83,9 @@ context('Offline management', () => { { method: 'GET', path: - '/bff/v1/vessels/find?vesselId=1&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=', + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS' + + '&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', times: 2 }, { statusCode: 400 } @@ -96,8 +98,9 @@ context('Offline management', () => { cy.get('*[data-cy="vessel-sidebar-error"]').contains("Nous n'avons pas pu récupérer les informations du navire") cy.intercept( 'GET', - 'bff/v1/vessels/find?vesselId=1&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=' + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS' + + '&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', ).as('openVessel') cy.clickButton('Réessayer') cy.wait('@openVessel') @@ -105,8 +108,9 @@ context('Offline management', () => { // When clicking on Resume tab cy.intercept( - 'bff/v1/vessels/find?vesselId=1&internalReferenceNumber=FAK000999999&externalReferenceNumber=DONTSINK' + - '&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=', + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=DONTSINK' + + '&internalReferenceNumber=FAK000999999&IRCS=CALLME&trackDepth=TWELVE_HOURS' + + '&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER', cy.spy().as('openVesselSpyed') ) cy.get('*[data-cy="vessel-menu-summary"').click() diff --git a/frontend/cypress/e2e/side_window/beacon_malfunction/board.spec.ts b/frontend/cypress/e2e/side_window/beacon_malfunction/board.spec.ts index c82f66b49b..640431ea7f 100644 --- a/frontend/cypress/e2e/side_window/beacon_malfunction/board.spec.ts +++ b/frontend/cypress/e2e/side_window/beacon_malfunction/board.spec.ts @@ -238,11 +238,11 @@ context('Side Window > Beacon Malfunction Board', () => { cy.intercept( 'GET', new RegExp( - `bff\\/v1\\/vessels\\/find\\?vesselId=1&internalReferenceNumber=FAK000999999` + - `&externalReferenceNumber=DONTSINK&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER` + - `&trackDepth=CUSTOM` + - `&afterDateTime=${oneWeeksBeforeDate.format('YYYY-MM-DD')}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z` + - `&beforeDateTime=${oneWeeksBeforePlusOneDayDate.format('YYYY-MM-DD')}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z` + `bff\\/v1\\/vessels\\/find\\?` + + `&afterDateTime=${oneWeeksBeforeDate.format('YYYY-MM-DD')}T\\d{2}%3A\\d{2}%3A\\d{2}\\.\\d{3}Z` + + `&beforeDateTime=${oneWeeksBeforePlusOneDayDate.format('YYYY-MM-DD')}T\\d{2}%3A\\d{2}%3A\\d{2}\\.\\d{3}Z` + + `&externalReferenceNumber=DONTSINK&internalReferenceNumber=FAK000999999` + + `&IRCS=CALLME&trackDepth=CUSTOM&vesselId=1&vesselIdentifier=INTERNAL_REFERENCE_NUMBER` ) ).as('showVesselPositionsOnMap') cy.get('*[data-cy="side-window-beacon-malfunctions-detail-show-vessel"]').click() diff --git a/frontend/cypress/e2e/side_window/manual_prior_notification_form/form.spec.ts b/frontend/cypress/e2e/side_window/manual_prior_notification_form/form.spec.ts index 58ae31596b..cbef9c5cc4 100644 --- a/frontend/cypress/e2e/side_window/manual_prior_notification_form/form.spec.ts +++ b/frontend/cypress/e2e/side_window/manual_prior_notification_form/form.spec.ts @@ -276,7 +276,7 @@ context('Side Window > Manual Prior Notification Form > Form', () => { cy.contains('Créer le préavis').should('be.enabled') }) - it('Should calculate and display manual prior notification fleet segments, risk factor & schemas', () => { + it('Should calculate and display manual prior notification fleet segments, risk factor & types', () => { // ------------------------------------------------------------------------- // Add @@ -402,7 +402,7 @@ context('Side Window > Manual Prior Notification Form > Form', () => { }) }) - it('Should only recalculate manual prior notification fleet segments, risk factor & schemas when necessary (creation)', () => { + it('Should only recalculate manual prior notification fleet segments, risk factor & types when necessary (creation)', () => { cy.intercept('POST', '/bff/v1/prior_notifications/manual/compute').as('computePriorNotification') cy.resetCountRequestsByAlias('@computePriorNotification') @@ -446,7 +446,7 @@ context('Side Window > Manual Prior Notification Form > Form', () => { cy.countRequestsByAlias('@computePriorNotification', 1500).should('be.equal', 1) }) - it('Should only recalculate manual prior notification fleet segments, risk factor & schemas when necessary (edition)', () => { + it('Should only recalculate manual prior notification fleet segments, risk factor & types when necessary (edition)', () => { cy.intercept('POST', '/bff/v1/prior_notifications/manual/compute').as('computePriorNotification') cy.resetCountRequestsByAlias('@computePriorNotification') diff --git a/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts b/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts index 68511ef6fb..c0c129a32e 100644 --- a/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/sea_control.spec.ts @@ -92,13 +92,9 @@ context('Side Window > Mission Form > Sea Control', () => { cy.intercept( 'GET', - '/bff/v1/vessels/find?vesselId=2&' + - 'internalReferenceNumber=U_W0NTFINDME&' + - 'externalReferenceNumber=TALK2ME&' + - 'IRCS=QGDF&' + - 'vesselIdentifier=&' + - 'trackDepth=TWELVE_HOURS&' + - 'afterDateTime=&beforeDateTime=' + 'bff/v1/vessels/find?afterDateTime=&beforeDateTime=&externalReferenceNumber=TALK2ME' + + '&internalReferenceNumber=U_W0NTFINDME&IRCS=QGDF&trackDepth=TWELVE_HOURS' + + '&vesselId=2&vesselIdentifier=', ).as('showVessel') cy.get('a:contains("Voir la fiche")').click() cy.wait('@showVessel') diff --git a/frontend/cypress/e2e/side_window/prior_notification_list/filter_bar.spec.ts b/frontend/cypress/e2e/side_window/prior_notification_list/filter_bar.spec.ts index 38bf8abd91..2f054fb3bb 100644 --- a/frontend/cypress/e2e/side_window/prior_notification_list/filter_bar.spec.ts +++ b/frontend/cypress/e2e/side_window/prior_notification_list/filter_bar.spec.ts @@ -227,7 +227,7 @@ context('Side Window > Prior Notification List > VesselFilter Bar', () => { cy.get('.Table-SimpleTable tr').should('have.length.to.be.greaterThan', 0) }) - it('Should filter prior notifications by schemas', () => { + it('Should filter prior notifications by types', () => { openSideWindowPriorNotificationListAsSuperUser() cy.intercept('GET', `${apiPathBase}*priorNotificationTypes=${encodeURI('Préavis type A,Préavis type C')}*`).as( diff --git a/frontend/src/api/alert.ts b/frontend/src/api/alert.ts index 9957a3af85..839bbba069 100644 --- a/frontend/src/api/alert.ts +++ b/frontend/src/api/alert.ts @@ -56,8 +56,7 @@ export const alertApi = monitorfishApi.injectEndpoints({ }), getSilencedAlerts: builder.query({ query: () => '/operational_alerts/silenced', - transformErrorResponse: response => new FrontendApiError(ALERTS_ERROR_MESSAGE, response), - transformResponse: (response: SilencedAlert[]) => response + transformErrorResponse: response => new FrontendApiError(ALERTS_ERROR_MESSAGE, response) }), silenceAlert: builder.mutation< LEGACY_SilencedAlert, @@ -71,8 +70,7 @@ export const alertApi = monitorfishApi.injectEndpoints({ method: 'PUT', url: `/operational_alerts/${id}/silence` }), - transformErrorResponse: response => new FrontendApiError(SILENCE_ALERT_ERROR_MESSAGE, response), - transformResponse: (response: SilencedAlert) => response + transformErrorResponse: response => new FrontendApiError(SILENCE_ALERT_ERROR_MESSAGE, response) }), validateAlert: builder.mutation({ query: id => ({ diff --git a/frontend/src/api/api.ts b/frontend/src/api/api.ts index e7afc6dbd4..a8f854dafb 100644 --- a/frontend/src/api/api.ts +++ b/frontend/src/api/api.ts @@ -108,7 +108,7 @@ export const monitorfishApi = createApi({ if (result.error) { const error: CustomResponseError = { - path: typeof args === 'string' ? args : args.url, + path: `/bff/v1${typeof args === 'string' ? args : args.url}`, requestData: typeof args === 'string' ? undefined : args.body, responseData: result.error.data as BackendApi.ResponseBodyError, status: result.error.status diff --git a/frontend/src/domain/entities/vessel/types.ts b/frontend/src/domain/entities/vessel/types.ts index b62e166a90..7082a1136c 100644 --- a/frontend/src/domain/entities/vessel/types.ts +++ b/frontend/src/domain/entities/vessel/types.ts @@ -1,4 +1,4 @@ -// TODO This should be moved to `entities/vessel/mission.schemas.ts` +// TODO This should be moved to `entities/vessel/mission.types.ts` import type { VesselTrackDepth } from '../vesselTrackDepth' import type { SelectableVesselTrackDepth } from '@features/Vessel/components/VesselSidebar/actions/TrackRequest/types' diff --git a/frontend/src/domain/types/GeoJSON.ts b/frontend/src/domain/types/GeoJSON.ts index 0c2bd70767..eca87aa15e 100644 --- a/frontend/src/domain/types/GeoJSON.ts +++ b/frontend/src/domain/types/GeoJSON.ts @@ -1,6 +1,6 @@ /** - * Typescript schemas for the GeoJSON RFC7946 specification. This is not fully RFC-compliant due to lack of support for - * ranged number data schemas. + * Typescript types for the GeoJSON RFC7946 specification. This is not fully RFC-compliant due to lack of support for + * ranged number data types. * * See https://tools.ietf.org/html/rfc7946 */ @@ -13,13 +13,13 @@ export declare namespace GeoJSON { export type GeometryType = Geometry['type'] /** - * ...the term "GeoJSON schemas" refers to nine case-sensitive strings: "Feature", "FeatureCollection", and the - * geometry schemas listed above. + * ...the term "GeoJSON types" refers to nine case-sensitive strings: "Feature", "FeatureCollection", and the + * geometry types listed above. */ export type GeoJson = Geometry | Feature | FeatureCollection export type GeoJsonType = GeoJson['type'] - // schemas + // types /** * A position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and @@ -34,7 +34,7 @@ export declare namespace GeoJSON { export type Record = { [key in string | number]: unknown } /** - * Properties inherit to all GeoJSON schemas + * Properties inherit to all GeoJSON types */ export interface GeometryBase extends Record { /** @@ -55,7 +55,7 @@ export declare namespace GeoJSON { */ } - // geometry schemas + // geometry types export interface Point extends GeometryBase { /** @@ -132,7 +132,7 @@ export declare namespace GeoJSON { type: 'GeometryCollection' } - // GeoJSON schemas + // GeoJSON types export interface Feature { /** diff --git a/frontend/src/features/BeaconMalfunction/useCases/getVesselBeaconMalfunctions.ts b/frontend/src/features/BeaconMalfunction/useCases/getVesselBeaconMalfunctions.ts index 06c65b0894..bfb0f9bb01 100644 --- a/frontend/src/features/BeaconMalfunction/useCases/getVesselBeaconMalfunctions.ts +++ b/frontend/src/features/BeaconMalfunction/useCases/getVesselBeaconMalfunctions.ts @@ -36,7 +36,7 @@ export const getVesselBeaconMalfunctions = (isFromUserAction: boolean) => async { fromDate: vesselBeaconMalfunctionsFromDate, vesselId: selectedVessel.vesselId }, RTK_FORCE_REFETCH_QUERY_OPTIONS ) - )().unwrap() + ).unwrap() dispatch( setVesselBeaconMalfunctionsResumeAndHistory({ diff --git a/frontend/src/features/PriorNotification/priorNotificationApi.ts b/frontend/src/features/PriorNotification/priorNotificationApi.ts index 6889f78254..e7bc4c0501 100644 --- a/frontend/src/features/PriorNotification/priorNotificationApi.ts +++ b/frontend/src/features/PriorNotification/priorNotificationApi.ts @@ -11,7 +11,7 @@ import type { ListFilter } from './components/PriorNotificationList/types' import type { Logbook } from '@features/Logbook/Logbook.types' const COMPUTE_PRIOR_NOTIFICATION_ERROR_MESSAGE = - "Nous n'avons pas pu calculer note de risque, segments ou schemas pour ce préavis." + "Nous n'avons pas pu calculer note de risque, segments ou types pour ce préavis." const CREATE_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu créé le préavis." const DELETE_PRIOR_NOTIFICATION_UPLOAD_ERROR_MESSAGE = "Nous n'avons pas pu supprimer ce document attaché." const GET_PRIOR_NOTIFICATION_UPLOADS_ERROR_MESSAGE = @@ -21,7 +21,7 @@ const GET_PRIOR_NOTIFICATION_SENT_MESSAGES_ERROR_MESSAGE = const UPDATE_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu modifier le préavis." const GET_PRIOR_NOTIFICATION_DETAIL_ERROR_MESSAGE = "Nous n'avons pas pu récupérer le préavis." const GET_PRIOR_NOTIFICATIONS_ERROR_MESSAGE = "Nous n'avons pas pu récupérer la liste des préavis." -const GET_PRIOR_NOTIFICATION_TYPES_ERROR_MESSAGE = "Nous n'avons pas pu récupérer la liste des schemas de préavis." +const GET_PRIOR_NOTIFICATION_TYPES_ERROR_MESSAGE = "Nous n'avons pas pu récupérer la liste des types de préavis." const GET_PRIOR_NOTIFICATION_PDF_ERROR_MESSAGE = "Nous n'avons pas pu récupérer le PDF du préavis." const VERIFY_AND_SEND_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu vérifier et envoyer le préavis." const INVALIDATE_PRIOR_NOTIFICATION_ERROR_MESSAGE = "Nous n'avons pas pu invalider et envoyer le préavis." @@ -139,7 +139,7 @@ export const priorNotificationApi = monitorfishApi.injectEndpoints({ getPriorNotificationTypes: builder.query({ providesTags: () => [{ type: RtkCacheTagType.PriorNotificationTypes }], - query: () => '/prior_notifications/schemas', + query: () => '/prior_notifications/types', transformErrorResponse: response => new FrontendApiError(GET_PRIOR_NOTIFICATION_TYPES_ERROR_MESSAGE, response) }), diff --git a/frontend/src/features/Regulation/slice.ts b/frontend/src/features/Regulation/slice.ts index 4e49d62ccf..7fe4fb7966 100644 --- a/frontend/src/features/Regulation/slice.ts +++ b/frontend/src/features/Regulation/slice.ts @@ -392,7 +392,7 @@ const regulationSlice = createSlice({ } }, - // TODO Fix these schemas and find a cleaner way to achieve that. Proposal: pass a partial `RegulatoryZoneDraft` as param and use a "deepMerge" function. + // TODO Fix these types and find a cleaner way to achieve that. Proposal: pass a partial `RegulatoryZoneDraft` as param and use a "deepMerge" function. updateProcessingRegulationByKeyAndSubKey( state, action: PayloadAction<{ diff --git a/frontend/src/features/Regulation/types.ts b/frontend/src/features/Regulation/types.ts index 3e69750847..803f7bb357 100644 --- a/frontend/src/features/Regulation/types.ts +++ b/frontend/src/features/Regulation/types.ts @@ -55,7 +55,7 @@ export type TimeInterval = { to: Date | undefined } -// TODO It would be safer to use strict array schemas: `DateRange[]` and `DateAsStringRange[]`. +// TODO It would be safer to use strict array types: `DateRange[]` and `DateAsStringRange[]`. export type FishingPeriod = { always: boolean | undefined annualRecurrence: boolean | undefined diff --git a/frontend/src/features/Reporting/types.ts b/frontend/src/features/Reporting/types.ts index fa00f78256..8a8eeec0a5 100644 --- a/frontend/src/features/Reporting/types.ts +++ b/frontend/src/features/Reporting/types.ts @@ -7,7 +7,7 @@ import type { Infraction } from '../../domain/types/infraction' import type { PendingAlertValue } from '../Alert/types' import type { LegacyControlUnit } from '../ControlUnit/legacyControlUnit' -// TODO Move other schemas into new `Reporting` namespace. +// TODO Move other types into new `Reporting` namespace. export namespace Reporting { export type Reporting = InfractionSuspicionReporting | ObservationReporting | PendingAlertReporting export type EditableReporting = InfractionSuspicionReporting | ObservationReporting @@ -125,7 +125,7 @@ export type Observation = { } type ReportingTypeCharacteristic = { - // TODO It should be useless now that schemas are discriminated. + // TODO It should be useless now that types are discriminated. code: ReportingType displayName: string // TODO This should be named differently to avoid confusion with `ReportingType.INFRACTION_SUSPICION` type. diff --git a/frontend/src/features/Vessel/Vessel.types.ts b/frontend/src/features/Vessel/Vessel.types.ts index 703de3efc3..561f2dd739 100644 --- a/frontend/src/features/Vessel/Vessel.types.ts +++ b/frontend/src/features/Vessel/Vessel.types.ts @@ -4,6 +4,7 @@ import { numberOrUndefined, stringOrUndefined } from '../../types' import type { ProducerOrganizationMembership } from '@features/ProducerOrganizationMembership/types' import type { RiskFactor } from '@features/RiskFactor/types' +import type { VesselLastPositionLightSchema } from '@features/Vessel/schemas/VesselLastPositionLightSchema' import type { VesselLastPositionSchema } from '@features/Vessel/schemas/VesselLastPositionSchema' import type Feature from 'ol/Feature' import type LineString from 'ol/geom/LineString' @@ -155,6 +156,7 @@ export namespace Vessel { export type DeclaredLogbookSpecies = z.infer export type VesselLastPosition = z.infer + export type VesselLightLastPosition = z.infer export type VesselPosition = { course: number diff --git a/frontend/src/features/Vessel/components/VesselLoader.tsx b/frontend/src/features/Vessel/components/VesselLoader.tsx index 3c49b3c53e..32edc64857 100644 --- a/frontend/src/features/Vessel/components/VesselLoader.tsx +++ b/frontend/src/features/Vessel/components/VesselLoader.tsx @@ -1,14 +1,15 @@ import { FIVE_MINUTES, TWENTY_MINUTES } from '@api/APIWorker' import { FulfillingBouncingCircleSpinner } from '@components/FulfillingBouncingCircleSpinner' import { showVesselsLastPosition } from '@features/Vessel/useCases/showVesselsLastPosition' +import { Vessel } from '@features/Vessel/Vessel.types' import { useIsInLightMode } from '@hooks/useIsInLightMode' import { useMainAppDispatch } from '@hooks/useMainAppDispatch' import { useMainAppSelector } from '@hooks/useMainAppSelector' +import { THEME } from '@mtes-mct/monitor-ui' import { skipToken } from '@reduxjs/toolkit/query' import { useEffect, useState } from 'react' import styled from 'styled-components' -import { COLORS } from '../../../constants/constants' import { setError } from '../../../domain/shared_slices/Global' import { MapComponent } from '../../commonStyles/MapComponent' import VesselSVG from '../../icons/Icone_navire.svg?react' @@ -43,7 +44,8 @@ export function VesselLoader() { return } - dispatch(showVesselsLastPosition(vessels)) + // TODO include the VesselLightLastPosition type to the redux state + dispatch(showVesselsLastPosition(vessels as Vessel.VesselLastPosition[])) }, [dispatch, vessels, isError, error]) useEffect(() => { @@ -56,7 +58,7 @@ export function VesselLoader() { <> {!isAppLoaded && ( - + Chargement... @@ -64,8 +66,8 @@ export function VesselLoader() { {(isFetching || loadingPositions) && isAppLoaded && ( <> - - + + )} @@ -76,12 +78,12 @@ export function VesselLoader() { const Text = styled.span` margin-top: 10px; font-size: 13px; - color: ${COLORS.white}; + color: ${p => p.theme.color.white}; bottom: -17px; position: relative; ` -const Vessel = styled(VesselSVG)` +const VesselIcon = styled(VesselSVG)` position: absolute; top: 2px; left: 8px; diff --git a/frontend/src/features/Vessel/schemas/VesselLastPositionLightSchema.ts b/frontend/src/features/Vessel/schemas/VesselLastPositionLightSchema.ts new file mode 100644 index 0000000000..35914863c2 --- /dev/null +++ b/frontend/src/features/Vessel/schemas/VesselLastPositionLightSchema.ts @@ -0,0 +1,11 @@ +import { VesselLastPositionSchema } from '@features/Vessel/schemas/VesselLastPositionSchema' + +export const VesselLastPositionLightSchema = VesselLastPositionSchema.omit({ + alerts: true, + detectabilityRiskFactor: true, + impactRiskFactor: true, + postControlComment: true, + probabilityRiskFactor: true, + reportings: true, + riskFactor: true +}) diff --git a/frontend/src/features/Vessel/vesselApi.ts b/frontend/src/features/Vessel/vesselApi.ts index 2e54987614..9b1d15968e 100644 --- a/frontend/src/features/Vessel/vesselApi.ts +++ b/frontend/src/features/Vessel/vesselApi.ts @@ -85,7 +85,6 @@ export const vesselApi = monitorfishApi.injectEndpoints({ return { method: 'GET', - // Pass query parameters params: { afterDateTime, beforeDateTime, diff --git a/frontend/src/features/Vessel/vesselNavApi.ts b/frontend/src/features/Vessel/vesselNavApi.ts index b96691d722..aa6bad5944 100644 --- a/frontend/src/features/Vessel/vesselNavApi.ts +++ b/frontend/src/features/Vessel/vesselNavApi.ts @@ -1,13 +1,13 @@ import { monitorfishLightApi } from '@api/api' -import { VesselLastPositionSchema } from '@features/Vessel/schemas/VesselLastPositionSchema' +import { VesselLastPositionLightSchema } from '@features/Vessel/schemas/VesselLastPositionLightSchema' import { Vessel } from '@features/Vessel/Vessel.types' export const vesselNavApi = monitorfishLightApi.injectEndpoints({ endpoints: builder => ({ - getVesselsLastPositions: builder.query({ + getVesselsLastPositions: builder.query({ query: () => `/v1/vessels`, - transformResponse: (baseQueryReturnValue: Vessel.VesselLastPosition[]) => - baseQueryReturnValue.map(LastPosition => VesselLastPositionSchema.parse(LastPosition)) + transformResponse: (baseQueryReturnValue: Vessel.VesselLightLastPosition[]) => + baseQueryReturnValue.map(LastPosition => VesselLastPositionLightSchema.parse(LastPosition)) }) }) }) diff --git a/frontend/src/store/index.ts b/frontend/src/store/index.ts index df4d4bbca0..6a23f6c82a 100644 --- a/frontend/src/store/index.ts +++ b/frontend/src/store/index.ts @@ -55,7 +55,7 @@ setupListeners(mainStore.dispatch) export const mainStorePersistor = persistStore(mainStore) // https://react-redux.js.org/using-react-redux/usage-with-typescript#define-root-state-and-dispatch-types -// Infer the `MainRootState` and `AppDispatch` schemas from the store itself +// Infer the `MainRootState` and `AppDispatch` types from the store itself export type MainAppDispatch = typeof mainStore.dispatch export type MainAppGetState = () => MainRootState export type MainAppThunk = ThunkAction diff --git a/frontend/src/types.test.ts b/frontend/src/types.test.ts index 595e50c0ac..81bb58693b 100644 --- a/frontend/src/types.test.ts +++ b/frontend/src/types.test.ts @@ -24,7 +24,7 @@ describe('types', () => { /** * This test is required by jest to pass the error : "Your test suite must contain at least one test." * - * The actual tests are running when checkin TS schemas (by `npm run test:type`): + * The actual tests are running when checkin TS types (by `npm run test:type`): * - undefinableTestInterface * - undefinableTestInterfaceWithMissingProp */ diff --git a/frontend/src/utils/nullify.ts b/frontend/src/utils/nullify.ts index e115e2f018..bfedc57cb7 100644 --- a/frontend/src/utils/nullify.ts +++ b/frontend/src/utils/nullify.ts @@ -30,7 +30,7 @@ const nullifyObjectPropPair = ([key, value]: [string, NativeAny]) => [key, nulli * Transform all `undefined` values into `null` ones in any type of value * * @description - * The value must be of native type and only contains native schemas. + * The value must be of native type and only contains native types. */ export function nullify(value: T): Nullify | null { if (value === null || value === undefined) { diff --git a/frontend/src/utils/undefinedize.ts b/frontend/src/utils/undefinedize.ts index 1efff35753..42b8a6fb8d 100644 --- a/frontend/src/utils/undefinedize.ts +++ b/frontend/src/utils/undefinedize.ts @@ -31,7 +31,7 @@ const undefinedizeObjectPropPair = ([key, value]: [string, NativeAny]) => [key, * Transform all `null` values into `undefined` ones in any type of value * * @description - * The value must be of native type and only contains native schemas. + * The value must be of native type and only contains native types. */ export function undefinedize(value: T): Undefinedized | undefined { if (value === null || value === undefined) {