question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Pay on Thursday 27th May] [IOU] Create Currency Modal, with geolocation and Location permissions

See original GitHub issue

If you haven’t already, check out our contributing guidelines for onboarding!


Context

This issue builds on top of the existing IOU Modal, which was implemented in this PR. The IOU Amount step page has already been created and is a controlled component (IOUModal manages its state). The amount step allows users to select the IOU request or bill split amount, depending on how they launched the Modal.

We now seek to extend functionality. We want to use a Geolocation library and an existing API to detect the users preferred currency, allowing them to change it manually, too. We also need to implement a permissions library to request location permission from the user if they decide to change their currency, as we will then seek to detect it automatically from then on.

To open the Modal, you can navigate to localhost:8080/iou/request AND localhost:8080/iou/split.

You can also launch the IOUModal by temporarily modifying the routes in CreateMenu. Launch the request money flow with Navigation.navigate(ROUTES.IOU_REQUEST) and the bill split flow with Navigation.navigate(ROUTES.IOU_BILL)

Mobile & mobile web Currency Selector - Mobile

Web & Desktop Currency Selector - Desktop (1)

Deliverables:

  1. Create a new API.js function for calling our GetPreferredCurrency API and another for calling GetCurrencyList. Details at the bottom of this post.
  2. Add the react-native-geolocation and react-native-permissions libraries to the project.
  3. We should create a new function within the PersonalDetails.js Action which calls the new GetPreferredCurrency API.js function
    1. If the location permission has already been granted, we will get lat and lon from getCurrentPosition and pass the params to GetPreferredCurrency, else we ignore those query params (as they are optional)
    2. We should then call GetCurrencyList matching the currency we received from the previous request to get the correct symbol for that currency. (the full currency list should also be persisted to Onyx via a new key: currencyList)
    3. We then persist both the preferredCurrencyCode AND preferredCurrencySymbol data in Onyx, similar to how we store the users timezone
  4. When the IOUModal is opened, we should subscribe to the MY_PERSONAL_DETAILS Onyx key:
    1. We take updated values of preferredCurrencySymbol and preferredCurrencyCode, setting IOUModal props for both of these (currencySelected prop should be deleted, selectedCurrency should be modified to be of type Object: selectedCurrency: { currencyCode: String, currencySymbol: String })
    2. The currency Text component should be updated with this.props.selectedCurrency.currencySymbol
  5. When the currency symbol is tapped, a CurrencyModal should be displayed. This is a new Modal which needs the following functionality:
    1. The Modal should follow the structure of our existing Modals
    2. Retrieve all currencies from GetCurrencyList via another new Action function and again persisting this data to Onyx under the currencyList key.
    3. using the above data, we should display all currencies to the user in a FlatList, using a new OptionsListUtils variant
    4. If the user makes a currency selection then we should pass this value back to the IOUModal via a callback and update the preferredCurrencyCode AND preferredCurrencySymbol Onyx data
    5. The modal should then close, returning the user to the IOUAmount step, with the updated currency symbol

GetPreferredCurrency API Example of the API which is used to retrieve the users preferred currency

https://www.expensify.com/api?command=GetPreferredCurrency&latitude=0.01&longitude=-1.44
latitude - optional param
longitude - optional param

// Response
{
  "currency": "GBP",
  "jsonCode": 200,
  "requestID": "0uBdrX"
}

GetCurrencyList API Example of the API which returns all supported currency and symbol parings

https://www.expensify.com/api?command=Mobile_GetConstants&data=[%22currencyList%22]

// Response
{
  "currencyList": "{"AED":{"symbol":"Dhs","name":"UAE Dirham","ISO4217":"784"},"AFN":{"symbol":"Af","name":"Afghan Afghani","ISO4217":"971"},"ALL":{"symbol":"ALL","name":"Albanian
	...
  }}",
  "jsonCode": 200,
  "requestID": "wjy42x"
}

Original issue: https://github.com/Expensify/Expensify/issues/157871#event-4483831003

Upwork Issue: https://www.upwork.com/ab/applicants/1373765458169090048/job-details

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
rameshhpathakcommented, Mar 22, 2021

Got it. Thanks. Also, have submitted the proposal on job posting under the name Ramesh Pathak.

1reaction
rameshhpathakcommented, Apr 14, 2021

@kadiealexander Hi, sorry! I am resolving the outstanding issues within next half an hour!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Turn Location Services and GPS on or off on your iPhone ...
How to give apps permission to use your location · Tap Allow to let the app use Location Services information as needed. ·...
Read more >
Online Terms and Conditions - Grinnell State Bank
Please review our terms and conditions for using our online banking and wealth management services.
Read more >
2015 -2016 CATALOG - Ringling College of Art and Design
May 27. Deadline for students to submit work to instructors for ... making interest-only payments while in school or deferring all payments ......
Read more >
American
the prior permission in writing of Oxford University Press, ... recognizing places and numbers ... may have problems with Tuesday /ˈtuzdeɪ/, Wednesday.
Read more >
Untitled
B. Permission to advertise a Request for Proposals for Disaster Debris ... but the Department may make any payments or parts of payments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found