Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6f9f935
Validation, weather, weather week on frontend and backend done
Hailemelekotmelakie Mar 30, 2023
e4b3f12
quick fix on env example
andrew-bierman Mar 30, 2023
37c73a8
Google sign up and sign in added done
Hailemelekotmelakie Mar 31, 2023
d76c7a7
SignIn and signUp by Google or by manual done
Hailemelekotmelakie Mar 31, 2023
c955248
Update RegisterScreen.js
Hailemelekotmelakie Mar 31, 2023
771a86e
All external api calls from frontend are moved to backend and Express…
Hailemelekotmelakie Mar 31, 2023
1b061b5
Merge branch 'bra' of https://github.com/andrew-bierman/PackRat into bra
Hailemelekotmelakie Mar 31, 2023
2f148d2
Verify login password and signIn signUp changed to firebase
Hailemelekotmelakie Apr 1, 2023
41c1c0c
Update firebase.js
Hailemelekotmelakie Apr 1, 2023
f04629a
Forgot password added
Hailemelekotmelakie Apr 2, 2023
0285275
Update google-services.json
Hailemelekotmelakie Apr 2, 2023
112e98f
Case sensetivenes fixed
Hailemelekotmelakie Apr 2, 2023
f9fc439
Merge branch 'bra' of https://github.com/andrew-bierman/PackRat into bra
Hailemelekotmelakie Apr 2, 2023
6945af6
MapContainer Rollback
Hailemelekotmelakie Apr 3, 2023
2a9559e
Pack validation fixed
Hailemelekotmelakie Apr 3, 2023
4b4a521
OSM Endpoint added
Hailemelekotmelakie Apr 4, 2023
4d7fe75
changing route to node fetch and adding some helper functions for que…
andrew-bierman Apr 5, 2023
d64cef6
Merge branch 'andrew_testing' into andrew_osm_route
andrew-bierman Apr 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ web_modules/
.env
.env.test

.expo/
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
Expand Down
2 changes: 1 addition & 1 deletion client/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For users to edit
app.json

.env

.expo/
dist/
Expand Down
5 changes: 4 additions & 1 deletion client/_layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { QueryClientProvider } from "@tanstack/react-query";
import { queryClient } from "../constants/queryClient";
import { NativeBaseProvider } from "native-base";
import store from "../store/store";
import NavigationMobile from "../screens/NavigationMobile";
import NavigationMobile from "./screens/NavigationMobile";
import 'mapbox-gl/dist/mapbox-gl.css';
import 'mapbox://mapbox.mapbox-streets-v7'


import { ProviderAuth } from "../auth/provider";

Expand Down
26 changes: 4 additions & 22 deletions client/api/getGeoCode.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
// import { Geoapify_Key } from "../constants/api";
import { GEOAPIFY_KEY } from "@env";
import { api } from "../constants/api";

