diff --git a/src/api/treeTrackerApi.js b/src/api/treeTrackerApi.js index 6734df65..a2e2f068 100644 --- a/src/api/treeTrackerApi.js +++ b/src/api/treeTrackerApi.js @@ -526,18 +526,6 @@ export default { getSessions() { try { const query = `${FIELD_DATA_API}/session`; - // Will want to limit results to the orgs/user's sessions only... - // Which is best field to query by? - // orgList &&... - // device_configuration_id - // originating_wallet_registration_id - // target_wallet - // organization - // organization_id - // device_identifier - // grower_account_id - - log.debug('GET SESSIONS -----', query); return fetch(query, { method: 'GET', diff --git a/src/components/CaptureFilter.js b/src/components/CaptureFilter.js index c00a88b4..75dc801c 100644 --- a/src/components/CaptureFilter.js +++ b/src/components/CaptureFilter.js @@ -6,8 +6,10 @@ import TextField from '@material-ui/core/TextField'; import MenuItem from '@material-ui/core/MenuItem'; import Autocomplete from '@material-ui/lab/Autocomplete'; import SelectOrg from './common/SelectOrg'; +import SelectSession from './common/SelectSession'; import FilterModel, { ALL_SPECIES, + ALL_SESSIONS, SPECIES_ANY_SET, SPECIES_NOT_SET, ALL_ORGANIZATIONS, @@ -94,6 +96,9 @@ function Filter(props) { const [tag, setTag] = useState(null); const [tagSearchString, setTagSearchString] = useState(''); const [organizationId, setOrganizationId] = useState(ALL_ORGANIZATIONS); + const [sessionId, setSessionId] = useState( + filter?.session_id || ALL_SESSIONS + ); const [tokenId, setTokenId] = useState(filter?.tokenId || filterOptionAll); const handleStartDateChange = (date) => { @@ -123,6 +128,7 @@ function Filter(props) { species_id: speciesId, tag_id: tag ? tag.id : undefined, organization_id: organizationId, + session_id: sessionId, tokenId: tokenId.trim(), }; const filter = new FilterModel(test); @@ -144,6 +150,7 @@ function Filter(props) { setTag(null); setTagSearchString(''); setOrganizationId(ALL_ORGANIZATIONS); + setSessionId(ALL_SESSIONS); setTokenId(filterOptionAll); const filter = new FilterModel(); props.onSubmit && props.onSubmit(filter); @@ -338,6 +345,12 @@ function Filter(props) { setOrganizationId(org.stakeholder_uuid); }} /> + { + setSessionId(session.id); + }} + />