App icon indicating copy to clipboard operation
App copied to clipboard

Add CurrencySelectionList component and use it in IOU and WS currency settings

Open tsa321 opened this issue 2 years ago • 30 comments

Details

Fixed Issues

$ https://github.com/Expensify/App/issues/29618 PROPOSAL: https://github.com/Expensify/App/issues/29618#issuecomment-1785638160

Tests

  1. Go to workspace settings and select default currency
  2. The currency selection list will appears and type "euro"
  3. The euro currency must be available in the list
  4. Select the euro currency, then notice the default currency is changed into euro
  5. Repeat step 2-4 for other search text like "rupee", "pound", "Australia" then notice the Indian rupee , England pounds, Australia dollar is available in the list for the respected search text
  6. Go to + fab button -> select money request -> go to manual tab -> click the currency
  7. Repeat the step 2-5
  8. Go to IOU request money address like: https://dev.new.expensify.com:8082/request/new/currency/?currency=HUF&backTo=%2Frequest%2Fnew%2Fmanual then notice the selected currency code is HUF
  9. Change the HUF text of the address into JPY and notice the selected currency in the list is JPY
  • [x] Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Go to workspace settings and select default currency
  2. The currency selection list will appears and type "euro"
  3. The euro currency must be available in the list
  4. Select the euro currency, then notice the default currency is changed into euro
  5. Repeat step 2-4 for other search text like "rupee", "pound", "Australia" then notice the Indian rupee , England pounds, Australia dollar is available in the list for the respected search text
  6. Go to + fab button -> select money request -> go to manual tab -> click the currency
  7. Repeat the step 2-5
  8. Go to IOU request money address like: https://dev.new.expensify.com:8082/request/new/currency/?currency=HUF&backTo=%2Frequest%2Fnew%2Fmanual then notice the selected currency code is HUF
  9. Change the HUF text of the address into JPY and notice the selected currency in the list is JPY
  • [x] Verify that no errors appear in the JS console

PR Author Checklist

  • [x] I linked the correct issue in the ### Fixed Issues section above
  • [x] I wrote clear testing steps that cover the changes made in this PR
    • [x] I added steps for local testing in the Tests section
    • [x] I added steps for the expected offline behavior in the Offline steps section
    • [x] I added steps for Staging and/or Production testing in the QA steps section
    • [x] I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • [x] I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • [x] I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • [x] I included screenshots or videos for tests on all platforms
  • [x] I ran the tests on all platforms & verified they passed on:
    • [x] Android: Native
    • [x] Android: mWeb Chrome
    • [x] iOS: Native
    • [x] iOS: mWeb Safari
    • [x] MacOS: Chrome / Safari
    • [x] MacOS: Desktop
  • [x] I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • [x] I followed proper code patterns (see Reviewing the code)
    • [x] I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • [x] I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • [x] I verified that comments were added to code that is not self explanatory
    • [x] I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • [x] I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • [x] If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • [x] I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • [x] I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • [x] I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • [x] I verified the JSDocs style guidelines (in STYLE.md) were followed
  • [x] If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • [x] I followed the guidelines as stated in the Review Guidelines
  • [x] I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • [x] I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • [x] I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • [x] I verified that if a function's arguments changed that all usages have also been updated correctly
  • [x] If a new component is created I verified that:
    • [x] A similar component doesn't exist in the codebase
    • [x] All props are defined accurately and each prop has a /** comment above it */
    • [x] The file is named correctly
    • [x] The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • [x] The only data being stored in the state is data necessary for rendering and nothing else
    • [x] If we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes
      • [x] Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • [x] All JSX used for rendering exists in the render method
    • [x] The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • [x] If any new file was added I verified that:
    • [x] The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • [x] If a new CSS style is added I verified that:
    • [x] A similar style doesn't already exist
    • [x] The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • [x] If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • [x] If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • [x] If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • [x] If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • [x] If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • [x] If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • [x] I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native

https://github.com/Expensify/App/assets/114975543/e6cd1499-e4c9-4d37-8967-2e426a22f3f0

Android: mWeb Chrome

https://github.com/Expensify/App/assets/114975543/0177cf20-ce12-4308-a8ac-3133da495bfd

iOS: Native

