Skip to content

Commit

Permalink
minor renames
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Nov 30, 2023
1 parent 370b8c2 commit 6a62729
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 40 deletions.
8 changes: 4 additions & 4 deletions frontend/src/containers/map/content/details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -63,4 +63,4 @@ const DataToolDetails: React.FC = () => {
);
};

export default DataToolDetails;
export default MapDetails;
4 changes: 2 additions & 2 deletions frontend/src/containers/map/content/details/table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<HTMLTableElement>();
const firstColumnRef = useRef<HTMLTableCellElement>(null);

Expand Down Expand Up @@ -125,4 +125,4 @@ const DataToolTable = ({ columns, data }) => {
);
};

export default DataToolTable;
export default MapTable;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const GlobalRegionalTable: React.FC = () => {

const queryClient = useQueryClient();

const dataToolLocation = queryClient.getQueryData<LocationGroupsDataItemAttributes>([
const mapLocation = queryClient.getQueryData<LocationGroupsDataItemAttributes>([
'locations',
locationCode,
]);
Expand All @@ -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,
},
},
}
Expand Down Expand Up @@ -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,
Expand All @@ -169,7 +169,7 @@ const GlobalRegionalTable: React.FC = () => {
globalContribution: globalContributionPercentage,
};
});
}, [dataToolLocation, locationsData]);
}, [mapLocation, locationsData]);

const tableData = useMemo(() => {
return applyFilters(parsedData, filters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +33,7 @@ type UseColumnsProps = {
};

const useColumns = ({ filters, onFiltersChange }: UseColumnsProps) => {
const searchParams = useDataToolSearchParams();
const searchParams = useMapSearchParams();
const { locationTypes: locationTypesOptions } = useFiltersOptions();

const tooltips = useTooltips();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NationalHighseasTable: React.FC = () => {

const queryClient = useQueryClient();

const dataToolLocation = queryClient.getQueryData<LocationGroupsDataItemAttributes>([
const mapLocation = queryClient.getQueryData<LocationGroupsDataItemAttributes>([
'locations',
locationCode,
]);
Expand Down Expand Up @@ -50,7 +50,7 @@ const NationalHighseasTable: React.FC = () => {
filters: {
location: {
code: {
$eq: dataToolLocation?.code,
$eq: mapLocation?.code,
},
},
},
Expand Down Expand Up @@ -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,
Expand All @@ -112,7 +112,7 @@ const NationalHighseasTable: React.FC = () => {
area: mpa?.area,
};
});
}, [coverageData, dataToolLocation]);
}, [coverageData, mapLocation]);

const tableData = useMemo(() => {
return applyFilters(parsedData, filters);
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/containers/map/content/index.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
Expand All @@ -18,4 +18,4 @@ const DataToolContent: React.FC = () => {
);
};

export default DataToolContent;
export default MapContent;
4 changes: 2 additions & 2 deletions frontend/src/containers/map/content/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -211,4 +211,4 @@ const DataToolMap: React.FC = () => {
);
};

export default DataToolMap;
export default MainMap;
4 changes: 2 additions & 2 deletions frontend/src/containers/map/content/map/popup/eez/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,7 +20,7 @@ const EEZLayerPopup = ({ locationId }) => {
const [rendered, setRendered] = useState(false);
const DATA_REF = useRef<Feature['properties'] | undefined>();
const { default: map } = useMap();
const searchParams = useDataToolSearchParams();
const searchParams = useMapSearchParams();

const popup = useAtomValue(popupAtom);
const layersInteractiveIds = useAtomValue(layersInteractiveIdsAtom);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,7 +20,7 @@ const EEZLayerPopup = ({ locationId }) => {
const [rendered, setRendered] = useState(false);
const DATA_REF = useRef<Feature['properties'] | undefined>();
const { default: map } = useMap();
const searchParams = useDataToolSearchParams();
const searchParams = useMapSearchParams();

const popup = useAtomValue(popupAtom);
const layersInteractiveIds = useAtomValue(layersInteractiveIdsAtom);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/containers/map/content/map/sync-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/containers/map/sidebar/details-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/containers/map/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocationGroupsDataItemAttributes>([
'locations',
Expand Down Expand Up @@ -70,4 +70,4 @@ const DataToolSidebar: React.FC = () => {
);
};

export default DataToolSidebar;
export default MapSidebar;
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -40,7 +40,7 @@ const LocationSelector: React.FC<LocationSelectorProps> = ({ className }) => {
'locations',
locationCode,
]);
const searchParams = useDataToolSearchParams();
const searchParams = useMapSearchParams();

const [locationPopoverOpen, setLocationPopoverOpen] = useState(false);
const { data: locationsData } = useGetLocations(
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/containers/map/sidebar/widgets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -31,4 +31,4 @@ const DataToolWidgets: React.FC = () => {
);
};

export default DataToolWidgets;
export default MapWidgets;
2 changes: 1 addition & 1 deletion frontend/src/containers/map/sync-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const DEFAULT_SYNC_CONTENT_SETTINGS: {
showDetails: false,
};

export const useSyncDataToolContentSettings = () => {
export const useSyncMapContentSettings = () => {
return useQueryState(
'content',
parseAsJson<typeof DEFAULT_SYNC_CONTENT_SETTINGS>().withDefault(DEFAULT_SYNC_CONTENT_SETTINGS)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion frontend/src/pages/map/[locationCode].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 6a62729

Please sign in to comment.