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

feat: refactoring currency module to use central geo data [ATLAS-167] #119

Merged
merged 51 commits into from May 2, 2024

Conversation

RgnDunes
Copy link
Contributor

@RgnDunes RgnDunes commented Mar 30, 2024

Description

This PR updates currency module apis to now use central geo data (i18nify-data) rather that using modular static data.

Changes Made

List the main changes made in this pull request.

Title ---
JIRA link https://razorpay.atlassian.net/browse/ATLAS-167
Slack thread (if any) NA
Product spec NA
Tech spec/One-pager NA
Bundle Size Difference NA
Fixes Issue NA

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change is a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Is your change backward compatible ?
  • Tested on major browsers (Chrome, Firefox, Safari, IE) ?
  • Tested in a consumer application(s) ?

Additional Notes

Any additional information that would be helpful for the reviewer.

Checklist:

  • Add Jira ID(s) in PR title and in the description?
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My code is written in TypeScript and follows the coding standards of the project.
  • I have added relevant documentation and updated the README if necessary.
  • My commit messages are clear and follow the project's commit message conventions.
  • Is any external library added?
  • My changes do not introduce any new runtime errors or warnings.
  • All relevant unit tests have been added/updated in my PR for the change.
  • Any Screenshots (mobile & desktop) required for PR? If yes, have you added the respective screenshots ?
  • Any manual dev testing done by you on beta/func environment?
  • Reviewer added (SLA 2 days)

Reviewer Checklist

  • Sufficient QA/Dev-Testing is done with proof (test cases list)
  • Ensure that the change in bundle size falls within the acceptable range.

PR Title Format

Format: <type>: <subject>

Types can be as follows:

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Copy link

changeset-bot bot commented Mar 30, 2024

🦋 Changeset detected

Latest commit: 6f68562

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/i18nify-js Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This comment has been minimized.

@codecov-commenter
Copy link

codecov-commenter commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.57%. Comparing base (1047227) to head (155bcdb).
Report is 12 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #119       +/-   ##
===========================================
- Coverage   95.00%   84.57%   -10.44%     
===========================================
  Files          44       49        +5     
  Lines         501      590       +89     
  Branches      128      147       +19     
===========================================
+ Hits          476      499       +23     
- Misses         24       84       +60     
- Partials        1        7        +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RgnDunes RgnDunes marked this pull request as draft March 30, 2024 19:52

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@rzpcibot
Copy link
Contributor

rzpcibot commented Apr 2, 2024

Warnings
⚠️ Your PR has over 600 lines of code additions 😱 . Try to breakup into separate PRs 👍
⚠️ this currencyConfig.json has over 600 lines of code additions 😱 . Try to breakup into separate functions/components 👍

Bundle Size Report

Files

click to expand/collapse
🟢 No Change 🗑 File Deleted 🆕 New File 📈 Size Increased 👍 Size Reduced
Parsed (kb)
🚦 File Name Base PR Diff %
👍 cjs/index.js 143.6 138.9 $\textcolor{green}{-4.7}$ -3.27
👍 esm/index.min.js 53.71 51.45 $\textcolor{green}{-2.26}$ -4.21
👍 umd/index.js 163.03 158.85 $\textcolor{green}{-4.18}$ -2.56

Generated by 🚫 dangerJS against 6f68562

This comment has been minimized.

@RgnDunes RgnDunes marked this pull request as ready for review April 2, 2024 09:06

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@@ -21,7 +22,7 @@ describe('getIntlInstanceWithOptions', () => {
});

it('should handle currency options', () => {
const currency = 'EUR';
const currency = 'EUR' as CurrencyCodeType;
Copy link
Collaborator

Choose a reason for hiding this comment

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

redundant type cast.

export type CurrencyCodeType = keyof typeof CURRENCIES;
export type CurrencyCodeType = keyof typeof CURRENCY_INFO;

export interface CurrencySubsetData {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's not call this type CurrencySubsetData.
Just Currency should be fine IMO.

expect(sampleCurrency.symbol).toBe(CURRENCIES[sampleCurrencyCode].symbol);
expect(sampleCurrency.name).toBe(CURRENCIES[sampleCurrencyCode].name);
expect(sampleCurrency.symbol).toBe(
(CURRENCY_INFO as CurrencySubsetData)[sampleCurrencyCode].symbol,
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this typecast required here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

This comment has been minimized.

@@ -17,10 +19,12 @@ describe('getCurrencyList', () => {
it("check the values of 'symbol' and 'name' properties for a sample currency", () => {
const currencyList = getCurrencyList();
const sampleCurrencyCode = 'USD';
const sampleCurrency = currencyList[sampleCurrencyCode];
const sampleCurrency: Currency[string] = currencyList[sampleCurrencyCode];
Copy link
Collaborator

Choose a reason for hiding this comment

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

doesn't this translate to string ?
Also, is it needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's needed, since currency interface looks like below:

export interface Currency {
  [key: string]: {
    name: string;
    minor_unit: string;
    symbol: string;
  };
}

and sampleCurrency is supposed to store value like below:

{
    name: "Indian Rupee",
    minor_unit: "2",
    symbol: "₹"
  }


const minorUnitMultiplier = currencyInfo.minorUnitMultiplier || 100;
const majorUnitMultiplier =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Either name this minorUnitMultiplier or majorUnitDivider

Copy link
Contributor

github-actions bot commented May 2, 2024

Unit Test Results

0 files  0 suites   0s ⏱️
0 tests 0 ✔️ 0 💤 0 ❌

Results for commit 6f68562.

@tarun-khanna tarun-khanna merged commit 7321238 into master May 2, 2024
16 checks passed
@tarun-khanna tarun-khanna deleted the feat/currency-geo-data-migration branch May 2, 2024 10:23
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.

None yet

4 participants