From 7711383dea23d7ce4ece558e72f6d90c9d53bb02 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Thu, 21 Dec 2023 11:46:16 +0100 Subject: [PATCH] fix: put request in util/requests --- src/actions/map.js | 3 +-- src/components/app/FileMenu.js | 3 +-- src/util/apiDataStatisitcs.js | 8 -------- src/util/requests.js | 9 +++++++++ 4 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 src/util/apiDataStatisitcs.js diff --git a/src/actions/map.js b/src/actions/map.js index d831a51ec..3eaecd90f 100644 --- a/src/actions/map.js +++ b/src/actions/map.js @@ -1,8 +1,7 @@ import log from 'loglevel'; import * as types from '../constants/actionTypes'; import { getFallbackBasemap } from '../constants/basemaps'; -import { dataStatisticsMutation } from '../util/apiDataStatistics.js'; -import { fetchMap } from '../util/requests'; +import { fetchMap, dataStatisticsMutation } from '../util/requests'; import { addOrgUnitPaths } from '../util/helpers'; import { loadLayer } from './layers'; diff --git a/src/components/app/FileMenu.js b/src/components/app/FileMenu.js index 4e90d74de..c513de13c 100644 --- a/src/components/app/FileMenu.js +++ b/src/components/app/FileMenu.js @@ -8,8 +8,7 @@ import { useD2 } from '@dhis2/app-runtime-adapter-d2'; import { useDataMutation, useDataEngine } from '@dhis2/app-runtime'; import { newMap, tOpenMap, setMapProps } from '../../actions/map'; import { setAlert } from '../../actions/alerts'; -import { dataStatisticsMutation } from '../../util/apiDataStatistics.js'; -import { fetchMap } from '../../util/requests'; +import { fetchMap, dataStatisticsMutation } from '../../util/requests'; import { cleanMapConfig } from '../../util/favorites'; import { useSystemSettings } from '../SystemSettingsProvider'; diff --git a/src/util/apiDataStatisitcs.js b/src/util/apiDataStatisitcs.js deleted file mode 100644 index bf6145971..000000000 --- a/src/util/apiDataStatisitcs.js +++ /dev/null @@ -1,8 +0,0 @@ -export const dataStatisticsMutation = { - resource: 'dataStatistics', - params: ({ id }) => ({ - favorite: id, - eventType: 'MAP_VIEW', - }), - type: 'create', -}; diff --git a/src/util/requests.js b/src/util/requests.js index d8b86fc5b..f90be49f3 100644 --- a/src/util/requests.js +++ b/src/util/requests.js @@ -48,6 +48,15 @@ export const fetchMap = async (id, engine, keyDefaultBaseMap) => // }, // }; +export const dataStatisticsMutation = { + resource: 'dataStatistics', + params: ({ id }) => ({ + favorite: id, + eventType: 'MAP_VIEW', + }), + type: 'create', +}; + export const fetchOrgUnits = async () => { // TODO - use d2 until correct dataQuery format can be determined const d2 = await getD2();