diff --git a/package-lock.json b/package-lock.json index 301328c..3088758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "firebase": "^11.0.1", "immer": "^10.1.1", "ky": "^1.7.2", + "lodash.debounce": "^4.0.8", "react": "^18.3.1", "react-aria": "^3.35.1", "react-aria-components": "^1.4.1", @@ -9297,6 +9298,12 @@ "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", "license": "MIT" }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", diff --git a/package.json b/package.json index 45fdc35..3d853e0 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "firebase": "^11.0.1", "immer": "^10.1.1", "ky": "^1.7.2", + "lodash.debounce": "^4.0.8", "react": "^18.3.1", "react-aria": "^3.35.1", "react-aria-components": "^1.4.1", diff --git a/src/components/Filter.tsx b/src/components/Filter.tsx index f5c8c91..00e1a46 100644 --- a/src/components/Filter.tsx +++ b/src/components/Filter.tsx @@ -10,6 +10,7 @@ import DateRange from './filters/DateRange'; import Domain from './filters/Domain'; import Location from './filters/Location'; import SpeciesLength from './filters/SpeciesLength'; +import Submitter from './filters/Submitter'; import { useMap } from './hooks'; import { getStationQuery } from './queryHelpers'; @@ -165,6 +166,9 @@ export default function Filter(): JSX.Element {
+
+ +
); } diff --git a/src/components/ResultsGrid.tsx b/src/components/ResultsGrid.tsx index 7ec4d7c..eab1f30 100644 --- a/src/components/ResultsGrid.tsx +++ b/src/components/ResultsGrid.tsx @@ -40,7 +40,8 @@ async function getData(where: string, currentUser: User): Promise { FROM ${config.databaseSecrets.databaseName}.${config.databaseSecrets.user}.${config.tableNames.equipment} as eq WHERE se.${config.fieldNames.EVENT_ID} = eq.${config.fieldNames.EVENT_ID} FOR XML PATH ('')), - 1, 1, '') + 1, 1, ''), + se.${config.fieldNames.SUBMITTER} FROM ${config.databaseSecrets.databaseName}.${config.databaseSecrets.user}.${config.tableNames.events} as se LEFT OUTER JOIN ${config.databaseSecrets.databaseName}.${config.databaseSecrets.user}.${config.tableNames.fish} as f @@ -216,6 +217,9 @@ export default function ResultsGrid() { Equipment + + Submitter + Event ID @@ -234,6 +238,7 @@ export default function ResultsGrid() { {row[config.fieldNames.STATION_NAME]} {row[config.fieldNames.SPECIES]} {row[config.fieldNames.TYPES]} + {row[config.fieldNames.SUBMITTER]} {row[config.fieldNames.EVENT_ID]} )} diff --git a/src/components/contexts/FilterProvider.tsx b/src/components/contexts/FilterProvider.tsx index 656805f..bd7ca6d 100644 --- a/src/components/contexts/FilterProvider.tsx +++ b/src/components/contexts/FilterProvider.tsx @@ -6,7 +6,7 @@ export type QueryInfo = { table: string; }; export type FilterState = Partial>; -export type FilterKeys = 'purpose' | 'date' | 'speciesLength' | 'location' | 'equipmentType'; +export type FilterKeys = 'purpose' | 'date' | 'speciesLength' | 'location' | 'equipmentType' | 'submitter'; type Action = | { type: 'UPDATE_TABLE'; diff --git a/src/components/filters/Submitter.tsx b/src/components/filters/Submitter.tsx new file mode 100644 index 0000000..050b9ce --- /dev/null +++ b/src/components/filters/Submitter.tsx @@ -0,0 +1,26 @@ +import { TextField } from '@ugrc/utah-design-system'; +import debounce from 'lodash.debounce'; +import config from '../../config'; +import { useFilter } from '../contexts/FilterProvider'; + +export default function Submitter(): JSX.Element { + const { filterDispatch } = useFilter(); + + const onChange = debounce((value) => { + filterDispatch({ + type: 'UPDATE_TABLE', + filterKey: 'submitter', + value: { + table: config.tableNames.events, + where: `${config.fieldNames.SUBMITTER} = '${value}'`, + }, + }); + }, 1250); + + return ( + <> +

Submitter

+ + + ); +} diff --git a/src/config.ts b/src/config.ts index 8c8e00c..cc9ed38 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,6 +33,7 @@ const config = { SURVEY_PURPOSE: 'SURVEY_PURPOSE', EVENT_DATE: 'EVENT_DATE', OBSERVERS: 'OBSERVERS', + SUBMITTER: 'SUBMITTER', // Fish SPECIES: 'SPECIES', // dynamic field created via SQL query