overleaf/services/web/scripts
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
..
analytics
delete-duplicate-splittest-versions
delete-orphaned-docs
example
helpers
history
learn/checkSanitize
lezer-latex
oauth
plan-prices [web] Use localized number formatting for currencies (#17622) 2024-04-19 08:03:54 +00:00
recurly
sync-user-entitlements
translations
ukamf
add_feature_override.js
add_notification_ieee_collabratec_users.js
add_user_count_to_csv.js
back_fill_deleted_files.js
back_fill_doc_name_for_deleted_docs.js
back_fill_doc_rev.js
back_fill_dummy_doc_meta.js
back_fill_staff_access.js
back_fill_warning_user_personal_and_group_subscription.js
backfill_mixpanel_user_properties.js
backfill_project_image_name.js
backfill_user_properties.js
backfill_users_sso_attribute.js
bench_bcrypt.js
check_institution_users.js
check_saml_emails.js
clear_feedback_collection.js
clear_institution_notifications.js
clear_project_tokens.js
clear_sessions_2fa.js
clear_sessions_set_must_reconfirm.js
confirmed_at_to_dates.js
convert_archived_state.js
convert_doc_to_file.js
count_encrypted_access_tokens.js
count_files_in_projects.js
count_image_files.js
count_project_size.js
create_oauth_personal_access_token.js
create_project.js
delete_dangling_file_refs.js
delete_orphaned_chat_threads.js
delete_orphaned_data_helper.js
delete_orphaned_doc_comment_ranges.js
delete_orphaned_docs_online_check.js
delete_subscriptions.js
disconnect_all_users.js
ensure_affiliations.js
extract_onboardingdatacollection_csv.js
find_malformed_filetrees.js
fix_group_invite_emails_to_lowercase.js
fix_malformed_filetree.js
fix_oversized_docs.js
force_doc_flush.js
inst_table.js
invalidate_tokens.js
mark_migration.js
merge_group_subscription_members.js
migrate_audit_logs.js
migration_compile_timeout_60s_to_20s.js
process_lapsed_reconfirmations.js
purge_non_logged_in_sessions.js
recover_docs_from_redis.js
refresh_features.js
refresh_institution_users.js
regenerate_duplicate_referral_ids.js
remove_deleted_users_from_token_access_refs.js
remove_email.js
remove_oauth_application.js
remove_unwanted_ieee_collabratec_users.js
restore_orphaned_docs.js
restore_soft_deleted_docs.js
set_tex_live_image.js
soft_delete_project.js
split_tests_assigned_at_to_dates.js
sso_id_migration_check.js
sso_id_remove_not_migrated.js
stress_test.js
tsconfig.json
undelete_project_to_user.js
unlink_third_party_id.js
validate-data-of-model.js