diff --git a/packages/earth-map/src/components/collection/collection-new/CollectionNew.tsx b/packages/earth-map/src/components/collection/collection-new/CollectionNew.tsx index 7a34e280..011be187 100644 --- a/packages/earth-map/src/components/collection/collection-new/CollectionNew.tsx +++ b/packages/earth-map/src/components/collection/collection-new/CollectionNew.tsx @@ -20,11 +20,12 @@ import React, { useState } from 'react'; import { useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; -import { back, push, replace } from 'redux-first-router'; +import { replace } from 'redux-first-router'; +import Link from 'redux-first-router-link'; import { Card, Input, setupErrors } from '@marapp/earth-shared'; -import { IRouter } from '../../../modules/router/model'; +import { EarthRoutes, IRouter } from '../../../modules/router/model'; import PlacesService from '../../../services/PlacesService'; interface IProps { @@ -34,6 +35,7 @@ interface IProps { const CollectionNew = (props: IProps) => { const { privateGroups, router } = props; + const { prev } = router; const { t } = useTranslation(); const canCreateCollection = !!privateGroups.length; const [saveError, setSaveError] = useState(null); @@ -57,19 +59,6 @@ const CollectionNew = (props: IProps) => { } }; - const onCancel = () => { - // When navigating back to earth view keep track of the current coordinates and active layers, if available - const canGoBack = !!router.prev.pathname; - - if (canGoBack) { - back(); - } - // if the user just hit the /collection/new from the start - else { - push('/earth'); - } - }; - return (
{ > {t('Create Collection')} - +
); diff --git a/packages/earth-map/src/components/url/component.tsx b/packages/earth-map/src/components/url/component.tsx index 9d88a97b..a81e0f26 100644 --- a/packages/earth-map/src/components/url/component.tsx +++ b/packages/earth-map/src/components/url/component.tsx @@ -67,6 +67,10 @@ interface IUrl { paramsFromUrl: {}; } +/** + * Dispatches actions based on with payload created from query params + * TODO: Could be removed entirely if we find another way to apply side effects based on query params + */ class UrlComponent extends PureComponent { public componentDidMount() { const { urlProps, paramsFromUrl } = this.props; diff --git a/packages/earth-map/src/modules/router/model.ts b/packages/earth-map/src/modules/router/model.ts index ed27d408..03c643e6 100644 --- a/packages/earth-map/src/modules/router/model.ts +++ b/packages/earth-map/src/modules/router/model.ts @@ -2,6 +2,7 @@ export interface IRouter { type: EarthRoutes; payload: any; prev: any; + query: any; } export enum EarthRoutes { diff --git a/packages/earth-map/src/routes.tsx b/packages/earth-map/src/routes.tsx index 67d31d67..d81aaa8b 100644 --- a/packages/earth-map/src/routes.tsx +++ b/packages/earth-map/src/routes.tsx @@ -142,7 +142,9 @@ export const CONFIG = { basename: MAP_BASE_URL, location: 'router', querySerializer: { - stringify: qs.stringify, + stringify: (params) => { + return qs.stringify(params, { arrayFormat: 'comma' }); + }, parse: (url) => { return qs.parse(url, { arrayFormat: 'comma',