https://github.com/Expensify/App/assets/114975543/3db32afd-53b5-4dcc-b31a-70749a60372a

iOS: mWeb Safari

https://github.com/Expensify/App/assets/114975543/171000dd-0a27-4d3c-933b-969533aa6ac0

MacOS: Chrome / Safari

https://github.com/Expensify/App/assets/114975543/d91c143a-c7fe-4016-948b-4ee6c4d73a04

MacOS: Desktop

https://github.com/Expensify/App/assets/114975543/e5ddbf15-dc57-483f-a492-ffe7b279edb9

tsa321 avatar Nov 05 '23 04:11 tsa321

@parasharrajat Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

melvin-bot[bot] avatar Nov 05 '23 04:11 melvin-bot[bot]

@parasharrajat Currently the behavior of the workspace default currency setting is still the same. and I have some doubts before applying the url currency parameter for the workspace currency settings:

ss:

Screenshot 2023-11-04 at 19 50 58 copy

Screenshot 2023-11-04 at 19 33 27 copy

If the url parameter of currency is different than current policy currency stored in onyx, should we change the selected currency based on the url parameter?

tsa321 avatar Nov 05 '23 04:11 tsa321

If the url parameter of currency is different than current policy currency stored in onyx, should we change the selected currency based on the url parameter?

Only on Currency Selection page, the URL parameter will manage the selection. Then it should be removed when going back to workspace settings page.

parasharrajat avatar Nov 07 '23 16:11 parasharrajat

@parasharrajat I have add the URL parameter for workspace currency settings page and update the route accordingly. In my latest commit the focused currency is based on URL parameter and the selected currency is based on currency of the policy stored in onyx. The result is something like this:

Screenshot 2023-11-08 at 20 24 16 ed

If it is weird, I will revert back to make the focused and selected currency based on URL parameter.

tsa321 avatar Nov 08 '23 13:11 tsa321

Friendly bump @parasharrajat , Could you review my pr when you have a chance? thank you...

tsa321 avatar Nov 09 '23 16:11 tsa321

@parasharrajat are you ready to review this PR? I will merge main

tsa321 avatar Nov 21 '23 02:11 tsa321

Apologies for the delay here. I had build issues last week so couldn't focus on it. Unfortunately, I will be AFK till the weekend. But I am sure I can get this reviewed on Monday.

https://github.com/Expensify/App/pull/30889#issuecomment-1801896290

This is a weird situation. I currently don't have a direct answer here but I can dig into that. I would suggest that we follow similar patterns that are already being used in the App. May be try finding a similar page in the app and see what is done there.

parasharrajat avatar Nov 22 '23 18:11 parasharrajat

There is another variant of such a pattern in the APP used around CountrySelectionPage. Things to check would be comparing and seeing what is different between both. And can we stick to one?

parasharrajat avatar Nov 22 '23 18:11 parasharrajat

@parasharrajat done. The behavior will be like country selection page and will also fix https://github.com/Expensify/App/issues/31650

tsa321 avatar Nov 24 '23 03:11 tsa321

@tsa321 will it fix https://github.com/Expensify/App/issues/29822?

cead22 avatar Nov 27 '23 15:11 cead22

@cead22 yes, this will also fix that issue. I will follow the displayed text of the workspace currency setting, which is agreed in here.

tsa321 avatar Nov 27 '23 15:11 tsa321

Started review.

parasharrajat avatar Dec 03 '23 10:12 parasharrajat

I am currently OOO. I plan to continue this in 2 days. There are no urgent PRs/issues on my side so I would be able to fully focus here.

parasharrajat avatar Dec 19 '23 18:12 parasharrajat

@parasharrajat if there is navigation problem here, I suggest to solve the issue separately in here: https://github.com/Expensify/App/issues/31650 to get the best solution to fix the issue about Default Currency Updated Without Clicking "Save" Button.

tsa321 avatar Dec 30 '23 01:12 tsa321

Thanks for waiting here. It's been long but I was somewhat waiting on request flow migration done by Tgolen which would update IOUCurrencySelection. But it seems that we are completely removing that component https://github.com/Expensify/App/issues/34607.

More details https://github.com/Expensify/App/issues/29107.

This affects this PR as we are trying to update IOUCurrencySelection.

