Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚲 Bike station migration 🚲 : Moving to mobility API (v2) #470

Merged
merged 17 commits into from
Sep 22, 2021

Conversation

bendiksk
Copy link
Contributor

@bendiksk bendiksk commented Sep 20, 2021

🚲
This PR migrates the part of the app considering bike stations to utilize the mobility v2 API using the entur SDK.
The reason why many files are changed is primarily due to the different format of the returned data using the type Station. The primary changes are in the custom hook useBikeRentalStations(), the majority of other file changes are adaptations to the new data format.

The commit-log includes multiple Work-In-Progress commits (due to unknown migration scope) which may be squashed for prettier history. The drawback being a big bulk of changes with less traceability.

Changes:

  • Rewrite useBikeRentalStation() to use mobility v2

    • Using SDK-function getStations() to get nearby stations (within user selected radius)
    • ❗Updated entur/sdk package: Using New SDK-function getStationsById() to get user selected stations (from bike station searchfield)
  • As an effect we move from using BikeRentalStation type to Station type (return type of relevant mobility v2 functions)

  • Rewrite EditTab to use mobility v2 where needed

  • Different naming system (getTranslation() utility function added)

    • Adapting to: station.namestation.name.translation[0].value
    • created util function getTranslation() which which defaults to returning Norwegian translation with 'nb' language ID (norsk bokmål)

Other:

  • General refactoring (irrelevant to bike stations): Matched filename with exported component in StopPlaceSearch
  • Known issues: React warning inherent to Dropdown component
  • Discovered "bug" (fix incoming): User selected stations (newStations in settings) stores duplicates if same stations is searched and selected more than once. Fixed in additional commit

* Part of the migration to use mobility v2 api to fetch bike rental stations
* The new API returns data of the type Station, with different properties
* .. to be used with objects of the TranslatedString type from entur/sdk
* enables easier language-change if future translations are added to the API
Fixed render loop in useEffect
* Fixed missing bike-tile
* Refactored useEffect into smaller responsibilities
Changed implementation to use custom useBikeRentalStations hook in EditTab
* Migrating to fetch from mobility API v2 in BikeSearch
* Type migration BikeRentalStation -> Station
* added argument removeHiddenStations which may be set to false to enable usability for EditTab where hidden stations is needed in toggle-list
* fixed filtering logic in hook (removed adding of duplicate stations)
@bendiksk bendiksk requested a review from a team September 20, 2021 13:46
* Fixed conditionless adding of bike rental station added through search field. Now checks if ID is already stored in settings.newStations
Copy link
Contributor

@draperunner draperunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bra jobba!

Eg tenker squashing er greit, for WIP-commits har ofte ikkje så mykje verdi med mindre dei kan stå for seg sjølv.

src/logic/useBikeRentalStations.ts Show resolved Hide resolved
src/utils.tsx Outdated Show resolved Hide resolved
* Removed includesStation() from utils.tsx, implemented logic directly in useBikeRentalStation
* Changed cleanups in useEffects (in EditTab/*) to use AbortController instead of primitive boolean variable
@mjansrud
Copy link
Contributor

Credz for fin PR-beskrivelse 🙌

* Default to empty string '' instead of station.id
* Sorting station names defaults to putting stations with missing name last
@bendiksk bendiksk merged commit 566b89a into master Sep 22, 2021
@bendiksk bendiksk deleted the mobility-v2-stations branch September 22, 2021 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants