overleaf/services/web/frontend/js/features
Antoine Clausse b2ef7a935f [web] Use localized number formatting for currencies (#17622)
* Add a unit test on `SubscriptionFormatters.formatPrice`

* Add JSDoc to `formatPrice`

Also: Name the functions before exporting:
This fixes my IDE (WebStorm) navigation

* Make `'USD'` the default param instead of reassigning

* Create `formatCurrency` function

* Use `formatCurrency` in SubscriptionFormatters

* Use an `isNoCentsCurrency` logic for `CLP` `JPY` `KRW` `VND`

And remove custom `CLP` logic and locale

* Add `locale` param to `formatPrice`

* Generate `groups.json` and `localizedPlanPricing.json`

```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```

* Update scripts/plan-prices/plans.js to generate numbers instead of localized amounts

* Generate `groups.json` and `localizedPlanPricing.json`

```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```

* Remove generation of `plans.json`

As /services/web/frontend/js/main/plans.js was removed in https://github.com/overleaf/internal/pull/12593

* Sort currencies in alphabetical order in scripts/plan-prices/plans.js

* Generate `groups.json` and `localizedPlanPricing.json`

```
bin/exec web node ./scripts/recurly/recurly_prices.js --download -o prices.json
bin/exec web node ./scripts/plan-prices/plans.js -f ../../prices.json -o dir
```

* Use `formatCurrency` in price-summary.tsx

* Use `formatCurrency` in Subscription Pug files

* Fix unit tests SubscriptionHelperTests.js

* Remove unused `currencySymbol`

* Change to `formatCurrency` in other React components

* Add `CurrencyCode` JSDoc types

* Duplicate `formatCurrency` into services/web/app/src/util

* Wrap tests in a top-level describe block

* Use `narrowSymbol`

* Fix tests with `narrowSymbol` expects

* Revert deletion of old `formatPrice` in SubscriptionFormatters.js

* Rename `formatCurrency` -> `formatCurrencyLocalized`

* Revert deletion of `CurrencySymbol`

* Add split-test in SubscriptionController.js

* Add split-test in SubscriptionViewModelBuilder.js

* Add split-test in plans

* Add split-test in subscription-dashboard-context.tsx

* Add split-test in 4 more components

* Update tests

* Show currency and payment methods in interstitial page

* Fix `–` being printed. Use `–` instead

* Fix test with NOK

* Storybook: Fix missing `SplitTestProvider`

* Storybook: Revert "Remove unused `currencySymbol`"

This reverts commit e55387d4753f97bbf8e39e0fdc3ad17312122aaa.

* Replace `getSplitTestVariant` by `useSplitTestContext`

* Use parameterize currencyFormat in `generateInitialLocalizedGroupPrice`

* Fixup import paths of `formatCurrencyLocalized`

* Replace `% 1 === 0` by `Number.isInteger`

* Add comment explaining that any combinations of languages/currencies could happen

* Fixup after rebase: import `useSplitTestContext`

* Revert "Remove SplitTestProvider from subscription root"

This reverts commit be9f378fda715b86589ab0759737581c72321d87.

* Revert "Remove split test provider from some tests"

This reverts commit 985522932b550cfd38fa6a4f4c3d2ebaee6ff7df.

GitOrigin-RevId: 59a83cbbe0f7cc7e45f189c654e23fcf9bfa37af
2024-04-19 08:03:54 +00:00
..
algolia-search
autoplay-video Merge pull request #16805 from overleaf/tm-website-redesign-ios-video-tweaks 2024-01-30 16:49:37 +00:00
bookmarkable-tab
chat Merge pull request #16815 from overleaf/td-uuid-frontend-upgrade 2024-02-13 09:03:45 +00:00
clone-project-modal/components Merge pull request #15016 from overleaf/mf-remove-editor-left-menu-angular 2023-10-05 08:05:00 +00:00
contact-form
cookie-banner Add path attribute to cookie banner cookie attributes (#16783) 2024-02-02 09:03:43 +00:00
dictionary Merge pull request #17707 from overleaf/AR-modal-close-consistency-fixes 2024-04-05 08:04:13 +00:00
editor-left-menu Merge pull request #14709 from overleaf/ae-context-typescript 2024-01-29 09:03:04 +00:00
editor-navigation-toolbar Merge pull request #14709 from overleaf/ae-context-typescript 2024-01-29 09:03:04 +00:00
event-tracking Merge pull request #16608 from overleaf/jpa-writefull-double-loaded 2024-01-24 09:03:47 +00:00
fallback-image
faq-search Merge pull request #10675 from overleaf/mj-wiki-search-submit 2022-12-12 09:03:38 +00:00
file-tree Allow individual docs to be downloaded from the file tree (#17137) 2024-02-22 09:04:48 +00:00
file-view Merge pull request #14709 from overleaf/ae-context-typescript 2024-01-29 09:03:04 +00:00
form-helpers Merge pull request #17845 from overleaf/mf-add-icon-error-login-home 2024-04-12 08:05:52 +00:00
group-management Merge pull request #17728 from overleaf/jel-fix-member-view-update 2024-04-05 08:04:00 +00:00
history Merge pull request #17815 from overleaf/ar-allow-labels-to-be-added-in-label-list 2024-04-11 08:03:43 +00:00
hotkeys-modal/components Merge pull request #17707 from overleaf/AR-modal-close-consistency-fixes 2024-04-05 08:04:13 +00:00
ide-react Merge pull request #17879 from overleaf/rh-refresh-collab 2024-04-17 08:05:18 +00:00
link-helpers
mathjax Remove MathJax v2 (#16961) 2024-02-09 09:06:42 +00:00
multi-submit
outline Memoize FileTree and outline toggle button components (#16776) 2024-02-02 09:03:08 +00:00
pdf-preview Merge pull request #17422 from overleaf/jpa-avoid-resize-observer-loop 2024-04-17 08:03:59 +00:00
plans [web] Use localized number formatting for currencies (#17622) 2024-04-19 08:03:54 +00:00
preview Merge pull request #15040 from overleaf/jpa-js-to-jsx 2023-09-29 08:04:29 +00:00
project-list Merge pull request #17559 from overleaf/ds-latam-v2 2024-04-09 08:04:06 +00:00
settings Merge pull request #17898 from overleaf/tm-remove-twitter-login 2024-04-18 08:04:16 +00:00
share-project-modal [web] Paywall CTA split-test (#17555) 2024-04-03 08:04:16 +00:00
source-editor Merge pull request #17878 from overleaf/mj-keyboard-navigation-firefox-115 2024-04-12 08:06:27 +00:00
subscription [web] Use localized number formatting for currencies (#17622) 2024-04-19 08:03:54 +00:00
ui/components Merge pull request #17806 from overleaf/rd-bootstrap-button2 2024-04-17 08:05:10 +00:00
utils Merge pull request #17806 from overleaf/rd-bootstrap-button2 2024-04-17 08:05:10 +00:00
word-count-modal Merge pull request #17707 from overleaf/AR-modal-close-consistency-fixes 2024-04-05 08:04:13 +00:00