TheDevPath / Navi

Open Source Project for Grow with Google Udacity Scholarship Challenge - Navigation app using offline first strategy and google maps api - To get started please refer to the README.md - CONTRIBUTING.md and the project Wiki
https://navi-rocks.herokuapp.com/
MIT License
53 stars 63 forks source link

Display place details #182

Open jkwening opened 6 years ago

jkwening commented 6 years ago

Create a component for displaying details about a place.

It should have two view modes:

turisap commented 6 years ago

Hi, @jkwening, I'd like to try to implement this, can I work on it?

jkwening commented 6 years ago

@turisap certainly, go for it. It's assigned to you. Thanks.

turisap commented 6 years ago

@jkwening, I'm experiencing problems with the application, could you please help me out?

As I new to this project, I set up everything in accordance with instructions and then run npm run dev in the root directory and got the application running in my browser at localhost:8080. It reloads each time I made changes in the code, but it did not reflected it in the running application. Even if I did something which should affect the app significantly or crash it like commenting out render() or router it still worked as before without any changes or errors in the browser's console. Why it can be so and how can I fix this?

jkwening commented 6 years ago

@turisap we have a service worker implemented, so its probably caching the main bundle.js module where the primary code logic is embedded. You probably just need to set the service worker tool to "update on reload" to allow it to automatically sync new changes via dev tools. Else, have your tried clearing out all site data via "Application" and then "Clear Storarge" in dev tools?

turisap commented 6 years ago

@jkwening, your advice did help! So it's working now. Thank you)

I've got a couple of questions regarding how to make this component, can you answer them?

I guess it would not work if I store file in component's state. Probably I don't need to do that and image will be obtained through back-end somehow and I don't need to do everything I've done?

jkwening commented 6 years ago

@turisap sorry for just getting back to you - completely missed this in my inbox. Here's my response in order of your questions:

Additional notes:

@motosharpley I see a branch called "gmap-places" - I assume we want to use that for this feature or is that for something else? I can make a new branch if that is the case.

motosharpley commented 6 years ago

@jkwening we should make a new branch I just created that gmap-places branch to preserve the code from the google implementation before refactoring it out for leaflet in case someone wanted it

jkwening commented 6 years ago

@turisap I've create a feature branch called "place-details" that we will use for this issue until its complete and ready to be merged into "development" branch. Did my response answer your questions?

turisap commented 6 years ago

@jkwening, yes, thank you for the exhaustive answer, it is much clearer now. I'll proceed then with full-screen mode component in my PR soon.

turisap commented 6 years ago

@jkwening, sorry, it looks like I need to ask a couple of more questions..

I followed your advice and went to ~/controllers/google-api-controller.js and did find there both placeDetails() and directions() which I guess I need to use for this component. However, it is not clear how to make a request to those endpoints. Simple import of those actions does not work and crashes application with an error process in not defined. As I saw in other components, there is clint/src/js/server-request-utilities.js which has makeRequest() function. I suppose my requests should be somehow done via this utility, but a simple request like makeRequest('GET', 'placeDetails') returns a Promise with Error: Request failed with status code 404 at createError. Are there any docs on how to make a request?

The second question is that for obtaining place info from back-end I need a place_id, how am I suppose to have one in my component?

jkwening commented 6 years ago

@turisap regarding requests to the backend server, you're heading in the right direction; please utilize makeRequest() function along with BASE_ENDPOINTS object in server-request-utilities.js (see PR #264 OnLocationFound() and saveSaveMarkerToDB() functions in client/src/components/LeafletOsmMap/index.js as use case examples).

The example you provided is slightly off, the controllers/google-api-controller.js docstring for getting places details specifies the request needs to be of the form "{GET} /search/places/:id". The makeRequest() function takes arguments of the form: (method='GET', baseEndPoint, endPointAddon='', bodyData={}, params={}, headers={}). The "method" and "baseEndPoint" arguments are required, method defaults to "GET" request if not provided. The BASE_ENDPOINT object encapsulates most if not all of the currently available base endpoints for the backend server. The remaining arguments allow for the following flexibility via a single function call:

You got the method correct but are passing incorrect "baseEndPoint" arguments. For getting place details, the base endpoint is "/search/places" or you could use BASE_ENDPOINTS.places object constant. As mentioned you will need to pass the place id id in the params argument. The remaining args can be left blank since they're not needed.

For getting google specific place_id string, you've hit on an upcoming issue we need to resolve. For locations identified via search, the place_id value is returned as part of the result and is stored as part of the search result prediction list (see declared state values in constructor of: client/src/components/Search/index.js). On selection of a value, we should pass/store that information accordingly. That should now be partially implemented in PR #264 but needs to be enhanced. For user dropped pins, we will probably need to add another backend server endpoint for getting it from google if possible.

turisap commented 6 years ago

@jkwening, thank you for the explicit answer, it helped me a lot :-)