diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeSanctionEnum.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeResponseEnum.kt similarity index 78% rename from backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeSanctionEnum.kt rename to backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeResponseEnum.kt index 83116716e..89d224732 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeSanctionEnum.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/AdministrativeResponseEnum.kt @@ -1,6 +1,6 @@ package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction -enum class AdministrativeSanctionEnum { +enum class AdministrativeResponseEnum { SANCTION, REGULARIZATION, PENDING, diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionEntity.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionEntity.kt index 7a2004065..fdcacd687 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionEntity.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionEntity.kt @@ -4,14 +4,14 @@ import fr.gouv.cacem.monitorenv.domain.entities.VesselTypeEnum data class InfractionEntity( val id: String, - val administrativeSanction: AdministrativeSanctionEnum?, + val administrativeResponse: AdministrativeResponseEnum?, val natinf: List? = listOf(), val observations: String? = null, val registrationNumber: String? = null, val companyName: String? = null, val relevantCourt: String? = null, val imo: String? = null, - val legalSanction: LegalSanctionEnum, + val infractionType: InfractionTypeEnum, val formalNotice: FormalNoticeEnum, val mmsi: String? = null, val toProcess: Boolean, diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/LegalSanctionEnum.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionTypeEnum.kt similarity index 82% rename from backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/LegalSanctionEnum.kt rename to backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionTypeEnum.kt index dd66527f7..f0fd094d5 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/LegalSanctionEnum.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/domain/entities/mission/envAction/envActionControl/infraction/InfractionTypeEnum.kt @@ -1,6 +1,6 @@ package fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction -enum class LegalSanctionEnum { +enum class InfractionTypeEnum { WAITING, WITH_REPORT, WITHOUT_REPORT, diff --git a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/missions/MissionEnvActionControlInfractionDataInput.kt b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/missions/MissionEnvActionControlInfractionDataInput.kt index 1c3c49b95..fa8c018d9 100644 --- a/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/missions/MissionEnvActionControlInfractionDataInput.kt +++ b/backend/src/main/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/adapters/bff/inputs/missions/MissionEnvActionControlInfractionDataInput.kt @@ -1,19 +1,19 @@ package fr.gouv.cacem.monitorenv.infrastructure.api.adapters.bff.inputs.missions import fr.gouv.cacem.monitorenv.domain.entities.VesselTypeEnum -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeResponseEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.FormalNoticeEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionEntity -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.LegalSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionTypeEnum data class MissionEnvActionControlInfractionDataInput( val id: String, - val administrativeSanction: AdministrativeSanctionEnum, + val administrativeResponse: AdministrativeResponseEnum, val companyName: String? = null, val controlledPersonIdentity: String? = null, val formalNotice: FormalNoticeEnum, val imo: String? = null, - val legalSanction: LegalSanctionEnum, + val infractionType: InfractionTypeEnum, val mmsi: String? = null, val natinf: List? = listOf(), val observations: String? = null, @@ -27,12 +27,12 @@ data class MissionEnvActionControlInfractionDataInput( fun toInfractionEntity() = InfractionEntity( id = id, - administrativeSanction = administrativeSanction, + administrativeResponse = administrativeResponse, companyName = companyName, controlledPersonIdentity = controlledPersonIdentity, formalNotice = formalNotice, imo = imo, - legalSanction = legalSanction, + infractionType = infractionType, mmsi = mmsi, natinf = natinf, observations = observations, diff --git a/backend/src/main/resources/db/migration/internal/V0.142__rename_infractionType_to_legalSanction.sql b/backend/src/main/resources/db/migration/internal/V0.142__rename_infractionType_to_legalSanction.sql deleted file mode 100644 index c9e7e2048..000000000 --- a/backend/src/main/resources/db/migration/internal/V0.142__rename_infractionType_to_legalSanction.sql +++ /dev/null @@ -1,44 +0,0 @@ -BEGIN; - --- Étape 1: Vérifier que "items" contient un tableau et extraire les objets du tableau -WITH decomposed AS (SELECT id, - jsonb_array_elements(value -> 'infractions') AS obj, - value - 'infractions' AS data_without_items - FROM env_actions - WHERE jsonb_typeof(value -> 'infractions') = 'array'), - --- Étape 2: Modifier chaque objet JSON en remplaçant la clé - updated AS (SELECT id, - obj || - jsonb_build_object('legalSanction', obj -> 'infractionType') - 'infractionType' AS updated_obj, - data_without_items - FROM decomposed), - --- Étape 3: Recomposer les objets modifiés en un nouveau tableau - recomposed AS (SELECT id, - jsonb_agg(updated_obj) AS new_items, - data_without_items - FROM updated - GROUP BY id, data_without_items), - --- Étape 4: Inclure les lignes avec des tableaux vides - original_with_empty AS (SELECT id, - value - FROM env_actions - WHERE jsonb_typeof(value -> 'infractions') = 'array' - AND jsonb_array_length(value -> 'infractions') = 0), - --- Étape 5: Mettre à jour la table avec les nouveaux objets - final_update AS (SELECT recomposed.id, - data_without_items || jsonb_build_object('infractions', new_items) AS new_data - FROM recomposed - UNION ALL - SELECT original_with_empty.id, - original_with_empty.value - FROM original_with_empty) -UPDATE env_actions -SET value = final_update.new_data -FROM final_update -WHERE env_actions.id = final_update.id; - -COMMIT; diff --git a/backend/src/main/resources/db/testdata/V666.10__insert_dummy_env_actions.sql b/backend/src/main/resources/db/testdata/V666.10__insert_dummy_env_actions.sql index 7cbc637e4..f6343c4a8 100644 --- a/backend/src/main/resources/db/testdata/V666.10__insert_dummy_env_actions.sql +++ b/backend/src/main/resources/db/testdata/V666.10__insert_dummy_env_actions.sql @@ -48,7 +48,7 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{ "observations": "RAS", "relevantCourt": "LOCAL_COURT", "infractionType": "WITH_REPORT", - "administrativeSanction": "REGULARIZATION", + "administrativeResponse": "REGULARIZATION", "registrationNumber": null, "controlledPersonIdentity": null } @@ -103,7 +103,7 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{ "observations": "RAS", "relevantCourt": "PRE", "infractionType": "WAITING", - "administrativeSanction": "PENDING", + "administrativeResponse": "PENDING", "registrationNumber": null, "controlledPersonIdentity": "M DURAND" } @@ -168,7 +168,7 @@ VALUES ('e2257638-ddef-4611-960c-7675a3254c38', 38, 'SURVEILLANCE', '{ "observations": "Pas d''observations", "relevantCourt": "LOCAL_COURT", "infractionType": "WITH_REPORT", - "administrativeSanction": "PENDING", + "administrativeResponse": "PENDING", "registrationNumber": "BALTIK", "controlledPersonIdentity": "John Doe" } diff --git a/backend/src/main/resources/db/testdata/V666.17__rename_infractionType_to_legalSanction.sql b/backend/src/main/resources/db/testdata/V666.17__rename_infractionType_to_legalSanction.sql deleted file mode 100644 index c47d5a21b..000000000 --- a/backend/src/main/resources/db/testdata/V666.17__rename_infractionType_to_legalSanction.sql +++ /dev/null @@ -1,44 +0,0 @@ -BEGIN; - --- Étape 1: Vérifier que "items" contient un tableau et extraire les objets du tableau -WITH decomposed AS (SELECT id, - jsonb_array_elements(value -> 'infractions') AS obj, - value - 'infractions' AS value_without_infractions - FROM env_actions - WHERE jsonb_typeof(value -> 'infractions') = 'array'), - --- Étape 2: Modifier chaque objet JSON en remplaçant la clé - updated AS (SELECT id, - obj || - jsonb_build_object('legalSanction', obj -> 'infractionType') - 'infractionType' AS updated_obj, - value_without_infractions - FROM decomposed), - --- Étape 3: Recomposer les objets modifiés en un nouveau tableau - recomposed AS (SELECT id, - jsonb_agg(updated_obj) AS new_items, - value_without_infractions - FROM updated - GROUP BY id, value_without_infractions), - --- Étape 4: Inclure les lignes avec des tableaux vides - original_with_empty AS (SELECT id, - value - FROM env_actions - WHERE jsonb_typeof(value -> 'infractions') = 'array' - AND jsonb_array_length(value -> 'infractions') = 0), - --- Étape 5: Mettre à jour la table avec les nouveaux objets - final_update AS (SELECT recomposed.id, - value_without_infractions || jsonb_build_object('infractions', new_items) AS new_data - FROM recomposed - UNION ALL - SELECT original_with_empty.id, - original_with_empty.value - FROM original_with_empty) -UPDATE env_actions -SET value = final_update.new_data -FROM final_update -WHERE env_actions.id = final_update.id; - -COMMIT; diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt index dd68380dc..1e8c1054e 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/MissionsITests.kt @@ -16,7 +16,7 @@ import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionContr import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.ActionTargetTypeEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.EnvActionControlEntity import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.FormalNoticeEnum -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.LegalSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionTypeEnum import fr.gouv.cacem.monitorenv.domain.entities.reporting.ReportingEntity import fr.gouv.cacem.monitorenv.domain.entities.reporting.ReportingTypeEnum import fr.gouv.cacem.monitorenv.domain.entities.reporting.SourceTypeEnum @@ -447,8 +447,8 @@ class MissionsITests { ) .andExpect( jsonPath( - "$[0].envActions[0].infractions[0].legalSanction", - equalTo(LegalSanctionEnum.WAITING.toString()), + "$[0].envActions[0].infractions[0].infractionType", + equalTo(InfractionTypeEnum.WAITING.toString()), ), ) .andExpect( @@ -738,8 +738,8 @@ class MissionsITests { ) .andExpect( jsonPath( - "$.envActions[0].infractions[0].legalSanction", - equalTo(LegalSanctionEnum.WAITING.toString()), + "$.envActions[0].infractions[0].infractionType", + equalTo(InfractionTypeEnum.WAITING.toString()), ), ) .andExpect( diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/TestUtils.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/TestUtils.kt index 23e65a24a..debfb82d9 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/TestUtils.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/api/endpoints/bff/TestUtils.kt @@ -1,10 +1,10 @@ package fr.gouv.cacem.monitorenv.infrastructure.api.endpoints.bff import fr.gouv.cacem.monitorenv.domain.entities.VesselTypeEnum -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeResponseEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.FormalNoticeEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionEntity -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.LegalSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionTypeEnum class TestUtils { companion object { @@ -12,13 +12,13 @@ class TestUtils { return listOf( InfractionEntity( id = "d0f5f3a0-0b1a-4b0e-9b0a-0b0b0b0b0b0b", - administrativeSanction = AdministrativeSanctionEnum.SANCTION, + administrativeResponse = AdministrativeResponseEnum.SANCTION, natinf = listOf("27001"), observations = "Observations de l'infraction", registrationNumber = "AB-123-CD", companyName = "Company Name", relevantCourt = "LOCAL_COURT", - legalSanction = LegalSanctionEnum.WAITING, + infractionType = InfractionTypeEnum.WAITING, formalNotice = FormalNoticeEnum.NO, toProcess = false, controlledPersonIdentity = "Captain Flame", diff --git a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaMissionRepositoryITests.kt b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaMissionRepositoryITests.kt index c54145f23..296c2f27d 100644 --- a/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaMissionRepositoryITests.kt +++ b/backend/src/test/kotlin/fr/gouv/cacem/monitorenv/infrastructure/database/repositories/JpaMissionRepositoryITests.kt @@ -15,10 +15,10 @@ import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionNoteE import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.EnvActionSurveillanceEntity import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.ActionTargetTypeEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.EnvActionControlEntity -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.AdministrativeResponseEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.FormalNoticeEnum import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionEntity -import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.LegalSanctionEnum +import fr.gouv.cacem.monitorenv.domain.entities.mission.envAction.envActionControl.infraction.InfractionTypeEnum import fr.gouv.cacem.monitorenv.domain.use_cases.missions.dtos.MissionDTO import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable @@ -854,13 +854,13 @@ class JpaMissionRepositoryITests : AbstractDBTests() { val infraction = InfractionEntity( id = "a4d8cd64-ee6e-4dba-ae5d-f6a41395b52a", - administrativeSanction = AdministrativeSanctionEnum.SANCTION, + administrativeResponse = AdministrativeResponseEnum.SANCTION, natinf = listOf("53432"), observations = "This is an infraction", registrationNumber = "REGISTRATION NUM", companyName = "ACME inc.", relevantCourt = "MARITIME_COURT", - legalSanction = LegalSanctionEnum.WITHOUT_REPORT, + infractionType = InfractionTypeEnum.WITHOUT_REPORT, formalNotice = FormalNoticeEnum.NO, toProcess = false, controlledPersonIdentity = "Dick Hoover", diff --git a/frontend/cypress/e2e/side_window/mission_form/attach_actions_to_reportings_in_mission.spec.ts b/frontend/cypress/e2e/side_window/mission_form/attach_actions_to_reportings_in_mission.spec.ts index 4b88c60bb..f04bec3ea 100644 --- a/frontend/cypress/e2e/side_window/mission_form/attach_actions_to_reportings_in_mission.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/attach_actions_to_reportings_in_mission.spec.ts @@ -194,8 +194,8 @@ context('Side Window > Mission Form > Attach action to reporting', () => { cy.getDataCy('infraction-form-controlledPersonIdentity').should('have.value', 'Capitaine Crochet') cy.getDataCy('infraction-form-vesselName').should('have.value', 'Le Bateau 2000') cy.getDataCy('infraction-form-vessel-size').should('have.value', 13) - cy.fill('Sanction judiciaire', 'Avec PV') - cy.fill('Sanction administrative', 'Sanction') + cy.fill("Type d'infraction", 'Avec PV') + cy.fill('Réponse administrative', 'Sanction') cy.fill('Mise en demeure', 'En attente') cy.fill('NATINF', ["1508 - Execution d'un travail dissimule"]) @@ -231,9 +231,9 @@ context('Side Window > Mission Form > Attach action to reporting', () => { cy.get('*[data-cy="envaction-theme-element"]').contains('Remise en état après occupation du DPM') cy.getDataCy('infraction-form-registrationNumber').should('have.value', '987654321') cy.getDataCy('infraction-form-vesselName').should('have.value', 'The Boat') - cy.get('.Field-MultiRadio').contains('Sanction judiciaire').get('[aria-checked="true"]').contains('Avec PV') + cy.get('.Field-MultiRadio').contains("Type d'infraction").get('[aria-checked="true"]').contains('Avec PV') cy.get('.Field-MultiRadio') - .contains('Sanction administrative') + .contains('Réponse administrative') .get('[aria-checked="true"]') .contains('Sanction') cy.get('.Field-MultiRadio').contains('Mise en demeure').get('[aria-checked="true"]').contains('En attente') diff --git a/frontend/cypress/e2e/side_window/mission_form/delete_mission.spec.ts b/frontend/cypress/e2e/side_window/mission_form/delete_mission.spec.ts index 3f0948ec2..6d9e917c5 100644 --- a/frontend/cypress/e2e/side_window/mission_form/delete_mission.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/delete_mission.spec.ts @@ -99,8 +99,8 @@ context('Side Window > Mission Form > Delete Mission', () => { cy.intercept('PUT', `/bff/v1/missions/${missionId}`).as('updateMission') cy.clickButton('Editer') - cy.fill('Sanction judiciaire', 'Avec PV') - cy.fill('Sanction administrative', 'Sanction') + cy.fill("Type d'infraction", 'Avec PV') + cy.fill('Réponse administrative', 'Sanction') cy.fill('Mise en demeure', 'Oui') cy.fill('NATINF', ["1508 - Execution d'un travail dissimule"]) diff --git a/frontend/cypress/e2e/side_window/mission_form/mission_actions.spec.ts b/frontend/cypress/e2e/side_window/mission_form/mission_actions.spec.ts index 9f79a91ed..346ae169f 100644 --- a/frontend/cypress/e2e/side_window/mission_form/mission_actions.spec.ts +++ b/frontend/cypress/e2e/side_window/mission_form/mission_actions.spec.ts @@ -39,8 +39,8 @@ context('Side Window > Mission Form > Mission actions', () => { expect(duplicatedInfraction.controlledPersonIdentity).equal('John Doe') expect(duplicatedInfraction.formalNotice).equal('PENDING') - expect(duplicatedInfraction.administrativeSanction).equal('PENDING') - expect(duplicatedInfraction.legalSanction).equal('WITH_REPORT') + expect(duplicatedInfraction.administrativeResponse).equal('PENDING') + expect(duplicatedInfraction.infractionType).equal('WITH_REPORT') expect(duplicatedInfraction.natinf.length).equal(2) expect(duplicatedInfraction.observations).equal("Pas d'observations") expect(duplicatedInfraction.registrationNumber).equal('BALTIK') @@ -78,13 +78,13 @@ context('Side Window > Mission Form > Mission actions', () => { cy.get('*[data-cy="envaction-theme-element"]').contains('Oiseaux').click({ force: true }) // id 11 cy.get('*[data-cy="envaction-theme-element"]').click('topLeft', { force: true }) - /* + /* TODO: fix this command in monitor-ui cy.fill( 'Sous-thématiques de contrôle', ["Destruction, capture, arrachage d'espèces protégées", 'Détention des espèces protégées'], // id 117 and 120 { delay: 250 } - ) + ) cy.fill('Précisions sur la thématique', ['Habitat', 'Oiseaux'], { delay: 250 }) // id 15 and 11 */ cy.get('*[data-cy="envaction-add-theme"]').should('not.exist') @@ -511,8 +511,8 @@ context('Side Window > Mission Form > Mission actions', () => { cy.fill('Immatriculation', 'ABC123') cy.fill('Taille', 45) cy.fill('Type de navire', 'Commerce') - cy.fill('Sanction judiciaire', 'Avec PV') - cy.fill('Sanction administrative', 'Sanction') + cy.fill("Type d'infraction", 'Avec PV') + cy.fill('Réponse administrative', 'Sanction') cy.fill('Mise en demeure', 'Oui') cy.fill('NATINF', ["1508 - Execution d'un travail dissimule"]) @@ -529,8 +529,8 @@ context('Side Window > Mission Form > Mission actions', () => { expect(requestInfraction.registrationNumber).equal('ABC123') expect(requestInfraction.vesselSize).equal(45) expect(requestInfraction.vesselType).equal('COMMERCIAL') - expect(requestInfraction.legalSanction).equal('WITH_REPORT') - expect(requestInfraction.administrativeSanction).equal('SANCTION') + expect(requestInfraction.infractionType).equal('WITH_REPORT') + expect(requestInfraction.administrativeResponse).equal('SANCTION') expect(requestInfraction.formalNotice).equal('YES') expect(requestInfraction.natinf).to.deep.equal(['1508']) @@ -544,8 +544,8 @@ context('Side Window > Mission Form > Mission actions', () => { expect(responseInfraction.registrationNumber).equal('ABC123') expect(responseInfraction.vesselSize).equal(45) expect(responseInfraction.vesselType).equal('COMMERCIAL') - expect(requestInfraction.legalSanction).equal('WITH_REPORT') - expect(requestInfraction.administrativeSanction).equal('SANCTION') + expect(requestInfraction.infractionType).equal('WITH_REPORT') + expect(requestInfraction.administrativeResponse).equal('SANCTION') expect(requestInfraction.formalNotice).equal('YES') expect(requestInfraction.natinf).to.deep.equal(['1508']) @@ -574,8 +574,8 @@ context('Side Window > Mission Form > Mission actions', () => { cy.fill('Type de cible', 'Personne morale') cy.clickButton('+ Ajouter un contrôle avec infraction') // Fill mandatory fields - cy.fill('Sanction judiciaire', 'Avec PV') - cy.fill('Sanction administrative', 'Sanction') + cy.fill("Type d'infraction", 'Avec PV') + cy.fill('Réponse administrative', 'Sanction') cy.fill('Mise en demeure', 'Oui') cy.fill('NATINF', ["1508 - Execution d'un travail dissimule"]) cy.clickButton("Valider l'infraction") diff --git a/frontend/src/domain/entities/missions.ts b/frontend/src/domain/entities/missions.ts index d8716b1a0..32bd66824 100644 --- a/frontend/src/domain/entities/missions.ts +++ b/frontend/src/domain/entities/missions.ts @@ -1,4 +1,4 @@ -import { THEME, customDayjs } from '@mtes-mct/monitor-ui' +import { customDayjs, THEME } from '@mtes-mct/monitor-ui' import type { ControlPlansData } from './controlPlan' import type { LegacyControlUnit } from './legacyControlUnit' @@ -18,6 +18,7 @@ export enum ActionTypeEnum { REPORTING = 'REPORTING', SURVEILLANCE = 'SURVEILLANCE' } + export const actionTypeLabels = { CONTROL: { code: 'CONTROL', @@ -38,6 +39,7 @@ export enum MissionTypeEnum { LAND = 'LAND', SEA = 'SEA' } + export const missionTypeEnum = { SEA: { code: 'SEA', @@ -79,12 +81,13 @@ export enum MissionTypeLabel { SEA = 'Mer' } -export enum LegalSanctionEnum { +export enum InfractionTypeEnum { WAITING = 'WAITING', WITHOUT_REPORT = 'WITHOUT_REPORT', WITH_REPORT = 'WITH_REPORT' } -export const legalSanctionLabels = { + +export const infractionTypeLabels = { WITH_REPORT: { code: 'WITH_REPORT', libelle: 'Avec PV' @@ -105,6 +108,7 @@ export enum FormalNoticeEnum { PENDING = 'PENDING', YES = 'YES' } + export const formalNoticeLabels = { YES: { code: 'YES', @@ -120,9 +124,9 @@ export const formalNoticeLabels = { libelle: 'En attente' } } -export type AdministrativeSanctionType = 'SANCTION' | 'REGULARIZATION' | 'PENDING' +export type AdministrativeResponseType = 'SANCTION' | 'REGULARIZATION' | 'PENDING' -export const administrativeSanctionsOptions: { label: string; value: AdministrativeSanctionType }[] = [ +export const administrativeResponseOptions: { label: string; value: AdministrativeResponseType }[] = [ { label: 'Sanction', value: 'SANCTION' }, { label: 'Régularisation', value: 'REGULARIZATION' }, { label: 'En attente', value: 'PENDING' } @@ -306,13 +310,13 @@ export type EnvActionNote = EnvActionCommonProperties & { } export type NewInfraction = { - administrativeSanction?: AdministrativeSanctionType + administrativeResponse?: AdministrativeResponseType companyName?: string | null controlledPersonIdentity?: string | null formalNotice?: FormalNoticeEnum id: string imo?: string | null - legalSanction?: LegalSanctionEnum + infractionType?: InfractionTypeEnum mmsi?: string | null natinf?: string[] observations?: string | null @@ -324,9 +328,9 @@ export type NewInfraction = { vesselType?: VesselTypeEnum | null } export type Infraction = NewInfraction & { - administrativeSanction: AdministrativeSanctionType + administrativeResponse: AdministrativeResponseType formalNotice: FormalNoticeEnum - legalSanction: LegalSanctionEnum + infractionType: InfractionTypeEnum } export type EnvActionForTimeline = EnvAction & { diff --git a/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionCard.tsx b/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionCard.tsx index 26d75b357..144733725 100644 --- a/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionCard.tsx +++ b/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionCard.tsx @@ -1,10 +1,10 @@ import { Accent, Button, Icon, IconButton, Tag } from '@mtes-mct/monitor-ui' import { - FormalNoticeEnum, - LegalSanctionEnum, - legalSanctionLabels, type EnvActionControl, - type Infraction + FormalNoticeEnum, + type Infraction, + InfractionTypeEnum, + infractionTypeLabels } from 'domain/entities/missions' import { TargetTypeEnum, TargetTypeLabels } from 'domain/entities/targetType' import { VehicleTypeEnum, vehicleTypeLabels } from 'domain/entities/vehicleType' @@ -37,7 +37,7 @@ export function InfractionCard({ const [controlledPersonIdentity] = useField( `${infractionPath}.controlledPersonIdentity` ) - const [legalSanction] = useField(`${infractionPath}.legalSanction`) + const [infractionType] = useField(`${infractionPath}.infractionType`) const [formalNotice] = useField(`${infractionPath}.formalNotice`) const [natinf] = useField(`${infractionPath}.natinf`) @@ -123,20 +123,20 @@ export function InfractionCard({ return identification.join(' - ') } - let libelleLegalSanction - switch (legalSanction?.value) { + let libelleInfractionType + switch (infractionType?.value) { case undefined: - libelleLegalSanction = 'PV : -' + libelleInfractionType = 'PV : -' break - case legalSanctionLabels.WITHOUT_REPORT.code: - libelleLegalSanction = legalSanctionLabels.WITHOUT_REPORT.libelle + case infractionTypeLabels.WITHOUT_REPORT.code: + libelleInfractionType = infractionTypeLabels.WITHOUT_REPORT.libelle break - case legalSanctionLabels.WITH_REPORT.code: - libelleLegalSanction = legalSanctionLabels.WITH_REPORT.libelle + case infractionTypeLabels.WITH_REPORT.code: + libelleInfractionType = infractionTypeLabels.WITH_REPORT.libelle break - case legalSanctionLabels.WAITING.code: + case infractionTypeLabels.WAITING.code: default: - libelleLegalSanction = legalSanctionLabels.WAITING.libelle + libelleInfractionType = infractionTypeLabels.WAITING.libelle } return ( @@ -146,7 +146,7 @@ export function InfractionCard({ {displayIdentification()} - {libelleLegalSanction} + {libelleInfractionType} {formalNotice?.value === FormalNoticeEnum.YES && MED} {natinf.value?.length ?? '0'} NATINF {natinf.value?.length && `: ${natinf.value?.join(', ')}`} diff --git a/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionForm/InfractionForm.tsx b/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionForm/InfractionForm.tsx index 676b2d43b..567c9a04a 100644 --- a/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionForm/InfractionForm.tsx +++ b/frontend/src/features/missions/MissionForm/ActionForm/ControlForm/InfractionForm/InfractionForm.tsx @@ -1,13 +1,13 @@ import { Accent, Button, FormikCheckbox, FormikMultiRadio, FormikTextarea } from '@mtes-mct/monitor-ui' import { - administrativeSanctionsOptions, - formalNoticeLabels, - legalSanctionLabels, + administrativeResponseOptions, type EnvActionControl, + formalNoticeLabels, + infractionTypeLabels, type Mission } from 'domain/entities/missions' import { TargetTypeEnum } from 'domain/entities/targetType' -import { useField, useFormikContext, type FormikErrors } from 'formik' +import { type FormikErrors, useField, useFormikContext } from 'formik' import styled from 'styled-components' import { InfractionFormHeaderCompany } from './InfractionFormHeaderCompany' @@ -18,7 +18,7 @@ import { RelevantCourtSelector } from './RelevantCourtSelector' import type { MouseEventHandler } from 'react' -const legalSanctionOptions = Object.values(legalSanctionLabels).map(o => ({ label: o.libelle, value: o.code })) +const infractionTypeOptions = Object.values(infractionTypeLabels).map(o => ({ label: o.libelle, value: o.code })) const formalNoticeOptions = Object.values(formalNoticeLabels).map(o => ({ label: o.libelle, value: o.code })) type InfractionFormProps = { @@ -27,6 +27,7 @@ type InfractionFormProps = { removeInfraction: MouseEventHandler validateInfraction: MouseEventHandler } + export function InfractionForm({ currentInfractionIndex, envActionIndex, @@ -66,18 +67,18 @@ export function InfractionForm({ isErrorMessageHidden isInline isRequired - label="Sanction judiciaire" - name={`${infractionPath}.legalSanction`} - options={legalSanctionOptions} + label="Type d'infraction" + name={`${infractionPath}.infractionType`} + options={infractionTypeOptions} /> .Field-Checkbox { padding-bottom: 12px; } diff --git a/frontend/src/features/missions/MissionForm/Schemas/Infraction.ts b/frontend/src/features/missions/MissionForm/Schemas/Infraction.ts index 055c25359..e10f57e6a 100644 --- a/frontend/src/features/missions/MissionForm/Schemas/Infraction.ts +++ b/frontend/src/features/missions/MissionForm/Schemas/Infraction.ts @@ -2,10 +2,10 @@ import { VesselTypeEnum } from 'domain/entities/vesselType' import * as Yup from 'yup' import { + type AdministrativeResponseType, FormalNoticeEnum, - LegalSanctionEnum, - type AdministrativeSanctionType, - type Infraction + type Infraction, + InfractionTypeEnum } from '../../../../domain/entities/missions' Yup.addMethod(Yup.mixed, 'oneOfOptional', (arr, message) => @@ -21,18 +21,18 @@ Yup.addMethod(Yup.mixed, 'oneOfOptional', (arr, message) => ) export const NewInfractionSchema: Yup.SchemaOf = Yup.object().shape({ - administrativeSanction: Yup.mixed().required(), + administrativeResponse: Yup.mixed().required(), companyName: Yup.string().optional().nullable(), controlledPersonIdentity: Yup.string().nullable(), formalNotice: Yup.mixed().oneOf(Object.values(FormalNoticeEnum)).required(), id: Yup.string().required(), imo: Yup.string().nullable(), - legalSanction: Yup.mixed().oneOf(Object.values(LegalSanctionEnum)).required(), + infractionType: Yup.mixed().oneOf(Object.values(InfractionTypeEnum)).required(), mmsi: Yup.string().nullable(), natinf: Yup.array() .of(Yup.string().ensure()) - .when('legalSanction', { - is: LegalSanctionEnum.WAITING, + .when('infractionType', { + is: InfractionTypeEnum.WAITING, otherwise: schema => schema.compact().min(1), then: schema => schema.compact().min(0) }) @@ -49,7 +49,7 @@ export const NewInfractionSchema: Yup.SchemaOf = Yup.object().shape( }) export const CompletionInfractionSchema: Yup.SchemaOf = NewInfractionSchema.shape({ - administrativeSanction: Yup.mixed().oneOf(['SANCTION', 'REGULARIZATION']).required(), + administrativeResponse: Yup.mixed().oneOf(['SANCTION', 'REGULARIZATION']).required(), formalNotice: Yup.mixed().oneOf([FormalNoticeEnum.YES, FormalNoticeEnum.NO]).required(), - legalSanction: Yup.mixed().oneOf([LegalSanctionEnum.WITH_REPORT, LegalSanctionEnum.WITHOUT_REPORT]).required() + infractionType: Yup.mixed().oneOf([InfractionTypeEnum.WITH_REPORT, InfractionTypeEnum.WITHOUT_REPORT]).required() }) diff --git a/frontend/src/features/missions/Missions.helpers.ts b/frontend/src/features/missions/Missions.helpers.ts index 93a605377..8b3ff5c8f 100644 --- a/frontend/src/features/missions/Missions.helpers.ts +++ b/frontend/src/features/missions/Missions.helpers.ts @@ -1,30 +1,30 @@ import { v4 as uuidv4 } from 'uuid' import { + ActionSource, + type ActionsTypeForTimeLine, ActionTypeEnum, - type NewEnvAction, - FormalNoticeEnum, - MissionSourceEnum, - type Mission, - type NewMission, - LegalSanctionEnum, + CompletionStatus, type EnvAction, - type EnvActionSurveillance, type EnvActionForTimeline, - type NewInfraction, + type EnvActionNote, + type EnvActionSurveillance, + FormalNoticeEnum, type Infraction, + InfractionTypeEnum, + type Mission, + MissionSourceEnum, + type NewEnvAction, type NewEnvActionControl, - type EnvActionNote, - ActionSource, - CompletionStatus, - type ActionsTypeForTimeLine + type NewInfraction, + type NewMission } from '../../domain/entities/missions' import { type DetachedReporting, + type DetachedReportingForTimeline, type Reporting, type ReportingDetailed, - type ReportingForTimeline, - type DetachedReportingForTimeline + type ReportingForTimeline } from '../../domain/entities/reporting' import { getFormattedReportingId } from '../Reportings/utils' @@ -170,11 +170,11 @@ export const getControlInfractionsTags = (actionNumberOfControls: number, infrac const totalInfractions = infractions?.length || 0 const ras = (actionNumberOfControls || 0) - totalInfractions const infractionsWithReport = - infractions?.filter(inf => inf.legalSanction === LegalSanctionEnum.WITH_REPORT)?.length || 0 + infractions?.filter(inf => inf.infractionType === InfractionTypeEnum.WITH_REPORT)?.length || 0 const infractionsWithoutReport = - infractions?.filter(inf => inf.legalSanction === LegalSanctionEnum.WITHOUT_REPORT)?.length || 0 + infractions?.filter(inf => inf.infractionType === InfractionTypeEnum.WITHOUT_REPORT)?.length || 0 const infractionsWithWaitingReport = - infractions?.filter(inf => inf.legalSanction === LegalSanctionEnum.WAITING)?.length || 0 + infractions?.filter(inf => inf.infractionType === InfractionTypeEnum.WAITING)?.length || 0 const med = infractions?.filter(inf => inf.formalNotice === FormalNoticeEnum.YES)?.length || 0 return { infractionsWithoutReport, infractionsWithReport, infractionsWithWaitingReport, med, ras, totalInfractions }