From 6a62729c6bfcf95b88157515c7f37203285af8bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Mu=C3=B1oz?= Date: Thu, 30 Nov 2023 12:04:33 +0100 Subject: [PATCH] minor renames --- frontend/src/containers/map/content/details/index.tsx | 8 ++++---- .../src/containers/map/content/details/table/index.tsx | 4 ++-- .../content/details/tables/global-regional/index.tsx | 10 +++++----- .../details/tables/global-regional/useColumns.tsx | 4 ++-- .../content/details/tables/national-highseas/index.tsx | 8 ++++---- frontend/src/containers/map/content/index.tsx | 8 ++++---- frontend/src/containers/map/content/map/index.tsx | 4 ++-- .../src/containers/map/content/map/popup/eez/index.tsx | 4 ++-- .../containers/map/content/map/popup/regions/index.tsx | 4 ++-- .../src/containers/map/content/map/sync-settings.ts | 2 +- .../containers/map/sidebar/details-button/index.tsx | 4 ++-- frontend/src/containers/map/sidebar/index.tsx | 8 ++++---- .../containers/map/sidebar/location-selector/index.tsx | 4 ++-- frontend/src/containers/map/sidebar/widgets/index.tsx | 4 ++-- frontend/src/containers/map/sync-settings.ts | 2 +- frontend/src/layouts/{data-tool.tsx => map.tsx} | 0 frontend/src/pages/map/[locationCode].tsx | 2 +- 17 files changed, 40 insertions(+), 40 deletions(-) rename frontend/src/layouts/{data-tool.tsx => map.tsx} (100%) diff --git a/frontend/src/containers/map/content/details/index.tsx b/frontend/src/containers/map/content/details/index.tsx index 710d4999..9ff995d3 100644 --- a/frontend/src/containers/map/content/details/index.tsx +++ b/frontend/src/containers/map/content/details/index.tsx @@ -6,11 +6,11 @@ import { useQueryClient } from '@tanstack/react-query'; import { Button } from '@/components/ui/button'; import tablesSettings from '@/containers/map/content/details/tables-settings'; -import { useSyncDataToolContentSettings } from '@/containers/map/sync-settings'; +import { useSyncMapContentSettings } from '@/containers/map/sync-settings'; import { LocationGroupsDataItemAttributes } from '@/types/generated/strapi.schemas'; -const DataToolDetails: React.FC = () => { - const [, setSettings] = useSyncDataToolContentSettings(); +const MapDetails: React.FC = () => { + const [, setSettings] = useSyncMapContentSettings(); const { query: { locationCode }, } = useRouter(); @@ -63,4 +63,4 @@ const DataToolDetails: React.FC = () => { ); }; -export default DataToolDetails; +export default MapDetails; diff --git a/frontend/src/containers/map/content/details/table/index.tsx b/frontend/src/containers/map/content/details/table/index.tsx index dc45881f..b53e97af 100644 --- a/frontend/src/containers/map/content/details/table/index.tsx +++ b/frontend/src/containers/map/content/details/table/index.tsx @@ -10,7 +10,7 @@ import { import { cn } from '@/lib/classnames'; // ! todo: type columns,data properly -const DataToolTable = ({ columns, data }) => { +const MapTable = ({ columns, data }) => { const tableRef = useRef(); const firstColumnRef = useRef(null); @@ -125,4 +125,4 @@ const DataToolTable = ({ columns, data }) => { ); }; -export default DataToolTable; +export default MapTable; diff --git a/frontend/src/containers/map/content/details/tables/global-regional/index.tsx b/frontend/src/containers/map/content/details/tables/global-regional/index.tsx index ba7f0a46..5763f1fc 100644 --- a/frontend/src/containers/map/content/details/tables/global-regional/index.tsx +++ b/frontend/src/containers/map/content/details/tables/global-regional/index.tsx @@ -20,7 +20,7 @@ const GlobalRegionalTable: React.FC = () => { const queryClient = useQueryClient(); - const dataToolLocation = queryClient.getQueryData([ + const mapLocation = queryClient.getQueryData([ 'locations', locationCode, ]); @@ -40,11 +40,11 @@ const GlobalRegionalTable: React.FC = () => { const { data: locationsData }: { data: LocationListResponseDataItem[] } = useGetLocations( { filters: - dataToolLocation?.type === 'region' + mapLocation?.type === 'region' ? { groups: { code: { - $eq: dataToolLocation?.code, + $eq: mapLocation?.code, }, }, } @@ -154,7 +154,7 @@ const GlobalRegionalTable: React.FC = () => { const lfpHighProtectedPercentage = (lfpHighProtectedArea * 100) / location.totalMarineArea; // Global contributions calculations - const globalContributionPercentage = (protectedArea * 100) / dataToolLocation.totalMarineArea; + const globalContributionPercentage = (protectedArea * 100) / mapLocation.totalMarineArea; return { location: location.name, @@ -169,7 +169,7 @@ const GlobalRegionalTable: React.FC = () => { globalContribution: globalContributionPercentage, }; }); - }, [dataToolLocation, locationsData]); + }, [mapLocation, locationsData]); const tableData = useMemo(() => { return applyFilters(parsedData, filters); diff --git a/frontend/src/containers/map/content/details/tables/global-regional/useColumns.tsx b/frontend/src/containers/map/content/details/tables/global-regional/useColumns.tsx index efb19000..737fc0fc 100644 --- a/frontend/src/containers/map/content/details/tables/global-regional/useColumns.tsx +++ b/frontend/src/containers/map/content/details/tables/global-regional/useColumns.tsx @@ -12,7 +12,7 @@ import SortingButton from '@/containers/map/content/details/table/sorting-button import TooltipButton from '@/containers/map/content/details/table/tooltip-button'; import useFiltersOptions from '@/containers/map/content/details/tables/global-regional/useFiltersOptions'; import useTooltips from '@/containers/map/content/details/tables/global-regional/useTooltips'; -import { useDataToolSearchParams } from '@/containers/map/content/map/sync-settings'; +import { useMapSearchParams } from '@/containers/map/content/map/sync-settings'; export type GlobalRegionalTableColumns = { location: string; @@ -33,7 +33,7 @@ type UseColumnsProps = { }; const useColumns = ({ filters, onFiltersChange }: UseColumnsProps) => { - const searchParams = useDataToolSearchParams(); + const searchParams = useMapSearchParams(); const { locationTypes: locationTypesOptions } = useFiltersOptions(); const tooltips = useTooltips(); diff --git a/frontend/src/containers/map/content/details/tables/national-highseas/index.tsx b/frontend/src/containers/map/content/details/tables/national-highseas/index.tsx index 8e545653..64b0205d 100644 --- a/frontend/src/containers/map/content/details/tables/national-highseas/index.tsx +++ b/frontend/src/containers/map/content/details/tables/national-highseas/index.tsx @@ -20,7 +20,7 @@ const NationalHighseasTable: React.FC = () => { const queryClient = useQueryClient(); - const dataToolLocation = queryClient.getQueryData([ + const mapLocation = queryClient.getQueryData([ 'locations', locationCode, ]); @@ -50,7 +50,7 @@ const NationalHighseasTable: React.FC = () => { filters: { location: { code: { - $eq: dataToolLocation?.code, + $eq: mapLocation?.code, }, }, }, @@ -100,7 +100,7 @@ const NationalHighseasTable: React.FC = () => { const fishingProtectionLevel = coverageStats?.fishing_protection_level?.data?.attributes; // Calculate coverage percentage - const coveragePercentage = (coverageStats.area / dataToolLocation.totalMarineArea) * 100; + const coveragePercentage = (coverageStats.area / mapLocation.totalMarineArea) * 100; return { protectedArea: mpa?.name, @@ -112,7 +112,7 @@ const NationalHighseasTable: React.FC = () => { area: mpa?.area, }; }); - }, [coverageData, dataToolLocation]); + }, [coverageData, mapLocation]); const tableData = useMemo(() => { return applyFilters(parsedData, filters); diff --git a/frontend/src/containers/map/content/index.tsx b/frontend/src/containers/map/content/index.tsx index 21e03d4c..ba29b8e4 100644 --- a/frontend/src/containers/map/content/index.tsx +++ b/frontend/src/containers/map/content/index.tsx @@ -1,10 +1,10 @@ -import { useSyncDataToolContentSettings } from '@/containers/map/sync-settings'; +import { useSyncMapContentSettings } from '@/containers/map/sync-settings'; import Details from './details'; import Map from './map'; -const DataToolContent: React.FC = () => { - const [{ showDetails }] = useSyncDataToolContentSettings(); +const MapContent: React.FC = () => { + const [{ showDetails }] = useSyncMapContentSettings(); return ( <> @@ -18,4 +18,4 @@ const DataToolContent: React.FC = () => { ); }; -export default DataToolContent; +export default MapContent; diff --git a/frontend/src/containers/map/content/map/index.tsx b/frontend/src/containers/map/content/map/index.tsx index 11ba0c2f..74f0943d 100644 --- a/frontend/src/containers/map/content/map/index.tsx +++ b/frontend/src/containers/map/content/map/index.tsx @@ -31,7 +31,7 @@ const LayerManager = dynamic(() => import('@/containers/map/content/map/layer-ma ssr: false, }); -const DataToolMap: React.FC = () => { +const MainMap: React.FC = () => { const [{ bbox: URLBbox }, setMapSettings] = useSyncMapSettings(); const { default: map } = useMap(); const drawState = useAtomValue(drawStateAtom); @@ -211,4 +211,4 @@ const DataToolMap: React.FC = () => { ); }; -export default DataToolMap; +export default MainMap; diff --git a/frontend/src/containers/map/content/map/popup/eez/index.tsx b/frontend/src/containers/map/content/map/popup/eez/index.tsx index abce571e..6ad21d51 100644 --- a/frontend/src/containers/map/content/map/popup/eez/index.tsx +++ b/frontend/src/containers/map/content/map/popup/eez/index.tsx @@ -8,7 +8,7 @@ import type { Feature } from 'geojson'; import { useAtomValue } from 'jotai'; import { PAGES } from '@/constants/pages'; -import { useDataToolSearchParams } from '@/containers/map/content/map/sync-settings'; +import { useMapSearchParams } from '@/containers/map/content/map/sync-settings'; import { layersInteractiveIdsAtom, popupAtom } from '@/containers/map/store'; import { useGetLayersId } from '@/types/generated/layer'; import { useGetLocations } from '@/types/generated/location'; @@ -20,7 +20,7 @@ const EEZLayerPopup = ({ locationId }) => { const [rendered, setRendered] = useState(false); const DATA_REF = useRef(); const { default: map } = useMap(); - const searchParams = useDataToolSearchParams(); + const searchParams = useMapSearchParams(); const popup = useAtomValue(popupAtom); const layersInteractiveIds = useAtomValue(layersInteractiveIdsAtom); diff --git a/frontend/src/containers/map/content/map/popup/regions/index.tsx b/frontend/src/containers/map/content/map/popup/regions/index.tsx index 11dbcbb8..aefaedb9 100644 --- a/frontend/src/containers/map/content/map/popup/regions/index.tsx +++ b/frontend/src/containers/map/content/map/popup/regions/index.tsx @@ -8,7 +8,7 @@ import type { Feature } from 'geojson'; import { useAtomValue } from 'jotai'; import { PAGES } from '@/constants/pages'; -import { useDataToolSearchParams } from '@/containers/map/content/map/sync-settings'; +import { useMapSearchParams } from '@/containers/map/content/map/sync-settings'; import { layersInteractiveIdsAtom, popupAtom } from '@/containers/map/store'; import { useGetLayersId } from '@/types/generated/layer'; import { useGetLocations } from '@/types/generated/location'; @@ -20,7 +20,7 @@ const EEZLayerPopup = ({ locationId }) => { const [rendered, setRendered] = useState(false); const DATA_REF = useRef(); const { default: map } = useMap(); - const searchParams = useDataToolSearchParams(); + const searchParams = useMapSearchParams(); const popup = useAtomValue(popupAtom); const layersInteractiveIds = useAtomValue(layersInteractiveIdsAtom); diff --git a/frontend/src/containers/map/content/map/sync-settings.ts b/frontend/src/containers/map/content/map/sync-settings.ts index e8c31c19..36a326d5 100644 --- a/frontend/src/containers/map/content/map/sync-settings.ts +++ b/frontend/src/containers/map/content/map/sync-settings.ts @@ -34,7 +34,7 @@ export const useSyncMapLayerSettings = () => { // ? updated via next-usequerystate, so we rely in next-usequerystate to retrieve those searchParams as well // ? this might be an issue with next-usequerystate, but for now we can make it work this way. // ! if you are using syncing a new state through next-usequerystate in the data-tool's map page, remember to register it here -export const useDataToolSearchParams = () => { +export const useMapSearchParams = () => { const [settings] = useSyncMapSettings(); const [layers] = useSyncMapLayers(); const [layerSettings] = useSyncMapLayerSettings(); diff --git a/frontend/src/containers/map/sidebar/details-button/index.tsx b/frontend/src/containers/map/sidebar/details-button/index.tsx index 29b197e2..1b42a139 100644 --- a/frontend/src/containers/map/sidebar/details-button/index.tsx +++ b/frontend/src/containers/map/sidebar/details-button/index.tsx @@ -3,11 +3,11 @@ import { ComponentProps, useCallback } from 'react'; import { ArrowRight } from 'lucide-react'; import { Button } from '@/components/ui/button'; -import { useSyncDataToolContentSettings } from '@/containers/map/sync-settings'; +import { useSyncMapContentSettings } from '@/containers/map/sync-settings'; import { cn } from '@/lib/classnames'; const DetailsButton: React.FC = () => { - const [{ showDetails }, setSettings] = useSyncDataToolContentSettings(); + const [{ showDetails }, setSettings] = useSyncMapContentSettings(); const handleButtonClick = useCallback(() => { setSettings((prevSettings) => ({ ...prevSettings, showDetails: !prevSettings.showDetails })); diff --git a/frontend/src/containers/map/sidebar/index.tsx b/frontend/src/containers/map/sidebar/index.tsx index 2743845c..1f60ab01 100644 --- a/frontend/src/containers/map/sidebar/index.tsx +++ b/frontend/src/containers/map/sidebar/index.tsx @@ -10,18 +10,18 @@ import { sidebarAtom } from '@/containers/map/store'; import { cn } from '@/lib/classnames'; import { LocationGroupsDataItemAttributes } from '@/types/generated/strapi.schemas'; -import { useSyncDataToolContentSettings } from '../sync-settings'; +import { useSyncMapContentSettings } from '../sync-settings'; import DetailsButton from './details-button'; import LocationSelector from './location-selector'; import Widgets from './widgets'; -const DataToolSidebar: React.FC = () => { +const MapSidebar: React.FC = () => { const { query: { locationCode }, } = useRouter(); const queryClient = useQueryClient(); - const [{ showDetails }] = useSyncDataToolContentSettings(); + const [{ showDetails }] = useSyncMapContentSettings(); const location = queryClient.getQueryData([ 'locations', @@ -70,4 +70,4 @@ const DataToolSidebar: React.FC = () => { ); }; -export default DataToolSidebar; +export default MapSidebar; diff --git a/frontend/src/containers/map/sidebar/location-selector/index.tsx b/frontend/src/containers/map/sidebar/location-selector/index.tsx index 891af404..c6917139 100644 --- a/frontend/src/containers/map/sidebar/location-selector/index.tsx +++ b/frontend/src/containers/map/sidebar/location-selector/index.tsx @@ -20,7 +20,7 @@ import { cn } from '@/lib/classnames'; import { useGetLocations } from '@/types/generated/location'; import { LocationGroupsDataItemAttributes } from '@/types/generated/strapi.schemas'; -import { useDataToolSearchParams } from '../../content/map/sync-settings'; +import { useMapSearchParams } from '../../content/map/sync-settings'; type LocationSelectorProps = { className: HTMLDivElement['className']; @@ -40,7 +40,7 @@ const LocationSelector: React.FC = ({ className }) => { 'locations', locationCode, ]); - const searchParams = useDataToolSearchParams(); + const searchParams = useMapSearchParams(); const [locationPopoverOpen, setLocationPopoverOpen] = useState(false); const { data: locationsData } = useGetLocations( diff --git a/frontend/src/containers/map/sidebar/widgets/index.tsx b/frontend/src/containers/map/sidebar/widgets/index.tsx index 234454d9..af7a7c9b 100644 --- a/frontend/src/containers/map/sidebar/widgets/index.tsx +++ b/frontend/src/containers/map/sidebar/widgets/index.tsx @@ -9,7 +9,7 @@ import HabitatWidget from './habitat'; import MarineConservationWidget from './marine-conservation'; import ProtectionTypesWidget from './protection-types'; -const DataToolWidgets: React.FC = () => { +const MapWidgets: React.FC = () => { const { query: { locationCode }, } = useRouter(); @@ -31,4 +31,4 @@ const DataToolWidgets: React.FC = () => { ); }; -export default DataToolWidgets; +export default MapWidgets; diff --git a/frontend/src/containers/map/sync-settings.ts b/frontend/src/containers/map/sync-settings.ts index f3122ea4..97344c51 100644 --- a/frontend/src/containers/map/sync-settings.ts +++ b/frontend/src/containers/map/sync-settings.ts @@ -7,7 +7,7 @@ const DEFAULT_SYNC_CONTENT_SETTINGS: { showDetails: false, }; -export const useSyncDataToolContentSettings = () => { +export const useSyncMapContentSettings = () => { return useQueryState( 'content', parseAsJson().withDefault(DEFAULT_SYNC_CONTENT_SETTINGS) diff --git a/frontend/src/layouts/data-tool.tsx b/frontend/src/layouts/map.tsx similarity index 100% rename from frontend/src/layouts/data-tool.tsx rename to frontend/src/layouts/map.tsx diff --git a/frontend/src/pages/map/[locationCode].tsx b/frontend/src/pages/map/[locationCode].tsx index d9c6fba4..7bb85d82 100644 --- a/frontend/src/pages/map/[locationCode].tsx +++ b/frontend/src/pages/map/[locationCode].tsx @@ -3,7 +3,7 @@ import type { GetServerSideProps } from 'next'; import Content from '@/containers/map/content'; import Sidebar from '@/containers/map/sidebar'; -import Layout from '@/layouts/data-tool'; +import Layout from '@/layouts/map'; import { getLocations } from '@/types/generated/location'; import { Location, LocationGroupsDataItemAttributes } from '@/types/generated/strapi.schemas';