Files
iNaturalistReactNative/src/components/Projects/ProjectObservations.js
Amanda Bullington e81894d406 Use authenticated queries for fetch/search requests (#195)
* Use authenticated query for search results
* Use search API for fetching places from Settings
* Use authenticated query for authorized applications
* Use authenticated query to fetch user.me
* Move fetch/search api calls into react query format, out of hooks
* Update with react query instead of hooks
* Fetch list of blocked and muted users with authenticated query
* Added Podfile postinstall block to get app running in a Simulator
* Use auth query in identify
* Upgrade Realm to 11.0.0-rc.0, most recent version that will work with RN 0.68.2
* Upgrade @realm/react library to 0.4.0; fixes initialization error on android due to importing realm
* Use authquery for explore provider
* ObsDetail wasn't showing the edit button for obs created while signed out
* simplified ObsEditHeader so it takes a full observation instead of relying
  on the ObsEditContext
* ObsEdit now accepts an obs UUID as a param and loads that if the context
  doesn't have a current obs
* null checks for API methods, mostly to prevent requests that won't work b/c
  of missing params

Co-authored-by: Ken-ichi Ueda <kenichi.ueda@gmail.com>
2022-10-19 13:01:04 -07:00

42 lines
1.1 KiB
JavaScript

// @flow
import { useNavigation } from "@react-navigation/native";
import { searchObservations } from "api/observations";
import GridItem from "components/SharedComponents/ObservationViews/GridItem";
import * as React from "react";
import { FlatList } from "react-native";
import useAuthenticatedQuery from "sharedHooks/useAuthenticatedQuery";
type Props = {
id: number
}
const ProjectObservations = ( { id }: Props ): React.Node => {
const {
data: observations
} = useAuthenticatedQuery(
["searchObservations", id],
optsWithAuth => searchObservations( { project_id: id }, optsWithAuth )
);
const navigation = useNavigation( );
const navToObsDetails = observation => {
navigation.navigate( "ObsDetails", { uuid: observation.uuid } );
};
const renderGridItem = ( { item } ) => (
<GridItem item={item} handlePress={navToObsDetails} uri="project" />
);
return (
<FlatList
data={observations}
key={1}
renderItem={renderGridItem}
numColumns={4}
testID="ProjectObservations.grid"
/>
);
};
export default ProjectObservations;