From 12d0fb53807e6a689ff25dac0e334ced5fb26299 Mon Sep 17 00:00:00 2001 From: stdavis Date: Fri, 23 Aug 2024 12:31:09 -0600 Subject: [PATCH] feat: add logged out state and refactor filter into it's own component Ref #182 --- src/App.tsx | 176 ++++++++++---------------------------- src/components/Filter.tsx | 85 ++++++++++++++++++ 2 files changed, 131 insertions(+), 130 deletions(-) create mode 100644 src/components/Filter.tsx diff --git a/src/App.tsx b/src/App.tsx index dc5d4c8..da496fd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,31 +1,22 @@ import esriConfig from '@arcgis/core/config'; import Graphic from '@arcgis/core/Graphic'; -import FeatureLayer from '@arcgis/core/layers/FeatureLayer.js'; import Viewpoint from '@arcgis/core/Viewpoint.js'; -import { - Button, - Checkbox, - CheckboxGroup, - Drawer, - Footer, - Header, - Sherlock, - TextField, - masqueradeProvider, -} from '@ugrc/utah-design-system'; +import { Button, Drawer, Footer, Header, Sherlock, masqueradeProvider } from '@ugrc/utah-design-system'; import PropTypes from 'prop-types'; -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { useOverlayTrigger } from 'react-aria'; import { ErrorBoundary } from 'react-error-boundary'; import { useOverlayTriggerState } from 'react-stately'; import { MapContainer } from './components'; import { useAnalytics, useFirebaseApp } from './components/contexts'; +import Filter from './components/Filter'; import { useMap } from './components/hooks'; import { DnrLogo } from './components/Logo'; import config from './config'; const version = import.meta.env.PACKAGE_VERSION; -const secureServiceUrl = import.meta.env.VITE_PROXY_URL; + +console.log('application version:', version); const ErrorFallback = ({ error }: { error: Error }) => { return ( @@ -62,13 +53,10 @@ const links = [ const url = 'https://masquerade.ugrc.utah.gov/arcgis/rest/services/UtahLocator/GeocodeServer'; const wkid = 26912; -// TODO!: replace partial list with actual list -const purpose = ['Depletion estimate', 'Mark-Recapture', 'Disease certification', 'Genetics', 'Other']; - export default function App() { const app = useFirebaseApp(); const logEvent = useAnalytics(); - const { zoom, placeGraphic, addLayers } = useMap(); + const { zoom, placeGraphic } = useMap(); const sideBarState = useOverlayTriggerState({ defaultOpen: window.innerWidth >= config.MIN_DESKTOP_WIDTH }); const sideBarTriggerProps = useOverlayTrigger( { @@ -95,36 +83,6 @@ export default function App() { initPerformance(); }, [app]); - // add public layers - useEffect(() => { - const streams = new FeatureLayer({ - url: `${secureServiceUrl}/reference/0`, - id: 'streams', - }); - - const lakes = new FeatureLayer({ - url: `${secureServiceUrl}/reference/1`, - id: 'lakes', - }); - - const stations = new FeatureLayer({ - url: `${secureServiceUrl}/mapservice/0`, - id: 'stations', - }); - - const events = new FeatureLayer({ - url: `${secureServiceUrl}/mapservice/1`, - id: 'stations', - }); - - const fish = new FeatureLayer({ - url: `${secureServiceUrl}/mapservice/2`, - id: 'stations', - }); - - addLayers([streams, lakes, stations, events, fish]); - }, [addLayers]); - const onSherlockMatch = (graphics: Graphic[]) => { // summary: // Zooms to the passed in graphic(s). @@ -156,6 +114,7 @@ export default function App() { // }, // [mapView, trayState], // ); + const [isAuthenticated, setIsAuthenticated] = useState(false); return ( <> @@ -168,96 +127,53 @@ export default function App() { -
- -
-

Map filters

-
-
-

Purpose

- - {purpose.map((p) => ( -
- - -
- ))} -
+ {isAuthenticated ? ( +
+ +
+ +

Map controls

+
+ + +
-
- +
+ + +
-
-

Species and length

-
-
- species -
-
- min - max -
-
- -
-
-
-
-

Date range

-
-
- from - to -
-
- -
-
-
-
-

Water body

-
-
- name -
-
- -
-
-
-

Map controls

-
+ +
+
- - -
-
- - + + +
+

Selected records

+
+
- -
-
- - - - -
-

Selected records

-
-
+
+ ) : ( +
+
+

Please log in to use the application

+
-
-
+ + )}