diff --git a/backend/src/main/resources/db/testdata/V666.11__Insert_dummy_risk_factors.sql b/backend/src/main/resources/db/testdata/V666.11__Insert_dummy_risk_factors.sql index f1f330fa5b..32ac0ae4e2 100644 --- a/backend/src/main/resources/db/testdata/V666.11__Insert_dummy_risk_factors.sql +++ b/backend/src/main/resources/db/testdata/V666.11__Insert_dummy_risk_factors.sql @@ -1,14 +1,14 @@ -- /!\ This file is automatically generated by a local script. -- Do NOT update it directly, update the associated .jsonc file in /backend/src/main/resources/db/testdata/json/ and execute 'make generate-test-data'. -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('FAK000999999', 2.56, 3.8, CURRENT_DATE, 3, 'DONTSINK', 2.1, 2.56, NULL, 'CALLME', '2024-03-01 00:00:00', true, CURRENT_DATE, 1, 8, 4, 5, 0, 3, 2, '', 2, 2.473, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 1235.36, 123101, 1, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('FAK000999999', 2.56, 3.8, CURRENT_DATE, 3, 'DONTSINK', 2.1, 2.56, NULL, 'CALLME', '2024-03-01 00:00:00', true, CURRENT_DATE, 1, 8, 4, 5, 0, 3, 2, '', 2, 2.473, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 1235.36, 123101, 1, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"NEP","weight":235.6}]'); -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR101', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM101', 4, 3, NULL, 'IRCS101', '2023-01-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 12345.67, 123102, 101, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR101', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM101', 4, 3, NULL, 'IRCS101', '2023-01-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 12345.67, 123102, 101, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR102', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM103', 4, 3, NULL, 'IRCS103', NULL, true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 12345.67, 123103, 102, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR102', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM103', 4, 3, NULL, 'IRCS103', NULL, true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 12345.67, 123103, 102, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR109', 4, 5, '2024-03-31 14:00:00', 5, 'EXTIMM109', 4, 3, NULL, 'IRCS109', '2024-04-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 12345.67, 123109, 109, '[]', '[]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR109', 4, 5, '2024-03-31 14:00:00', 5, 'EXTIMM109', 4, 3, NULL, 'IRCS109', '2024-04-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 4, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 12345.67, 123109, 109, '[]', '[]'); -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR115', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM115', 4, 3, NULL, 'IRCS115', '2024-05-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 2.5, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 12345.67, 123102, 115, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR115', 4, 5, NOW() - INTERVAL '1 day', 5, 'EXTIMM115', 4, 3, NULL, 'IRCS115', '2024-05-01 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 4, 2.5, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 12345.67, 123102, 115, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); -INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR117', 4, 5, NOW() - INTERVAL '1 day', 1.8, 'EXTIMM117', 2, 3, NULL, 'IRCS117', '2023-10-15 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 3, 2.2, 'NWW10', 'PEL 03', '{"NWW10", "PEL 03"}', 12345.67, 123102, 117, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); +INSERT INTO risk_factors (cfr, control_priority_level, control_rate_risk_factor, departure_datetime_utc, detectability_risk_factor, external_immatriculation, impact_risk_factor, infraction_rate_risk_factor, infraction_score, ircs, last_control_datetime_utc, last_control_infraction, last_logbook_message_datetime_utc, number_controls_last_3_years, number_controls_last_5_years, number_gear_seizures_last_5_years, number_infractions_last_5_years, number_recent_controls, number_species_seizures_last_5_years, number_vessel_seizures_last_5_years, post_control_comments, probability_risk_factor, risk_factor, segment_highest_impact, segment_highest_priority, segments, total_weight_onboard, trip_number, vessel_id, gear_onboard, species_onboard) VALUES ('CFR117', 4, 5, NOW() - INTERVAL '1 day', 1.8, 'EXTIMM117', 2, 3, NULL, 'IRCS117', '2023-10-15 00:00:00', true, NOW(), 0, 0, 4, 5, 0, 3, 2, '', 3, 2.2, 'NWW10', 'PEL03', '{"NWW10", "PEL03"}', 12345.67, 123102, 117, '[{"gear":"OTB","mesh":70,"dimensions":45}]', '[{"gear":"OTB","faoZone":"27.8.b","species":"BLI","weight":13.46},{"gear":"OTB","faoZone":"27.8.c","species":"HKE","weight":235.6},{"gear":"OTB","faoZone":"27.8.b","species":"HKE","weight":235.6}]'); diff --git a/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql b/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql index 6c7653f742..c27e178390 100644 --- a/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql +++ b/backend/src/main/resources/db/testdata/V666.3__Insert_dummy_last_positions.sql @@ -1030,9 +1030,9 @@ COPY public.last_positions (id, cfr, external_immatriculation, mmsi, ircs, vesse estimated_current_longitude, impact_risk_factor, probability_risk_factor, detectability_risk_factor, risk_factor, under_charter, is_at_port, alerts, beacon_malfunction_id, reportings) FROM stdin; -10000 FAK000999999 DONTSINK \N CALLME PHENOMENE GB \N 47.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL 03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] CAEN CN 2020-12-22 08:59:00 true Pas de com INTERNAL_REFERENCE_NUMBER 47.7123 -8.8123 2.1 2 3 2.473 t f {THREE_MILES_TRAWLING_ALERT} 1 \N -10001 SOCR4T3 LePhiloFilou \N SCRT SOCRATE FR \N 48.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL 03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N -10002 U_W0NTFINDME ABC123456 \N TALK2ME MALOTRU FR \N 48.221999999999997 -8.5129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL 03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N +10000 FAK000999999 DONTSINK \N CALLME PHENOMENE GB \N 47.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] CAEN CN 2020-12-22 08:59:00 true Pas de com INTERNAL_REFERENCE_NUMBER 47.7123 -8.8123 2.1 2 3 2.473 t f {THREE_MILES_TRAWLING_ALERT} 1 \N +10001 SOCR4T3 LePhiloFilou \N SCRT SOCRATE FR \N 48.921999999999997 -8.0129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N +10002 U_W0NTFINDME ABC123456 \N TALK2ME MALOTRU FR \N 48.221999999999997 -8.5129999999999999 8.40000000000000036 14 2021-01-15 07:32:00 00:40:00 2020-12-21 15:01:00 14.3 5.2 {"W10", "PEL03"} [{"gear": "OTB", "mesh": 70.0, "dimensions": 45.0}] [{ "gear": "OTB","faoZone": "27.8.b","species": "BLI","weight": 13.46 },{ "gear": "OTB","faoZone": "27.8.c","species": "HKE","weight": 235.6 }] ATHENES AT 2020-12-22 08:59:00 true No comment INTERNAL_REFERENCE_NUMBER 49.003 -7.9523 2.1 2 3 2.473 f f \N \N \N \. update last_positions diff --git a/backend/src/main/resources/db/testdata/json/V666.11__Insert_dummy_risk_factors.jsonc b/backend/src/main/resources/db/testdata/json/V666.11__Insert_dummy_risk_factors.jsonc index f1a1f4a1d5..a2a94bc124 100644 --- a/backend/src/main/resources/db/testdata/json/V666.11__Insert_dummy_risk_factors.jsonc +++ b/backend/src/main/resources/db/testdata/json/V666.11__Insert_dummy_risk_factors.jsonc @@ -29,8 +29,8 @@ "probability_risk_factor": 2, "risk_factor": 2.473, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 1235.36, "trip_number": 123101, "vessel_id": 1, @@ -59,6 +59,12 @@ "faoZone": "27.8.b", "species": "HKE", "weight": 235.6 + }, + { + "gear": "OTB", + "faoZone": "27.8.b", + "species": "NEP", + "weight": 235.6 } ] }, @@ -90,8 +96,8 @@ "probability_risk_factor": 4, "risk_factor": 4, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 12345.67, "trip_number": 123102, "vessel_id": 101, @@ -151,8 +157,8 @@ "probability_risk_factor": 4, "risk_factor": 4, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 12345.67, "trip_number": 123103, "vessel_id": 102, @@ -212,8 +218,8 @@ "probability_risk_factor": 4, "risk_factor": 4, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 12345.67, "trip_number": 123109, "vessel_id": 109, @@ -248,8 +254,8 @@ "probability_risk_factor": 4, "risk_factor": 2.5, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 12345.67, "trip_number": 123102, "vessel_id": 115, @@ -309,8 +315,8 @@ "probability_risk_factor": 3, "risk_factor": 2.2, "segment_highest_impact": "NWW10", - "segment_highest_priority": "PEL 03", - "segments": ["NWW10", "PEL 03"], + "segment_highest_priority": "PEL03", + "segments": ["NWW10", "PEL03"], "total_weight_onboard": 12345.67, "trip_number": 123102, "vessel_id": 117, diff --git a/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/index.tsx b/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/index.tsx new file mode 100644 index 0000000000..4aa4955878 --- /dev/null +++ b/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/index.tsx @@ -0,0 +1,115 @@ +import { useGetGearsQuery } from '@api/gear' +import { useGetFleetSegmentsQuery } from '@features/FleetSegment/apis' +import { + getFaoZones, + getGearsWithNames, + getTargetSpeciesIncludedInSegments +} from '@features/FleetSegment/components/VesselCurrentFleetSegmentDetails/utils' +import { SpeciesTypeToSpeciesTypeLabel } from '@features/FleetSegment/constants' +import { FlatKeyValue } from '@features/Vessel/components/VesselSidebar/common/FlatKeyValue' +import { useMainAppSelector } from '@hooks/useMainAppSelector' +import { type ForwardedRef, forwardRef, useMemo } from 'react' +import styled from 'styled-components' + +import type { FleetSegment } from '@features/FleetSegment/types' + +type VesselCurrentFleetSegmentDetailsProps = Readonly<{ + className?: string | undefined +}> +function VesselCurrentFleetSegmentDetailsWithRef( + { className }: VesselCurrentFleetSegmentDetailsProps, + ref: ForwardedRef +) { + const selectedVessel = useMainAppSelector(state => state.vessel.selectedVessel) + const { data: gearsReferential } = useGetGearsQuery() + const { data: fleetSegmentsReferential } = useGetFleetSegmentsQuery() + const riskFactor = selectedVessel?.riskFactor + + const fleetSegments: FleetSegment[] = + riskFactor?.segments + ?.map(fleetSegmentsCode => + fleetSegmentsReferential?.find(segmentFromReferential => segmentFromReferential.segment === fleetSegmentsCode) + ) + ?.filter(segment => !!segment) ?? [] + + const isFleetSegmentSpecifyingMeshSize = !!fleetSegments.find( + fleetSegment => !!fleetSegment.minMesh || !!fleetSegment.maxMesh + ) + const mainScipSpeciesType = fleetSegments.find( + fleetSegment => !!fleetSegment.mainScipSpeciesType + )?.mainScipSpeciesType + + const targetSpeciesIncludedInSegments = getTargetSpeciesIncludedInSegments(riskFactor, fleetSegments) + const gearsWithName = getGearsWithNames(gearsReferential, riskFactor) + const faoZones = getFaoZones(riskFactor) + + const columns = useMemo(() => { + let baseColumns = [ + { + key: 'Zones de la marée', + value: faoZones + }, + { + hasMultipleLines: true, + key: 'Engins de la marée (FAR)', + value: gearsWithName?.length ? ( + <> + {gearsWithName?.map(gear => ( + + {gear.gearName} ({gear.gear}) + + ))} + + ) : undefined + } + ] + + if (isFleetSegmentSpecifyingMeshSize) { + baseColumns = baseColumns.concat({ + hasMultipleLines: true, + key: 'Maillage des engins', + value: ( + <> + {gearsWithName?.map(gear => ( + + {gear.mesh ? <>{gear.mesh} mm : -} ({gear.gear}) + + ))} + + ) + }) + } + + if (mainScipSpeciesType) { + baseColumns = baseColumns.concat({ + key: "Majorité d'espèces à bord", + value: SpeciesTypeToSpeciesTypeLabel[mainScipSpeciesType] + }) + } + + if (targetSpeciesIncludedInSegments) { + baseColumns = baseColumns.concat({ + key: 'Espèces cibles à bord', + value: targetSpeciesIncludedInSegments + }) + } + + return baseColumns + }, [faoZones, mainScipSpeciesType, isFleetSegmentSpecifyingMeshSize, targetSpeciesIncludedInSegments, gearsWithName]) + + return +} + +export const VesselCurrentFleetSegmentDetails = forwardRef( + VesselCurrentFleetSegmentDetailsWithRef +) + +const ValueWithLineBreak = styled.div` + font-size: 13px; +` + +const NoValue = styled.span` + color: ${p => p.theme.color.slateGray}; + font-weight: 300; + line-height: normal; +` diff --git a/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/utils.ts b/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/utils.ts new file mode 100644 index 0000000000..5d1dd66413 --- /dev/null +++ b/frontend/src/features/FleetSegment/components/VesselCurrentFleetSegmentDetails/utils.ts @@ -0,0 +1,57 @@ +import { uniq } from 'lodash' + +import type { RiskFactor } from '../../../../domain/entities/vessel/riskFactor/types' +import type { Gear } from '../../../../domain/types/Gear' +import type { FleetSegment } from '@features/FleetSegment/types' + +export function getTargetSpeciesIncludedInSegments( + riskFactor: RiskFactor | undefined, + fleetSegments: FleetSegment[] +): string | undefined { + if (!riskFactor?.speciesOnboard || !fleetSegments.length) { + return undefined + } + + const speciesFromSegments = uniq(fleetSegments.flatMap(fleetSegment => fleetSegment.targetSpecies)) + if (!speciesFromSegments.length) { + return undefined + } + + const minShareOfTargetSpecies = fleetSegments.find( + fleetSegment => !!fleetSegment.minShareOfTargetSpecies + )?.minShareOfTargetSpecies + + const minShareOfTargetSpeciesText = minShareOfTargetSpecies + ? ` (≥ ${minShareOfTargetSpecies * 100}% du total des captures)` + : '' + + const foundSpecies = uniq(riskFactor.speciesOnboard) + .filter(specy => speciesFromSegments.includes(specy.species)) + .map(specy => specy.species) + .join(', ') + + return `${foundSpecies}${minShareOfTargetSpeciesText}` +} + +export function getGearsWithNames(gearsReferential: Gear[] | undefined, riskFactor: RiskFactor | undefined) { + if (!riskFactor?.gearOnboard) { + return undefined + } + + return riskFactor.gearOnboard.map(gear => { + const gearName = + gearsReferential?.find(gearFromReferential => gearFromReferential.code === gear.gear)?.name ?? undefined + + return { ...gear, gearName } + }) +} + +export function getFaoZones(riskFactor: RiskFactor | undefined): string | undefined { + if (!riskFactor?.speciesOnboard) { + return undefined + } + + const nextFaoZones = riskFactor.speciesOnboard.map(species => species.faoZone) + + return uniq(nextFaoZones).join(', ') +} diff --git a/frontend/src/features/FleetSegment/constants.ts b/frontend/src/features/FleetSegment/constants.ts index d72cbb374e..92fb5695c3 100644 --- a/frontend/src/features/FleetSegment/constants.ts +++ b/frontend/src/features/FleetSegment/constants.ts @@ -1,5 +1,14 @@ +import { ScipSpeciesType } from '@features/FleetSegment/types' + export const FLEET_SEGMENT_VESSEL_TYPES = [ 'Chalutier pêche arrière - congélateur', 'Chalutier pêche arr. congélateur rampe port. fixe', 'Chalutiers pêche arrière congélateurs' ] + +export const SpeciesTypeToSpeciesTypeLabel: Record = { + [ScipSpeciesType.DEMERSAL]: 'Démersal', + [ScipSpeciesType.OTHER]: 'Autres', + [ScipSpeciesType.PELAGIC]: 'Pélagique', + [ScipSpeciesType.TUNA]: 'Thon' +} diff --git a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegments.tsx b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegmentsWithTooltip.tsx similarity index 64% rename from frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegments.tsx rename to frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegmentsWithTooltip.tsx index 66b86f49bd..3921256483 100644 --- a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegments.tsx +++ b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/FleetSegmentsWithTooltip.tsx @@ -1,29 +1,28 @@ +import { useGetFleetSegmentsQuery } from '@features/FleetSegment/apis' import { Icon } from '@mtes-mct/monitor-ui' import styled from 'styled-components' import { getSegmentInfo, getTripSegments } from './utils' -import { COLORS } from '../../../../../constants/constants' -import { useGetFleetSegmentsQuery } from '../../../../FleetSegment/apis' export type FleetSegmentsProps = { segments: string[] | undefined } -export function FleetSegments({ segments }: FleetSegmentsProps) { +export function FleetSegmentsWithTooltip({ segments }: FleetSegmentsProps) { const { data: fleetSegments } = useGetFleetSegmentsQuery() const tripSegments = getTripSegments(segments, fleetSegments) return ( <> - {tripSegments ? ( - tripSegments.map((segment, index) => ( + {segments ? ( + segments.map((segment, index) => ( // eslint-disable-next-line react/no-array-index-key - {segment.segment} - + {segment} + - {tripSegments.length === index + 1 ? '' : ', '} + {segments.length === index + 1 ? '' : ', '} )) ) : ( @@ -38,7 +37,7 @@ const TitleWrapper = styled.span` ` const NoValue = styled.span` - color: ${COLORS.slateGray}; + color: ${p => p.theme.color.slateGray}; font-weight: 300; line-height: normal; ` diff --git a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/index.tsx b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/index.tsx index 8d870a4918..800be892bb 100644 --- a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/index.tsx +++ b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/index.tsx @@ -1,4 +1,5 @@ import { COMMON_ALERT_TYPE_OPTION } from '@features/Alert/constants' +import { VesselCurrentFleetSegmentDetails } from '@features/FleetSegment/components/VesselCurrentFleetSegmentDetails' import { getLastLogbookTripsOptions } from '@features/Logbook/components/VesselLogbook/LogbookMessages/utils' import { useMainAppDispatch } from '@hooks/useMainAppDispatch' import { useMainAppSelector } from '@hooks/useMainAppSelector' @@ -7,7 +8,7 @@ import { skipToken } from '@reduxjs/toolkit/query' import { useMemo } from 'react' import styled from 'styled-components' -import { FleetSegments } from './FleetSegments' +import { FleetSegmentsWithTooltip } from './FleetSegmentsWithTooltip' import { CPSMessageResume } from './summaries/CPSMessageResume' import { DEPMessageResume } from './summaries/DEPMessageResume' import { DISMessageResume } from './summaries/DISMessageResume' @@ -19,9 +20,8 @@ import ArrowSVG from '../../../../icons/Picto_fleche-pleine-droite.svg?react' import { useGetLastLogbookTripsQuery } from '../../../api' import { LogbookMessageType as LogbookMessageTypeEnum, LogbookOperationType, NavigateTo } from '../../../constants' import { useGetLogbookUseCase } from '../../../hooks/useGetLogbookUseCase' -import { getFAOZonesFromFARMessages } from '../../../utils' import { CustomDatesShowedInfo } from '../CustomDatesShowedInfo' -import { getLogbookTripSummary, getUniqueGears } from '../utils' +import { getLogbookTripSummary } from '../utils' import type { LogbookTripSummary } from '../types' import type { Promisable } from 'type-fest' @@ -45,8 +45,6 @@ export function LogbookSummary({ showLogbookMessages }: LogbookSummaryProps) { const logbookTrip: LogbookTripSummary = useMemo(() => getLogbookTripSummary(fishingActivities), [fishingActivities]) - const faoZones = getFAOZonesFromFARMessages(logbookTrip.far.logs) - const catchesOverToleranceAlert = useMemo(() => { if (!fishingActivities?.alerts?.length) { return undefined @@ -57,31 +55,6 @@ export function LogbookSummary({ showLogbookMessages }: LogbookSummaryProps) { )?.value }, [fishingActivities?.alerts]) - const depGears = useMemo(() => { - if (!logbookTrip.dep?.log?.message?.gearOnboard?.length) { - return - - } - - const uniqueGears = getUniqueGears(logbookTrip.dep.log.message.gearOnboard) - - return uniqueGears.map(gear => { - if (!gear.gearName) { - return ( - - {gear.gear} -
-
- ) - } - - return ( - - {gear.gearName} ({gear.gear})
-
- ) - }) - }, [logbookTrip.dep?.log]) - const goToPreviousTrip = () => dispatch(getVesselLogbook(selectedVessel, NavigateTo.PREVIOUS, true)) const goToNextTrip = () => dispatch(getVesselLogbook(selectedVessel, NavigateTo.NEXT, true)) const goToLastTrip = () => dispatch(getVesselLogbook(selectedVessel, NavigateTo.LAST, true)) @@ -96,38 +69,15 @@ export function LogbookSummary({ showLogbookMessages }: LogbookSummaryProps) { <Text>Segment(s) de flotte(s) actuel(s)</Text> <TextValue> - <FleetSegments segments={selectedVessel?.segments} /> + <FleetSegmentsWithTooltip segments={selectedVessel?.segments} /> </TextValue> - - - - Engins à bord (JPE) - {depGears} - - - Zones de la marée (JPE) - - {faoZones?.length ? ( - faoZones.map((faoZone, index) => ( - // eslint-disable-next-line react/no-array-index-key - - {faoZone} - {index === faoZones.length - 1 ? '' : ', '} - - )) - ) : ( - - - )} - - - - + - <Text hasTwoLines>Résumé du JPE</Text> - <TextValue data-cy="vessel-fishing-trip-number" hasTwoLines={false}> + <Text $hasTwoLines>Résumé du JPE</Text> + <TextValue $hasTwoLines={false} data-cy="vessel-fishing-trip-number"> <PreviousTrip $disabled={!!isFirstVoyage} accent={Accent.TERTIARY} @@ -277,6 +227,10 @@ export function LogbookSummary({ showLogbookMessages }: LogbookSummaryProps) { ) } +const StyledVesselCurrentFleetSegmentDetails = styled(VesselCurrentFleetSegmentDetails)` + padding: 6px 4px 4px; +` + export const PreviousTrip = styled(IconButton)<{ $disabled: boolean }>` @@ -345,23 +299,23 @@ const LogbookMessages = styled.ul` ` const Text = styled.div<{ - hasTwoLines?: boolean + $hasTwoLines?: boolean }>` color: ${p => p.theme.color.slateGray}; font-size: 13px; font-weight: 500; - padding-top: ${p => (p.hasTwoLines ? '5px' : '0')}; + padding-top: ${p => (p.$hasTwoLines ? '5px' : '0')}; ` const TextValue = styled.div<{ - hasTwoLines?: boolean + $hasTwoLines?: boolean }>` font-size: 13px; color: ${p => p.theme.color.gunMetal}; font-weight: 500; margin: 0; padding-left: 12px; - padding-top: ${p => (p.hasTwoLines ? '6px' : '0')}; + padding-top: ${p => (p.$hasTwoLines ? '6px' : '0')}; .Field-Select { background-color: ${p => p.theme.color.gainsboro}; @@ -397,8 +351,6 @@ const Body = styled.div` padding: 10px 10px 1px 10px; ` -const TableBody = styled.tbody`` - const Title = styled.div<{ $hasTwoLines?: boolean }>` @@ -421,49 +373,3 @@ const Zone = styled.div<{ text-align: left; margin-bottom: 10px; ` - -const Fields = styled.table` - display: table; - margin: 15px 5px 10px 35px; - min-width: 40%; - width: inherit; -` - -const Field = styled.tr` - margin: 5px 5px 5px 0; - border: none; - background: none; - line-height: 0.5em; -` - -const Key = styled.th` - color: ${p => p.theme.color.slateGray}; - display: inline-block; - margin: 0; - border: none; - padding: 5px 5px 5px 0; - background: none; - width: max-content; - line-height: 0.5em; - height: 0.5em; - font-size: 13px; - font-weight: normal; -` - -const Value = styled.td` - font-size: 13px; - color: ${p => p.theme.color.gunMetal}; - font-weight: 500; - margin: 0; - text-align: left; - padding: 1px 5px 5px 5px; - background: none; - border: none; - line-height: normal; -` - -const NoValue = styled.span` - color: ${p => p.theme.color.slateGray}; - font-weight: 300; - line-height: normal; -` diff --git a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/utils.ts b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/utils.ts index 8a9a26558d..0b6a125b58 100644 --- a/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/utils.ts +++ b/frontend/src/features/Logbook/components/VesselLogbook/LogbookSummary/utils.ts @@ -1,47 +1,39 @@ +import { SpeciesTypeToSpeciesTypeLabel } from '@features/FleetSegment/constants' + import type { FleetSegment } from '../../../../FleetSegment/types' export function getTripSegments( segments: string[] | undefined, segmentsReferential: FleetSegment[] | undefined -): Partial<FleetSegment>[] { - if (!segments?.length) { +): Array<FleetSegment | undefined> { + if (!segments?.length || !segmentsReferential?.length) { return [] } - if (!segmentsReferential?.length) { - return segments.map(segment => ({ - segment - })) - } - return segments.map(segment => { const found = segmentsReferential.find(segmentWithProperties => segmentWithProperties.segment === segment) - if (!found) { - return { - segment - } + return undefined } return found }) } -export function getSegmentInfo(segment: Partial<FleetSegment>): string { - if (segment.gears ?? segment.faoAreas ?? segment.targetSpecies) { - const gears = segment.gears?.length ? segment.gears.join(', ') : 'aucun' - const faoAreas = segment.faoAreas?.length ? segment.faoAreas.join(', ') : 'aucune' - - let targetSpeciesArray: string[] = [] - if (segment.targetSpecies?.length) { - targetSpeciesArray = targetSpeciesArray.concat(segment.targetSpecies) - } - const targetSpecies = targetSpeciesArray.length ? targetSpeciesArray.join(', ') : 'aucune' - - return `Engins: ${gears} -Zones FAO: ${faoAreas} -Espèces: ${targetSpecies}` +export function getSegmentInfo(segment: FleetSegment | undefined): string { + if (!segment) { + return 'Segment de flotte inconnu' } - return 'Segment de flotte inconnu' + const gears = segment.gears?.length ? segment.gears.join(', ') : 'aucun' + const faoAreas = segment.faoAreas?.length ? segment.faoAreas.join(', ') : 'aucune' + const targetSpecies = segment.targetSpecies?.length ? segment.targetSpecies.join(', ') : 'aucune' + const percent = segment.minShareOfTargetSpecies ? segment.minShareOfTargetSpecies * 100 : undefined + + return `Zones : ${faoAreas} +Engins : ${gears} +Maillage min. : ${segment.minMesh ? `${segment.minMesh}mm` : 'aucun'} +Maillage max. : ${segment.maxMesh ? `${segment.maxMesh}mm` : 'aucun'} +Majorité d'espèces : ${segment.mainScipSpeciesType ? SpeciesTypeToSpeciesTypeLabel[segment.mainScipSpeciesType] : 'aucun'} +Espèces cibles ${percent ? `(≥ ${percent}% du total des captures) ` : ''}: ${targetSpecies}` } diff --git a/frontend/src/features/Logbook/utils.ts b/frontend/src/features/Logbook/utils.ts index 6531490197..4602a82984 100644 --- a/frontend/src/features/Logbook/utils.ts +++ b/frontend/src/features/Logbook/utils.ts @@ -402,21 +402,6 @@ export const getPNOSpeciesInsightRecord = ( return speciesToWeightPNOObject } -export const getFAOZonesFromFARMessages = (farMessages: Logbook.FarMessage[]) => - farMessages - .map(farMessage => - farMessage.message.hauls.map(haul => haul.catches.map(speciesCatch => speciesCatch.faoZone)).flat() - ) - .flat() - .filter((faoZone): faoZone is string => faoZone !== undefined) - .reduce((acc: string[], faoZone) => { - if (acc.indexOf(faoZone) < 0) { - acc.push(faoZone) - } - - return acc - }, []) - /** * Get the effective datetime from logbook message */ diff --git a/frontend/src/features/Vessel/components/VesselSidebar/common/FlatKeyValue.tsx b/frontend/src/features/Vessel/components/VesselSidebar/common/FlatKeyValue.tsx index e7e1e15a9d..ddc355dac3 100644 --- a/frontend/src/features/Vessel/components/VesselSidebar/common/FlatKeyValue.tsx +++ b/frontend/src/features/Vessel/components/VesselSidebar/common/FlatKeyValue.tsx @@ -1,7 +1,6 @@ +import { type ForwardedRef, forwardRef, ReactElement } from 'react' import styled from 'styled-components' -import type { ReactElement } from 'react' - type KeyValue = { hasMultipleLines?: boolean key: string @@ -14,9 +13,12 @@ type KeyValueTableProps = { keyWidth?: number | undefined valueEllipsisedForWidth?: number | undefined } -export function FlatKeyValue({ className, column, keyWidth, valueEllipsisedForWidth }: KeyValueTableProps) { +function FlatKeyValueWithRef( + { className, column, keyWidth, valueEllipsisedForWidth }: KeyValueTableProps, + ref: ForwardedRef<HTMLDivElement> +) { return ( - <Zone className={className}> + <Zone ref={ref ?? undefined} className={className}> <Fields> <TableBody> {column.map(({ hasMultipleLines, key, value }) => ( @@ -42,6 +44,8 @@ export function FlatKeyValue({ className, column, keyWidth, valueEllipsisedForWi ) } +export const FlatKeyValue = forwardRef<HTMLDivElement, KeyValueTableProps>(FlatKeyValueWithRef) + const TableBody = styled.tbody`` const Zone = styled.div` @@ -108,5 +112,4 @@ const NoValue = styled.td` line-height: normal; color: ${p => p.theme.color.slateGray}; font-weight: 300; - line-height: normal; ` diff --git a/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ImpactRiskFactorDetails.tsx b/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ImpactRiskFactorDetails.tsx index 1ca4118ae7..c49f5d1e32 100644 --- a/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ImpactRiskFactorDetails.tsx +++ b/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ImpactRiskFactorDetails.tsx @@ -1,33 +1,20 @@ +import { VesselCurrentFleetSegmentDetails } from '@features/FleetSegment/components/VesselCurrentFleetSegmentDetails' import { useMainAppSelector } from '@hooks/useMainAppSelector' -import { useEffect, useRef, useState } from 'react' +import { useRef } from 'react' import styled from 'styled-components' import InfoSVG from '../../../../../icons/Information.svg?react' export function ImpactRiskFactorDetails({ isOpen }) { const selectedVessel = useMainAppSelector(state => state.vessel.selectedVessel) - const [faoZones, setFaoZones] = useState([]) - const speciesElement = useRef<HTMLTableCellElement | null>(null) - - // TODO Fix `riskFactor` does not exist on type `AugmentedSelectedVessel`. - // @ts-ignore - const { riskFactor } = selectedVessel - - useEffect(() => { - if (riskFactor && riskFactor.speciesOnboard) { - const nextFaoZones = riskFactor.speciesOnboard.map(species => species.faoZone) - - setFaoZones(Array.from(new Set(nextFaoZones)) as any) - } else { - setFaoZones([]) - } - }, [riskFactor]) + const currentFleetSegmentDetailsElementRef = useRef<HTMLDivElement>(null) + const riskFactor = selectedVessel?.riskFactor return ( <SubRiskDetails - $hasSegment={riskFactor?.segmentHighestImpact} + $elementHeight={currentFleetSegmentDetailsElementRef?.current?.clientHeight} + $hasSegment={!!riskFactor?.segmentHighestImpact} $isOpen={isOpen} - $speciesHeight={speciesElement?.current?.clientHeight} > <Line /> <Zone> @@ -36,68 +23,24 @@ export function ImpactRiskFactorDetails({ isOpen }) { <Fields> <TableBody> <Field> - <Key $isBig>Segment de flotte actuel</Key> + <Key>Segment de flotte actuel</Key> <Value> - {riskFactor?.segmentHighestImpact ? ( - <> - {riskFactor?.segmentHighestImpact}{' '} - <Info - title={ - 'La note de risque de ce segment est la note attribuée par la DIRM de la ' + - 'façade dans son Plan de contrôle annuel.' - } - /> - </> - ) : ( - <NoValue>-</NoValue> - )} + {riskFactor?.segmentHighestImpact}{' '} + <Info + title={ + 'La note de risque de ce segment est la note attribuée par la DIRM de la ' + + 'façade dans son Plan de contrôle annuel.' + } + /> </Value> </Field> </TableBody> </Fields> - <Fields> - <TableBody> - <Field> - <Key>Engins à bord</Key> - <Value> - {riskFactor?.gearOnboard?.length ? ( - riskFactor?.gearOnboard?.map(gear => gear.gear).join(', ') - ) : ( - <NoValue>-</NoValue> - )} - </Value> - </Field> - <Field> - <Key>Espèces à bord</Key> - <Value - ref={speciesElement} - title={ - riskFactor?.speciesOnboard?.length - ? riskFactor?.speciesOnboard?.map(gear => gear.species).join(', ') - : undefined - } - > - {/* eslint-disable-next-line no-nested-ternary */} - {riskFactor?.speciesOnboard?.length ? ( - riskFactor?.speciesOnboard?.length > 20 ? ( - `${riskFactor?.speciesOnboard - ?.map(gear => gear.species) - .join(', ') - .substring(0, 104)}...` - ) : ( - riskFactor?.speciesOnboard?.map(gear => gear.species).join(', ') - ) - ) : ( - <NoValue>-</NoValue> - )} - </Value> - </Field> - <Field> - <Key>Zones de la marée</Key> - <Value>{faoZones.length ? faoZones.join(', ') : <NoValue>-</NoValue>}</Value> - </Field> - </TableBody> - </Fields> + <VesselCurrentFleetSegmentDetails ref={currentFleetSegmentDetailsElementRef} /> + <Text> + Si le navire appartient à plusieurs segments, c'est celui dont la note d'impact est la plus + élevée qui est retenu. + </Text> </> ) : ( <Text> @@ -110,12 +53,6 @@ export function ImpactRiskFactorDetails({ isOpen }) { ) } -const NoValue = styled.span` - color: ${p => p.theme.color.slateGray}; - font-weight: 300; - line-height: normal; -` - const Line = styled.div` width: 100%; border-bottom: 1px solid ${p => p.theme.color.lightGray}; @@ -127,26 +64,25 @@ const Info = styled(InfoSVG)<{ width: 14px; vertical-align: text-bottom; margin-bottom: 2px; - margin-left: ${props => (props.$isInfoSegment ? '5px' : '2px')}; + margin-left: ${p => (p.$isInfoSegment ? '5px' : '2px')}; ` const SubRiskDetails = styled.div<{ + $elementHeight: number | undefined $hasSegment: boolean $isOpen: boolean - $speciesHeight: number | undefined }>` width: 100%; - z-index: ${props => props.$speciesHeight}; - height: ${props => + height: ${p => // eslint-disable-next-line no-nested-ternary - props.$isOpen - ? props.$hasSegment + p.$isOpen + ? p.$hasSegment ? // eslint-disable-next-line no-nested-ternary - 120 + (props.$speciesHeight ? (props.$speciesHeight < 60 ? props.$speciesHeight : 60) : 36) + 95 + (p.$elementHeight ? p.$elementHeight : 36) : 80 : 0}px; - opacity: ${props => (props.$isOpen ? '1' : '0')}; - visibility: ${props => (props.$isOpen ? 'visible' : 'hidden')}; + opacity: ${p => (p.$isOpen ? '1' : '0')}; + visibility: ${p => (p.$isOpen ? 'visible' : 'hidden')}; overflow: hidden; transition: 0.2s all; ` @@ -154,7 +90,7 @@ const SubRiskDetails = styled.div<{ const TableBody = styled.tbody`` const Zone = styled.div` - margin: 5px 5px 10px 45px; + margin: 5px 5px 10px 16px; text-align: left; display: flex; flex-wrap: wrap; @@ -163,7 +99,7 @@ const Zone = styled.div` const Fields = styled.table` display: table; - margin: 10px 5px 5px 20px; + margin: 10px 5px 0 16px; min-width: 40%; width: inherit; ` @@ -175,27 +111,18 @@ const Field = styled.tr` line-height: 0.5em; ` -const Key = styled.th<{ - $isBig?: boolean -}>` +const Key = styled.th` color: ${p => p.theme.color.slateGray}; - flex: initial; - display: inline-block; - margin: 0; - border: none; - padding: 5px 5px 5px 0; - background: none; - width: ${props => (props.$isBig ? '160px' : '120px')}; + padding: 1px 5px 5px 0; line-height: 0.5em; - height: 0.5em; - font-size: 13px; font-weight: normal; + width: 170px; + text-align: left; ` const Value = styled.td` font-size: 13px; color: ${p => p.theme.color.gunMetal}; - margin: 0; text-align: left; padding: 1px 5px 5px 5px; background: none; @@ -207,13 +134,7 @@ const Value = styled.td` const Text = styled.div` font-size: 13px; color: ${p => p.theme.color.gunMetal}; - margin: 0; text-align: left; - padding: 1px 5px 5px 5px; - background: none; - border: none; - line-height: normal; font-weight: 500; - margin-left: -15px; - margin-top: 5px; + margin: 4px 0 0 16px; ` diff --git a/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ProbabilityRiskFactorDetails.tsx b/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ProbabilityRiskFactorDetails.tsx index d0f9fd346a..2cd275cca9 100644 --- a/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ProbabilityRiskFactorDetails.tsx +++ b/frontend/src/features/Vessel/components/VesselSidebar/risk_factor/details/ProbabilityRiskFactorDetails.tsx @@ -91,7 +91,7 @@ const InfractionsResumeZone = styled.div` ` const Zone = styled.div` - margin: 0px 5px 10px 45px; + margin: 0 5px 10px 45px; text-align: left; display: flex; flex-wrap: wrap;