What should we do?

  1. Revert all the changes done on IOUCurrencySelection.
  2. If a better solution has been implemented in IOURequestStepCurrency, analyze this.
  3. Revisit the solution.

I will start analyzing the changes myself to speed up the process.

parasharrajat avatar Jan 25 '24 17:01 parasharrajat

We might want to hold on https://github.com/Expensify/App/issues/34607 as it could help us with the migration of this PR to the new component without conflicts.

parasharrajat avatar Jan 25 '24 17:01 parasharrajat

cc @tgolen ^

cead22 avatar Jan 25 '24 17:01 cead22

pinged Tim 1:1

miljakljajic avatar Jan 29 '24 13:01 miljakljajic

Yes, I agree that we should only move forward with IOURequestStepCurrency. I don't think it needs to be held on the old component being removed though.

tgolen avatar Jan 29 '24 15:01 tgolen

@parasharrajat Should we hold this PR for https://github.com/Expensify/App/issues/34607 to be merged? because IOUCurrencySelection will be removed by that PR, but if this PR is more important then should I continue with this PR and make change in IOUCurrencySelection or/and IOURequestStepCurrency? but it will disturb that PR. My PR won't change navigation logic of IOU, it will only adds a CurrencySelectionList component. Should we continue on this PR or Should we wait for https://github.com/Expensify/App/issues/34607 to be merged? Or Should I add CurrencySelectionList and use it in WorkspaceSettingsCurrency first and will add the component in IOU when https://github.com/Expensify/App/issues/34607 has been merged? Thank you...

tsa321 avatar Mar 09 '24 02:03 tsa321

I think it's fine. let's hold on https://github.com/Expensify/App/issues/34607.

parasharrajat avatar Mar 09 '24 16:03 parasharrajat

We should be good here @tsa321 to move ahead.

parasharrajat avatar Apr 11 '24 18:04 parasharrajat

@tsa321 Please ping me when this is ready for review.

parasharrajat avatar Apr 16 '24 12:04 parasharrajat

@parasharrajat for the task of creating CurrencySelectionList component and use it in IOU request and Workspace setting currency it is already done in my latest commit and ready for a review.

But for adding currency parameter in url for workspace setting by following the country selector page there are some problem... The navigation isn't working properly in country selector page. For example:

Navgiaton problem in country selector:

https://github.com/Expensify/App/assets/114975543/380f10fe-7bff-4497-a6b7-43b464c84107

So I am not sure if I must follow the country selector page. I have tried it before and there are some problems, like my previous comments...

tsa321 avatar Apr 16 '24 14:04 tsa321

@parasharrajat for now it is ready for review...

tsa321 avatar Apr 16 '24 23:04 tsa321

So the issue you mentioned is unrelated. @tsa321 Could you please merge main? Testing it now.

parasharrajat avatar Apr 23 '24 22:04 parasharrajat

We need to merge main to be able to test it properly. Please merge main when possible and I will finish my testing immediately before another conflict.

parasharrajat avatar Apr 23 '24 22:04 parasharrajat

@parasharrajat main merged

tsa321 avatar Apr 24 '24 01:04 tsa321

Screenshots

:black_square_button: iOS / native

https://github.com/Expensify/App/assets/24370807/43424cd5-d5c9-4c80-bca5-8c5cebbbbcaa

:black_square_button: iOS / Safari

https://github.com/Expensify/App/assets/24370807/7d7adcda-2071-4ec9-b922-71cbd3bbf286

:black_square_button: MacOS / Desktop

https://github.com/Expensify/App/assets/24370807/e0826974-4ae3-4fdb-96d3-c15e37c0cb54

:black_square_button: MacOS / Chrome

https://github.com/Expensify/App/assets/24370807/73259fd1-9f90-42f6-81ed-1c8dd758ee24

:black_square_button: Android / Chrome

https://github.com/Expensify/App/assets/24370807/eb0c6536-a6d9-4587-a410-a6c356528cf0

:black_square_button: Android / native

https://github.com/Expensify/App/assets/24370807/33dd5b90-5668-4dd8-a495-335cd35cf69b

parasharrajat avatar Apr 24 '24 06:04 parasharrajat

@cead22 Bump for review.

parasharrajat avatar Apr 28 '24 08:04 parasharrajat