From 78f26a5b421155b5a4fab328398c17e375183511 Mon Sep 17 00:00:00 2001 From: stdavis Date: Wed, 28 Aug 2024 12:59:56 -0600 Subject: [PATCH] refactor: consolidate urls --- src/components/Filter.tsx | 4 ++-- src/components/MapContainer.tsx | 8 ++------ src/config.ts | 13 +++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/components/Filter.tsx b/src/components/Filter.tsx index bf2ad39..4b78cb7 100644 --- a/src/components/Filter.tsx +++ b/src/components/Filter.tsx @@ -1,6 +1,7 @@ import FeatureLayer from '@arcgis/core/layers/FeatureLayer'; import { Button, TextField } from '@ugrc/utah-design-system'; import { useEffect, useRef } from 'react'; +import config from '../config'; import { useFilter } from './contexts/FilterProvider'; import DateRange from './filters/DateRange'; import Purpose from './filters/Purpose'; @@ -20,8 +21,7 @@ export default function Filter(): JSX.Element { } stationsLayer.current = new FeatureLayer({ - // TODO: this needs to be switched out in favor of the AGS_HOST env var once we have UtahID wired up. - url: 'https://wrimaps.utah.gov/arcgis/rest/services/Electrofishing/Public/MapServer/0', + url: config.urls.stations, definitionExpression: emptyDefinition, }); addLayers([stationsLayer.current]); diff --git a/src/components/MapContainer.tsx b/src/components/MapContainer.tsx index 73f9232..2e25b7f 100644 --- a/src/components/MapContainer.tsx +++ b/src/components/MapContainer.tsx @@ -7,11 +7,7 @@ import { useEffect, useRef, useState } from 'react'; import { useMap } from './hooks'; import '@ugrc/layer-selector/src/LayerSelector.css'; - -const urls = { - landownership: - 'https://gis.trustlands.utah.gov/hosting/rest/services/Hosted/Land_Ownership_WM_VectorTile/VectorTileServer', -}; +import config from '../config'; type LayerFactory = { Factory: new () => __esri.Layer; @@ -73,7 +69,7 @@ export const MapContainer = ({ onClick }: { onClick?: __esri.ViewImmediateClickE 'Address Points', { Factory: VectorTileLayer, - url: urls.landownership, + url: config.urls.landownership, id: 'Land Ownership', opacity: 0.3, }, diff --git a/src/config.ts b/src/config.ts index a9dee12..62cba4d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,12 +3,17 @@ if (!import.meta.env.VITE_DATABASE_CONFIG) { } const databaseSecrets: { databaseName: string; user: string } = JSON.parse(import.meta.env.VITE_DATABASE_CONFIG); +// TODO: this should come from an env var once we get UtahID wired up +const arcgisServerHost = 'wrimaps.utah.gov'; +const mapService = `https://${arcgisServerHost}/arcgis/rest/services/Electrofishing/Public/MapServer`; + const config = { MIN_DESKTOP_WIDTH: 768, WEB_MERCATOR_WKID: 3857, MARKER_FILL_COLOR: [234, 202, 0, 0.5], MARKER_OUTLINE_COLOR: [77, 42, 84, 1], databaseSecrets, + fieldNames: { // common STATION_ID: 'STATION_ID', @@ -47,6 +52,14 @@ const config = { streams: 'UDWRStreams', lakes: 'UDWRLakes', }, + + urls: { + stations: `${mapService}/0`, + events: `${mapService}/1`, + fish: `${mapService}/2`, + landownership: + 'https://gis.trustlands.utah.gov/hosting/rest/services/Hosted/Land_Ownership_WM_VectorTile/VectorTileServer', + }, }; export default config;