From 80a292a4712dab668ebe1ea99fb6db264ef7ec65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=ADa?= Date: Tue, 7 May 2024 15:03:15 +0200 Subject: [PATCH] map bounds changed --- client/cypress/downloads/downloads.html | Bin 4680 -> 0 bytes client/cypress/e2e/navigation.cy.ts | 30 +++++++++++------------ client/src/components/map/constants.ts | 2 +- client/src/containers/countries/item.tsx | 24 ++++-------------- client/src/containers/map/index.tsx | 19 ++++++++------ client/src/containers/projects/list.tsx | 10 +++++--- 6 files changed, 39 insertions(+), 46 deletions(-) delete mode 100644 client/cypress/downloads/downloads.html diff --git a/client/cypress/downloads/downloads.html b/client/cypress/downloads/downloads.html deleted file mode 100644 index 4e6e883a5f39548b6afb7fccbc6b9fda25d65ef0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4680 zcmZ{nbx;)EyT)PZ5?DZ38l;wz?hufMg$0pVSf%z$EDh4Nbax5TEs|1#gh)yX(kUH+ z^wL*4dcl4P;9UTb4e#J{u zzEumQ?l0Ak|2kLxbolPr(SqIBD^sk(%=TjZyll!NZ}n97xyr3AmX?O*jy%)#JtY#| zHF3qHS9FQ#R~omLYe!nnq(t)Fjs=gMlc~vV5C=2@Yhzs}j8XNzAv~2ug85Tq6OpE= z4cLhyJNap2P!=}p4cWa#v{IB{8@pBJh2jIlQo1G@R*d95%c)CR4;FveBse3(^$v`q zWE0mwQK@pgc#$_}c*!Sg_m3M4J^GuY;n~yi20ON>2;xni@8r|o_I^ls+_9zu*wh#c z9!Kw}0MN!zgPoh}!+hdXnYc!V^U*s8794(f@Ds!^rwS`s z2UP|=(jB{8Qrtioan;3OsEz%tv=n5f<=Jul6`V=!l^D1O&KXhjW;PkP>qRb`cYrkl zI3K)&o%SL6y-&t@#i*ZeN*ZVz;%+15NSw{<3{^McBH*BJTD(<*id$2d6|Bx3#vue> zTY^$#&fn#c0&g-jf2x%miE-j=+B~*@)nQ7+>Ya_!z zqfVDvrj?+S@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ig1MOX zt~14KhfXjR_hoIIbLyma~q_L-ha@=BH9Uq3#! z!sF~8()>OR!68378~jQ&n53_UUr2pIFf7gwd3}_06patL`_Oymcyx|mc#0Iv@7acA zUBF?Qwpq+#KNWa#xw>eAyI%)`X!wjIsCo$2Szf}!juUm?@fh7j>k#5-E_A4-)30EU zK7xD@is-M+k?a^vCa@~(9ZUwH*!&K<-ZiMvFej?D=X^RKA&QarJ*jsY{?+$BYI7E# ztp+6MP2y#d7lU&p$M)di*J(*PRz4FGHU7CYQ{QRCd`?05V0Y67M>dEu?^`TTztXQ; zTwF#HDZA)F^GXfg3o9pYbWBUN@14aoZqLq7K5a_(`-JX2YyhP(2q zb^BGtm}UbKI*ByxOTY!*2?yG4l2FE zUD)5VhK=1>u4gZPD7BZAUK+jk&yAQn<@3ez_^{@k=R5y>?iDZ}g5|hI1O75T55{tW;h By#oLM diff --git a/client/cypress/e2e/navigation.cy.ts b/client/cypress/e2e/navigation.cy.ts index 358cb4c6..a8380700 100644 --- a/client/cypress/e2e/navigation.cy.ts +++ b/client/cypress/e2e/navigation.cy.ts @@ -1,24 +1,24 @@ describe('navigation', () => { - // it('redirects to project page', () => { - // cy.visit('/').url().should('be.equal', 'http://localhost:3000/projects'); - // }); + it('redirects to project page', () => { + cy.visit('/').url().should('be.equal', 'http://localhost:3000/projects'); + }); - // it('access to project detail page and switch dashboard', () => { - // cy.visit('/').wait(10000); - // cy.get('[data-cy="projects-list-tab"]').should('exist'); - // cy.get('[data-cy="projects-list-tab"]').click(); - // cy.get('[data-cy="project-item-link"]').first().click(); - // // cy.get('button[data-cy="project-dashboard-button"]').click().wait(3000); - // // cy.get('[data-cy="project-dashboard"]').should('exist'); - // // cy.get('button[data-cy="project-dashboard-button"]').click(); - // // cy.get('[data-cy="project-dashboard"]').should('not.exist'); - // }); + it('access to project detail page and switch dashboard', () => { + cy.visit('/').wait(10000); + cy.get('[data-cy="projects-list-tab"]').should('exist'); + cy.get('[data-cy="projects-list-tab"]').click(); + cy.get('[data-cy="project-item-link"]').first().click(); + cy.get('button[data-cy="project-dashboard-button"]').click().wait(3000); + cy.get('[data-cy="project-dashboard"]').should('exist'); + cy.get('button[data-cy="project-dashboard-button"]').click(); + cy.get('[data-cy="project-dashboard"]').should('not.exist'); + }); it('access to country detail page', () => { cy.visit('/').wait(10000); cy.get('a[data-cy="sidebar-tab-countries"]').click({ force: true }).wait(1000); - // cy.get('[data-cy="country-item"]').first().click().wait(10000); - // cy.get('[data-cy="country-detail-name"]').should('exist'); + cy.get('[data-cy="country-item"]').first().click().wait(10000); + cy.get('[data-cy="country-detail-name"]').should('exist'); }); it('access to datasets and displays an info dialog', () => { diff --git a/client/src/components/map/constants.ts b/client/src/components/map/constants.ts index 503b0ffb..fed3f38e 100644 --- a/client/src/components/map/constants.ts +++ b/client/src/components/map/constants.ts @@ -8,4 +8,4 @@ export const DEFAULT_VIEW_STATE: Partial = { longitude: 0, }; -export const DEFAULT_BBOX: Bbox = [-84.05,-46.96,227.66,64.23]; +export const DEFAULT_BBOX: Bbox = [-84.05, -46.96, 227.66, 64.23]; diff --git a/client/src/containers/countries/item.tsx b/client/src/containers/countries/item.tsx index aa893421..d46141c1 100644 --- a/client/src/containers/countries/item.tsx +++ b/client/src/containers/countries/item.tsx @@ -1,25 +1,17 @@ 'use client'; -import { useCallback } from 'react'; - import Flag from 'react-world-flags'; -import { useRouter } from 'next/navigation'; - -import { useSetAtom } from 'jotai'; +import Link from 'next/link'; -import { tmpBboxAtom } from '@/store'; import { useGetCountryIndicatorFields } from '@/types/generated/country-indicator-field'; import { CountryListResponseDataItem } from '@/types/generated/strapi.schemas'; -import type { Bbox } from '@/types/map'; import { useSyncQueryParams } from '@/hooks/datasets'; export default function CountryItem({ data }: { data: CountryListResponseDataItem }) { - const setTempBbox = useSetAtom(tmpBboxAtom); - const queryParams = useSyncQueryParams(); - const { push } = useRouter(); + const queryParams = useSyncQueryParams({ bbox: true }); const { data: projectsCountIndicator } = useGetCountryIndicatorFields( { @@ -36,16 +28,10 @@ export default function CountryItem({ data }: { data: CountryListResponseDataIte } ); - const handleClick = useCallback(() => { - setTempBbox(data.attributes?.bbox as Bbox); - push(`/countries/${data.id}${queryParams}&bbox=${data.attributes?.bbox}`); - }, [data, push, queryParams, setTempBbox]); - return ( - + ); } diff --git a/client/src/containers/map/index.tsx b/client/src/containers/map/index.tsx index ca6f32f3..3c1ae145 100644 --- a/client/src/containers/map/index.tsx +++ b/client/src/containers/map/index.tsx @@ -23,6 +23,7 @@ import PopupContainer from '@/containers/map/popup'; import MapSettingsManager from '@/containers/map/settings/manager'; import Map from '@/components/map'; +import { DEFAULT_BBOX } from '@/components/map/constants'; import Controls from '@/components/map/controls'; import SettingsControl from '@/components/map/controls/settings'; import ZoomControl from '@/components/map/controls/zoom'; @@ -45,7 +46,7 @@ const DEFAULT_PROPS: CustomMapProps = { zoom: 2, pitch: 0, bearing: 0, - bounds: [68.711178, -11.476973, 131.333249, 21.087406], + bounds: DEFAULT_BBOX as Bbox, }, minZoom: 2, maxZoom: 20, @@ -72,7 +73,7 @@ export default function MapContainer() { const layersInteractiveIds = useAtomValue(layersInteractiveIdsAtom); const setHoveredProjectMap = useSetAtom(hoveredProjectMapAtom); const [cursor, setCursor] = useState<'grab' | 'pointer'>('grab'); - const [bboxURL, setBboxURL] = useSyncBbox(); + const [bboxFromURL, setBboxFromURL] = useSyncBbox(); const [tmpBbox, setTmpBbox] = useAtom(tmpBboxAtom); const sidebarOpen = useAtomValue(openAtom); @@ -108,6 +109,7 @@ export default function MapContainer() { ); const handleMapViewStateChange = useCallback(() => { + console.log('handle view state'); if (map) { const b = map .getBounds() @@ -116,10 +118,10 @@ export default function MapContainer() { .map((v: number) => { return parseFloat(v.toFixed(2)); }) as Bbox; - setBboxURL(b); + setBboxFromURL(b); setTmpBbox(null); } - }, [map, setBboxURL, setTmpBbox]); + }, [map, setBboxFromURL, setTmpBbox]); const handleMapClick = useCallback( (e: MapLayerMouseEvent) => { @@ -266,11 +268,14 @@ export default function MapContainer() { data-cy="map" initialViewState={{ ...initialViewState, - ...(bboxURL && { - bounds: bboxURL as LngLatBoundsLike, + ...(bboxFromURL && { + bounds: bboxFromURL as LngLatBoundsLike, }), }} - bounds={tmpBounds} + bounds={{ + ...tmpBounds, + bbox: bboxFromURL as Bbox, + }} cursor={cursor} minZoom={minZoom} maxZoom={maxZoom} diff --git a/client/src/containers/projects/list.tsx b/client/src/containers/projects/list.tsx index 1617446b..be8f8b03 100644 --- a/client/src/containers/projects/list.tsx +++ b/client/src/containers/projects/list.tsx @@ -2,6 +2,7 @@ import { MouseEvent, useCallback, useState } from 'react'; +import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useSetAtom } from 'jotai'; @@ -31,7 +32,7 @@ export default function ProjectsList() { const [filtersSettings] = useSyncFilters(); const setHoveredProjectList = useSetAtom(hoveredProjectMapAtom); const router = useRouter(); - const queryParams = useSyncQueryParams(); + const queryParams = useSyncQueryParams({ bbox: true }); const { data, isFetching, isFetched, isError } = useGetProjects( { @@ -207,17 +208,18 @@ export default function ProjectsList() {
{data && data.map((project) => ( - + ))}