export const getGeoCode = async (addressArray = "Virginia") => {
const transform = addressArray.split(", ").join("%20").split(" ").join("%20");

const root = "https://api.geoapify.com/v1/geocode/search";

let params = `?`;

// let addressParams = addressArray.join("%20").replace(/\s/g, "%20");

if (addressArray) params += `text=${transform}`;

const api_key = `&apiKey=${GEOAPIFY_KEY}`;

params += api_key;

const url = root + params;

let resultReturn;

await fetch(url)
export const getGeoCode = async (addressArray) => {
let resultReturn
await fetch(`${api}/geocode?addressArray=${addressArray}`)
.then((response) => response.json())
.then((result) => {
resultReturn = result;
Expand Down
38 changes: 11 additions & 27 deletions client/api/getParks.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,18 @@
// import { NPS_API } from "../constants/api";
import { NPS_API, X_RAPIDAPI_KEY } from "@env";
import { api } from "../constants/api";
import abbrRegion from "../constants/convertStateToAbbr";

export const getParksRapid = async (state) => {
let parksArray = [];

const host = `https://jonahtaylor-national-park-service-v1.p.rapidapi.com/parks?stateCode=${
abbrRegion(state, "abbr") ?? ""
}`;

const options = {
method: "GET",
headers: {
"X-Api-Key": `${NPS_API}`,
"X-RapidAPI-Key": `${X_RAPIDAPI_KEY}`,
"X-RapidAPI-Host": "jonahtaylor-national-park-service-v1.p.rapidapi.com",
"User-Agent": "PackRat",
},
};

await fetch(host, options)
.then((res) => res.json())
.then((json) => {
// console.log("json.data:", json.data);
json.data.forEach((item) => {
parksArray.push(item);
});
})
.catch((err) => console.error("error:" + err));

const abbrState = abbrRegion(state, "abbr") ?? "";
if (abbrState) {
await fetch(`${api}/getparks?abbrState=${abbrState}`)
.then((res) => res.json())
.then((json) => {
json.data.forEach((item) => {
parksArray.push(item);
});
}).catch((err) => console.error("error:" + err));
}
if (parksArray.length > 0) {
parksArray = parksArray.map((park) => park.name);
} else {
Expand Down
63 changes: 7 additions & 56 deletions client/api/getTrails.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,16 @@
import { X_RAPIDAPI_KEY } from "@env";
import { api } from "../constants/api";

export const getTrailsRapid = async (locationObject, latParams, lonParams) => {
let trailsArray = [];

let radiusParams = 25;
let activityParams = true;

const {
administrative_area_level_1: state,
country,
locality: city,
} = locationObject;

let paramsConditional = "";

const root = "https://trailapi-trailapi.p.rapidapi.com/trails/explore/?";

if (latParams) paramsConditional += `lat=${latParams}`;
if (lonParams) paramsConditional += `&lon=${lonParams}`;

if (city) paramsConditional += `&q-city_cont=${city.replace(/\s/g, "")}`;

if (radiusParams) paramsConditional += `&radius=${radiusParams}`;
if (activityParams)
paramsConditional += `&q-activities_activity_type_name_eq=hiking`;

// const limitParams = `limit=${limit}`

// const latParams = `lat=34.1`

// const lonParams = `lon=-105.2`

// const cityParams = `q-city_cont=${city}`

// const radiusParams = `radius=50`

// const activityParams = 'q-activities_activity_type_name_eq=hiking'

// const params = `?${limitParams}&${latParams}&${lonParams}&${city ? cityParams : ''}&${radiusParams}&${activityParams}`

// const params = `?${limitParams}&${latParams}&${lonParams}&${cityParams}&${radiusParams}&${activityParams}`

const url1 = root + paramsConditional;

// https://trailapi-trailapi.p.rapidapi.com/activity/?&lat=34.1&lon=-105.2&q-city_cont=Charlottesville&radius=50&q-activities_activity_type_name_eq=hiking
const url =
"https://trailapi-trailapi.p.rapidapi.com/activity/?lat=34.1&lon=-105.2&q-city_cont=Denver&radius=25&q-activities_activity_type_name_eq=hiking";
// const url = 'https://trailapi-trailapi.p.rapidapi.com/activity?lat=34.1&limit=25&lon=-105.2&q-city_cont=Denver&q-country_cont=Australia&q-state_cont=California&radius=25&q-activities_activity_type_name_eq=hiking'
// const url = root + `${cityParams}&${activityParams}`
// const url = root + `?${activityParams}&${limitParams}`

const options = {
method: "GET",
await fetch(api + "/gettrails", {
method: 'POST',
headers: {
"X-RapidAPI-Key": `${X_RAPIDAPI_KEY}`,
"X-RapidAPI-Host": "trailapi-trailapi.p.rapidapi.com",
'Accept': 'application/json',
'Content-Type': 'application/json'
},
};

await fetch(url1, options)
.then((res) => res.json())
body: JSON.stringify({ ...locationObject, latitude: latParams, longitude: lonParams })
}).then((res) => res.json())
.then((json) => {
Object.values(json).forEach((item) => {
trailsArray.push(item);
Expand Down
25 changes: 4 additions & 21 deletions client/api/getWeather.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,19 @@
// import { OpenWeather_Key } from "../constants/api";
import { OPENWEATHER_KEY } from "@env";
import { api } from "../constants/api";

export const getWeather = async (lat, lon, state) => {
let weatherObject = {};

const root = "https://api.openweathermap.org/data/2.5/weather";

let params = `?`;

const latParams = lat;
const lonParams = lon;
const unitParams = "imperial";
const apiParams = true;

if (latParams) params += `lat=${latParams}`;
if (lonParams) params += `&lon=${lonParams}`;
if (unitParams) params += `&units=${unitParams}`;
if (apiParams) params += `&appid=${OPENWEATHER_KEY}`;
if (lat) params += `lat=${lat}`;
if (lon) params += `&lon=${lon}`;

const url = root + params;
const url = api + "/weather" + params;

await fetch(url)
.then((res) => res.json())
.then((json) => {
weatherObject = json;
// for (const key of Object.keys(json)) {
// const {weatherObject[key]} = json[key]
// }

// Object.values(json).forEach(item => {
// weatherArray.push(item)
// })
})
.catch((err) => {
console.error("error:" + err);
Expand Down
12 changes: 2 additions & 10 deletions client/api/getWeatherWeek.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
// import { OpenWeather_Key } from "../constants/api";
import { OPENWEATHER_KEY } from "@env";
import { api } from "../constants/api";

export const getWeatherWeek = async (lat, lon) => {
let weatherObject = {};

const root = "https://api.openweathermap.org/data/2.5/forecast";

let params = `?`;

const latParams = lat;
const lonParams = lon;
const unitParams = "imperial";

const apiParams = true;

if (latParams) params += `lat=${latParams}`;
if (lonParams) params += `&lon=${lonParams}`;
if (unitParams) params += `&units=${unitParams}`;
if (apiParams) params += `&appid=${OPENWEATHER_KEY}`;

const url = root + params;
const url = api + "/weather/week" + params;

await fetch(url)
.then((res) => res.json())
Expand Down
44 changes: 44 additions & 0 deletions client/app.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"expo": {
"name": "packrat-front",
"slug": "packrat-front",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"scheme": "./app/index.js",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff",
"scheme": "myapp"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.andrewbierman.packratfront"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
},
"package": "com.andrewbierman.packratfront"
},
"web": {
"favicon": "./assets/favicon.png",
"bundler": "metro"
},
"plugins": [
[
"@rnmapbox/maps",
{
"RNMapboxMapsImpl": "mapbox",
"RNMapboxMapsDownloadToken": "sk..."
}
]
]
}
}
2 changes: 1 addition & 1 deletion client/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function Index() {
/>
</Stack>

<MapContainer />
<MapContainer style="height: 100%" />

</Box>

Expand Down
2 changes: 1 addition & 1 deletion client/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ module.exports = function (api) {
safe: false,
allowUndefined: true,
}]
],
]
};
};
9 changes: 5 additions & 4 deletions client/components/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function Card({ title, Icon, isMap, data, isSearch, isTrail }) {
isSearch
? styles.searchContainer
: isMap
? styles.mapCard
: styles.containerMobile
? styles.containerMobile
: styles.mutualStyles
? styles.mapCard
: styles.containerMobile
? styles.containerMobile
: styles.mutualStyles
}
>
<Box
Expand All @@ -49,6 +49,7 @@ export default function Card({ title, Icon, isMap, data, isSearch, isTrail }) {
</Box>
{isMap ? null : isSearch ? (
<SearchInput />
// <Text>Search</Text>
) : (
<DropdownComponent
{...{
Expand Down
5 changes: 2 additions & 3 deletions client/components/SearchInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { SafeAreaView } from "react-native";
import { Platform } from "react-native";

import { GooglePlacesAutocomplete } from "react-native-google-places-autocomplete";
import { GOOGLE_API_KEY } from "@env";
import { GOOGLE_PLACES_API_KEY } from "@env";

// redux
import { useDispatch } from "react-redux";
Expand All @@ -38,7 +38,6 @@ export const SearchInput = () => {
const [isLoadingMobile, setIsLoadingMobile] = useState(false);

const dispatch = useDispatch();

const lat = geoCode?.features[0]?.geometry?.coordinates[1];
const lon = geoCode?.features[0]?.geometry?.coordinates[0];
const state = geoCode?.features[0]?.properties.state;
Expand Down Expand Up @@ -79,7 +78,7 @@ export const SearchInput = () => {
<GooglePlacesAutocomplete
placeholder="Search"
query={{
key: GOOGLE_API_KEY,
key: GOOGLE_PLACES_API_KEY,
language: "en", // language of the results
}}
minLength={2}
Expand Down
6 changes: 4 additions & 2 deletions client/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ ENVIRONMENT='development'
API_URL='your api url'
NPS_API = "your api key"
GEOAPIFY_KEY = "your api key"
OPENWEATHER_KEY = "your api key"
GOOGLE_PLACES_API_KEY = 'your api key'
MAPBOX_API_KEY = "your api key, starts with pk..."

X_RAPIDAPI_KEY = "your api key"
MAPBOX_ACCESS_TOKEN = "your api key, starts with pk..."
MAPBOX_DOWNLOADS_TOKEN="your api key, starts with sk..."
MAPBOX_DOWNLOADS_TOKEN="your api key, starts with sk..."

WEB_CLIENT_ID="962352557394-..................apps.googleusercontent.com"
ANDROID_CLIENT_ID="962352557394-........................apps.googleusercontent.com"
Loading