-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simplified MyObservations for logged out users with at leas…
…t 1 obs (#2599) Simplified version of MyObs for signed out users with more than 1 obs. Currently only in debug mode. Also: * refactor: extract TaxonGridItem into a reusable component * chore: TypeScript cleanup Closes MOB-317
- Loading branch information
Showing
23 changed files
with
502 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { INatIcon } from "components/SharedComponents"; | ||
import type { Props as TaxonGridItemProps } from "components/SharedComponents/TaxonGridItem"; | ||
import TaxonGridItem from "components/SharedComponents/TaxonGridItem.tsx"; | ||
import { Pressable } from "components/styledComponents"; | ||
import { | ||
EXPLORE_ACTION, | ||
useExplore | ||
} from "providers/ExploreContext.tsx"; | ||
import React from "react"; | ||
import { useTranslation } from "sharedHooks"; | ||
import colors from "styles/tailwindColors"; | ||
|
||
interface Props extends TaxonGridItemProps { | ||
count?: number; | ||
setCurrentExploreView: ( exploreView: "observations" ) => void | ||
} | ||
|
||
const ExploreTaxonGridItem = ( { | ||
count, | ||
showSpeciesSeenCheckmark = false, | ||
style, | ||
taxon, | ||
setCurrentExploreView | ||
}: Props ) => { | ||
const { dispatch } = useExplore( ); | ||
const { t } = useTranslation( ); | ||
return ( | ||
<TaxonGridItem | ||
headerText={ | ||
typeof ( count ) === "number" | ||
? t( "X-Observations", { count } ) | ||
: undefined | ||
} | ||
showSpeciesSeenCheckmark={showSpeciesSeenCheckmark} | ||
style={style} | ||
taxon={taxon} | ||
upperRight={count && ( | ||
<Pressable | ||
accessibilityRole="button" | ||
onPress={( ) => { | ||
if ( !( taxon?.id && taxon?.name ) ) return; | ||
dispatch( { | ||
type: EXPLORE_ACTION.CHANGE_TAXON, | ||
taxon: { id: taxon.id }, | ||
taxonId: taxon?.id, | ||
taxonName: taxon?.preferred_common_name || taxon?.name | ||
} ); | ||
setCurrentExploreView( "observations" ); | ||
}} | ||
> | ||
<INatIcon name="observations" size={15} color={String( colors?.white )} dropShadow /> | ||
</Pressable> | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ExploreTaxonGridItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.