diff --git a/apps/fishing-map/features/dataviews/dataviews.utils.ts b/apps/fishing-map/features/dataviews/dataviews.utils.ts index dbcc8300b8..4390951f41 100644 --- a/apps/fishing-map/features/dataviews/dataviews.utils.ts +++ b/apps/fishing-map/features/dataviews/dataviews.utils.ts @@ -25,6 +25,7 @@ import { getActiveDatasetsInDataview, isPrivateDataset, } from 'features/datasets/datasets.utils' +import { INCLUDES_RELATED_SELF_REPORTED_INFO_ID } from 'features/vessel/vessel.config' // used in workspaces with encounter events layers export const ENCOUNTER_EVENTS_SOURCE_ID = 'encounter' @@ -57,7 +58,7 @@ export const getVesselInfoDataviewInstanceDatasetConfig = ( { id: 'dataset', value: info }, { id: 'includes', - value: ['POTENTIAL_RELATED_SELF_REPORTED_INFO'], + value: [INCLUDES_RELATED_SELF_REPORTED_INFO_ID], }, ], endpoint: EndpointId.Vessel, diff --git a/apps/fishing-map/features/map/map.slice.ts b/apps/fishing-map/features/map/map.slice.ts index a1b34596ba..7ff4896177 100644 --- a/apps/fishing-map/features/map/map.slice.ts +++ b/apps/fishing-map/features/map/map.slice.ts @@ -47,6 +47,7 @@ import { selectEventsDataviews, selectVesselGroupDataviews, } from 'features/dataviews/selectors/dataviews.categories.selectors' +import { INCLUDES_RELATED_SELF_REPORTED_INFO_ID } from 'features/vessel/vessel.config' export const MAX_TOOLTIP_LIST = 5 @@ -197,7 +198,7 @@ const getVesselInfoEndpoint = (vesselDatasets: Dataset[], vesselIds: string[]) = }, { id: 'includes', - value: ['POTENTIAL_RELATED_SELF_REPORTED_INFO'], + value: [INCLUDES_RELATED_SELF_REPORTED_INFO_ID], }, ], } diff --git a/apps/fishing-map/features/modals/Modals.tsx b/apps/fishing-map/features/modals/Modals.tsx index 86c2ee2501..8502f340ff 100644 --- a/apps/fishing-map/features/modals/Modals.tsx +++ b/apps/fishing-map/features/modals/Modals.tsx @@ -12,7 +12,7 @@ import { ROOT_DOM_ELEMENT } from 'data/config' import useSecretMenu, { useSecretKeyboardCombo } from 'hooks/secret-menu.hooks' import { selectBigQueryActive, toggleBigQueryMenu } from 'features/bigquery/bigquery.slice' import { selectDownloadActivityAreaKey } from 'features/download/downloadActivity.slice' -import { selectVesselGroupModalOpen } from 'features/vessel-groups/vessel-groups.slice' +import { selectVesselGroupModalOpen } from 'features/vessel-groups/vessel-groups-modal.slice' import GFWOnly from 'features/user/GFWOnly' import { useAppDispatch } from 'features/app/app.hooks' import { selectDatasetUploadModalOpen, setModalOpen } from 'features/modals/modals.slice' diff --git a/apps/fishing-map/features/modals/modals.selectors.ts b/apps/fishing-map/features/modals/modals.selectors.ts index 2584b1ba59..9333e744d7 100644 --- a/apps/fishing-map/features/modals/modals.selectors.ts +++ b/apps/fishing-map/features/modals/modals.selectors.ts @@ -10,7 +10,7 @@ import { selectLayerLibraryModalOpen, selectScreenshotModalOpen, } from 'features/modals/modals.slice' -import { selectVesselGroupModalOpen } from 'features/vessel-groups/vessel-groups.slice' +import { selectVesselGroupModalOpen } from 'features/vessel-groups/vessel-groups-modal.slice' import { WelcomeContentKey } from 'features/welcome/welcome.content' import { selectLocationCategory, diff --git a/apps/fishing-map/features/reports/activity/vessels/ReportVesselsTableFooter.tsx b/apps/fishing-map/features/reports/activity/vessels/ReportVesselsTableFooter.tsx index f3bf986ed7..52da554920 100644 --- a/apps/fishing-map/features/reports/activity/vessels/ReportVesselsTableFooter.tsx +++ b/apps/fishing-map/features/reports/activity/vessels/ReportVesselsTableFooter.tsx @@ -4,6 +4,7 @@ import cx from 'classnames' import { Fragment, useMemo } from 'react' import { unparse as unparseCSV } from 'papaparse' import { saveAs } from 'file-saver' +import { uniq } from 'es-toolkit' import { Button, IconButton } from '@globalfishingwatch/ui-components' import I18nNumber from 'features/i18n/i18nNumber' import { useLocationConnect } from 'routes/routes.hook' @@ -11,10 +12,7 @@ import VesselGroupAddButton from 'features/vessel-groups/VesselGroupAddButton' import { selectTimeRange } from 'features/app/selectors/app.timebar.selectors' import { REPORT_SHOW_MORE_VESSELS_PER_PAGE, REPORT_VESSELS_PER_PAGE } from 'data/config' import { useAppDispatch } from 'features/app/app.hooks' -import { - setVesselGroupConfirmationMode, - setVesselGroupCurrentDataviewIds, -} from 'features/vessel-groups/vessel-groups.slice' +import { setVesselGroupConfirmationMode } from 'features/vessel-groups/vessel-groups-modal.slice' import { selectActiveActivityAndDetectionsDataviews } from 'features/dataviews/selectors/dataviews.selectors' import { TrackCategory, trackEvent } from 'features/app/analytics.hooks' import { selectReportVesselFilter } from 'features/reports/areas/area-reports.config.selectors' @@ -22,10 +20,7 @@ import { selectReportAreaName, ReportVesselWithDatasets, } from 'features/reports/areas/area-reports.selectors' -import { - parseReportVesselsToIdentity, - getVesselsFiltered, -} from 'features/reports/areas/area-reports.utils' +import { getVesselsFiltered } from 'features/reports/areas/area-reports.utils' import styles from './ReportVesselsTableFooter.module.css' import { selectReportVesselsListWithAllInfo, @@ -51,8 +46,15 @@ export default function ReportVesselsTableFooter({ reportName }: ReportVesselsTa const heatmapDataviews = useSelector(selectActiveActivityAndDetectionsDataviews) const { start, end } = useSelector(selectTimeRange) - const vesselGroupIdentityVessels = useMemo(() => { - return parseReportVesselsToIdentity(reportVesselFilter ? allFilteredVessels : allVessels) + const vesselGroupVessels = useMemo(() => { + const vessels = reportVesselFilter ? allFilteredVessels : allVessels + if (!vessels?.length) { + return null + } + return { + ids: vessels?.flatMap((v) => v.id || v.vesselId || []), + datasets: uniq(vessels.flatMap((v) => v.dataset || [])), + } }, [allFilteredVessels, allVessels, reportVesselFilter]) const onDownloadVesselsClick = () => { @@ -99,11 +101,7 @@ export default function ReportVesselsTableFooter({ reportName }: ReportVesselsTa }) } const onAddToVesselGroup = () => { - const dataviewIds = heatmapDataviews.map(({ id }) => id) dispatch(setVesselGroupConfirmationMode('saveAndSeeInWorkspace')) - if (dataviewIds?.length) { - dispatch(setVesselGroupCurrentDataviewIds(dataviewIds)) - } trackEvent({ category: TrackCategory.VesselGroups, action: 'add_to_vessel_group', @@ -171,7 +169,8 @@ export default function ReportVesselsTableFooter({ reportName }: ReportVesselsTa