diff --git a/components/Location.tsx b/components/Location.tsx index ad14bfa..a9222eb 100644 --- a/components/Location.tsx +++ b/components/Location.tsx @@ -36,7 +36,7 @@ const LocationScreen: React.FC = ({ visible, currentTheme, const [locLoading, setLocLoading] = useState(false); const [parks, setParks] = useState([]); const [hasSearched, setHasSearched] = useState(false); - const [selectedParkId, setSelectedParkId] = useState(null); + const [selectedPark, setSelectedPark] = useState(null); // Call the parks endpoint with coordinates const fetchNearbyParks = async (longitude: number, latitude: number) => { @@ -104,15 +104,14 @@ const LocationScreen: React.FC = ({ visible, currentTheme, }} titleStyle={{ fontWeight: "bold" }} descriptionNumberOfLines={2} - onPress={() => setSelectedParkId(item.Id)} + onPress={() => { + setSelectedPark(item); + setParks([]); + setHasSearched(false); + }} /> ); - // Find the selected park, if one is selected - const selectedPark = selectedParkId - ? parks.find(p => p.Id === selectedParkId) - : null; - return ( = ({ visible, currentTheme, />