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

chore(application-system): Translate country list in phone prefix dropdown #16708

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

norda-gunni
Copy link
Member

@norda-gunni norda-gunni commented Nov 4, 2024

...

Attach a link to issue if relevant

What

Specify what you're trying to achieve

Why

Specify why you need to achieve this

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced phone input functionality to support multiple languages for country codes, improving localization.
    • Added support for Icelandic country codes alongside English.
    • Introduced a locale prop in the PhoneInputController to facilitate localization.
  • Bug Fixes

    • Updated flag representation for the Netherlands Antilles in country codes.
  • Documentation

    • Improved clarity on the handling of localization in phone input components.

Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

The changes in this pull request introduce localization support for phone input components. The PhoneFormField now passes a locale prop to the PhoneInputController, which in turn passes it to the PhoneInput. The PhoneInput has been updated to handle multiple country code lists based on the locale, with distinct lists for English and Icelandic. Additionally, the countryCodes constant has been split into countryCodesEN and countryCodesIS. Overall, these modifications enhance the flexibility of the phone input components to accommodate different languages.

Changes

File Change Summary
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx Added import for Locale and updated useLocale hook to include lang as locale. Passed locale to PhoneInputController.
libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx Updated imports for country codes to countryCodesIS and countryCodesEN. Modified getCountryCodes and getDefaultCountryCode to accept lang parameter. Added optional locale property to PhoneInputProps. Utilized locale in handleInputChange.
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts Renamed countryCodes to countryCodesEN and added countryCodesIS. Updated structure to include Icelandic country codes and added new entry for "North-Macedonia".
libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx Added optional locale property to Props interface and passed it to PhoneInput. Added import for Locale.

Possibly related PRs

Suggested reviewers

  • albinagu
  • Toti91
  • HjorturJ

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e805bcc and 9c4f648.

📒 Files selected for processing (1)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@norda-gunni norda-gunni changed the title chore(application-system): Translate country list in phone prefix dro… chore(application-system): Translate country list in phone prefix dropdown Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.

Project coverage is 36.51%. Comparing base (89b4cf4) to head (9c4f648).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...s/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx 83.33% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16708      +/-   ##
==========================================
- Coverage   36.53%   36.51%   -0.02%     
==========================================
  Files        6888     6890       +2     
  Lines      143659   143717      +58     
  Branches    40931    41029      +98     
==========================================
- Hits        52490    52484       -6     
- Misses      91169    91233      +64     
Flag Coverage Δ
air-discount-scheme-web 0.00% <ø> (ø)
api 3.35% <ø> (ø)
application-api-files 56.54% <ø> (ø)
application-core 71.06% <ø> (ø)
application-system-api 41.11% <ø> (ø)
application-template-api-modules 27.68% <ø> (+<0.01%) ⬆️
application-templates-accident-notification 28.98% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 25.87% <ø> (ø)
application-templates-driving-license 18.26% <ø> (ø)
application-templates-estate 12.17% <28.57%> (+<0.01%) ⬆️
application-templates-example-payment 24.80% <ø> (ø)
application-templates-financial-aid 15.48% <ø> (ø)
application-templates-general-petition 23.07% <ø> (ø)
application-templates-inheritance-report 6.52% <ø> (ø)
application-templates-marriage-conditions 15.04% <ø> (ø)
application-templates-mortgage-certificate 43.22% <ø> (ø)
application-templates-parental-leave 29.84% <ø> (ø)
application-types 6.60% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 20.82% <28.57%> (-0.01%) ⬇️
auth-react 21.92% <28.57%> (-0.02%) ⬇️
clients-charge-fjs-v2 24.11% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
financial-aid-backend 51.25% <ø> (ø)
financial-aid-shared 17.81% <ø> (ø)
island-ui-core 28.94% <78.57%> (+0.08%) ⬆️
judicial-system-web 27.58% <28.57%> (-0.01%) ⬇️
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 15.95% <28.57%> (-0.01%) ⬇️
services-auth-personal-representative 45.59% <ø> (+0.02%) ⬆️
shared-components 26.95% <28.57%> (-0.03%) ⬇️
shared-form-fields 31.35% <85.71%> (+0.13%) ⬆️
web 1.80% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...i-fields/src/lib/PhoneFormField/PhoneFormField.tsx 5.88% <ø> (ø)
.../island-ui/core/src/lib/PhoneInput/countryCodes.ts 100.00% <100.00%> (ø)
.../lib/PhoneInputController/PhoneInputController.tsx 100.00% <ø> (ø)
...s/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx 51.00% <83.33%> (+1.71%) ⬆️

... and 24 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 89b4cf4...9c4f648. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 4, 2024

Datadog Report

All test runs 1044f6b 🔗

34 Total Test Services: 0 Failed, 32 Passed
⬆️ Test Sessions change in coverage: 2 increased, 148 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-web 0 0 0 2 0 7.02s 1 no change Link
api 0 0 0 4 0 2.38s 1 no change Link
application-api-files 0 0 0 12 0 5.58s 1 no change Link
application-core 0 0 0 97 0 15.01s 1 no change Link
application-system-api 0 0 0 120 2 3m 29.95s 1 no change Link
application-template-api-modules 0 0 0 123 0 2m 4.26s 1 no change Link
application-templates-accident-notification 0 0 0 148 0 15.75s 1 no change Link
application-templates-criminal-record 0 0 0 2 0 10.11s 1 no change Link
application-templates-driving-license 0 0 0 13 0 13.4s 1 no change Link
application-templates-example-payment 0 0 0 2 0 10.39s 1 no change Link

@norda-gunni norda-gunni force-pushed the as-translate-countries branch from 35afcfa to 3125225 Compare November 4, 2024 14:53
Copy link
Member

@jonnigs jonnigs left a comment

Choose a reason for hiding this comment

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

LGTM

@norda-gunni norda-gunni force-pushed the as-translate-countries branch from 3125225 to 4621033 Compare November 4, 2024 15:04
@norda-gunni norda-gunni marked this pull request as ready for review November 4, 2024 15:05
@norda-gunni norda-gunni requested review from a team as code owners November 4, 2024 15:05
@norda-gunni norda-gunni requested review from RunarVestmann and jonnigs and removed request for RunarVestmann November 4, 2024 15:05
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx (1)

16-16: Add JSDoc documentation for the locale prop

For better maintainability and to help library consumers, consider adding JSDoc documentation explaining the purpose and expected values of the locale prop.

+  /** The locale used for phone input localization (e.g., 'is' or 'en') */
   locale?: Locale
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

Data inconsistencies found between English and Icelandic country code arrays

The verification revealed several inconsistencies:

  1. Country codes are not consistently matched between arrays:

    • Some codes appear only once instead of twice (e.g., AG, AN, AS, AX)
    • This indicates missing translations or mismatched country codes
  2. Dial codes show inconsistent counts:

    • Multiple entries for some dial codes (+1, +500, +672)
    • This suggests potential duplicate or mismatched entries
  3. Format properties are preserved correctly between translations for:

    • Canada: (###) ###-####
    • Denmark: ## ## ## ##
    • Iceland: ###-####
    • Poland: ## ### ## ##
    • Ukraine: ## ###-##-##
    • United Kingdom: #### ######
    • United States: (###) ###-####

Please review and align the country codes and dial codes between the English and Icelandic arrays to ensure one-to-one mapping.

🔗 Analysis chain

Line range hint 1-941: Verify data consistency between English and Icelandic arrays.

Let's ensure both arrays maintain consistent data across translations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that both arrays have matching entries for codes and dial codes

# Extract and compare the number of entries
echo "Comparing array lengths..."
EN_COUNT=$(grep -c "dial_code:" libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts)
IS_COUNT=$(grep -c "dial_code:" libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts)
if [ "$EN_COUNT" -ne "$IS_COUNT" ]; then
  echo "Error: Arrays have different lengths"
  exit 1
fi

# Compare country codes
echo "Checking country codes consistency..."
grep -A 1 "code:" libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts | grep "code:" | sort | uniq -c | grep -v "      2" && echo "Error: Inconsistent country codes found"

# Compare dial codes
echo "Checking dial codes consistency..."
grep -A 1 "dial_code:" libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts | grep "dial_code:" | sort | uniq -c | grep -v "      2" && echo "Error: Inconsistent dial codes found"

# Check format properties
echo "Checking format properties consistency..."
grep -A 3 "format:" libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts

Length of output: 63768

libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (4)

26-30: Consider defaulting the lang parameter in getCountryCodes to simplify function calls

Currently, getCountryCodes requires a lang parameter, and you're defaulting to 'is' at each call site using locale || 'is'. By setting a default value for lang in the function signature, you can reduce code redundancy and prevent potential errors.

Apply this diff to set a default value for lang:

 const getCountryCodes = (
-  lang: Locale,
+  lang: Locale = 'is',
   allowedCountryCodes?: string[],
 ): StringOption[] => {

68-71: Set a default value for lang in getDefaultCountryCode to prevent repeated defaulting

Similarly to getCountryCodes, setting a default value for lang in getDefaultCountryCode can simplify calls and eliminate the need to default locale at each invocation.

Apply this diff:

 const getDefaultCountryCode = (
-  lang: Locale,
+  lang: Locale = 'is',
   phoneNumber?: string,
 ) => {

149-153: Simplify function calls by removing redundant default locale logic

With default values set for lang in both getDefaultCountryCode and getCountryCodes, you can remove the locale || 'is' logic from these function calls.

Apply these diffs:

 const defaultCountryCode = getDefaultCountryCode(
-  locale || 'is',
+  locale,
   value || defaultValue,
 )
 const countryCodes = getCountryCodes(
-  locale || 'is',
+  locale,
   allowedCountryCodes,
 )

186-189: Utilize default parameter for lang in handleInputChange

Since getDefaultCountryCode now defaults lang to 'is', you can simplify the function call by passing locale directly.

Apply this diff:

 const updatedCC = getDefaultCountryCode(
-  locale || 'is',
+  locale,
   e.currentTarget.value,
 )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66dd836 and 4621033.

📒 Files selected for processing (4)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (3 hunks)
  • libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (6 hunks)
  • libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (4 hunks)
  • libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx (2)

Pattern libs/shared/**/*: "Confirm that the code adheres to the following:

  • Cross-application utility functions, types, and constants.
  • TypeScript best practices to ensure type safety and reusability.
  • Documentation and examples for library consumers."

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (7)
libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (2)

12-12: LGTM! Clean TypeScript implementation.

The explicit import of Locale type and the destructuring of useLocale hook follow TypeScript best practices and maintain good tree-shaking capabilities.

Also applies to: 40-40


67-67: Consider avoiding type assertion for locale prop.

While the type assertion works, it would be better to ensure type safety at compile time. Consider defining the type for lang from useLocale directly or using type guards if necessary.

Let's verify the typing of useLocale:

libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx (3)

5-5: LGTM: Clean import of shared type

The import of Locale from shared types follows best practices for shared libraries.


52-52: LGTM: Clean prop destructuring

The locale prop is correctly destructured and maintains alphabetical ordering.


85-85: Verify PhoneInput component's locale prop implementation

The locale prop is correctly passed down to PhoneInput component.

Let's verify the PhoneInput component's implementation of the locale prop:

✅ Verification successful

PhoneInput component correctly implements the locale prop

The locale prop is properly implemented in the PhoneInput component:

  • It's defined in the PhoneInputProps type
  • It's used to determine the country codes list (via getCountryCodes function)
  • It affects the display of country names in the dropdown (switches between English and Icelandic)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PhoneInput component's locale prop implementation
# Expected: Find the locale prop definition in PhoneInput component

# Search for PhoneInput component's props interface
ast-grep --pattern 'interface $PROPS_NAME {
  $$$
  locale?: $TYPE
  $$$
}' 

# Search for locale usage in PhoneInput component
rg -A 5 'locale.*=.*props' libs/island-ui/core/src/lib/PhoneInput/

Length of output: 13095


Script:

#!/bin/bash
# Let's search for PhoneInput component's implementation and props
fd PhoneInput.tsx -x cat {}

# Also search for any PhoneInput interface or type definitions
ast-grep --pattern 'type PhoneInputProps = {
  $$$
}'

ast-grep --pattern 'interface PhoneInputProps {
  $$$
}'

Length of output: 14224

libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (2)

1-1: LGTM! Clean export structure.

The file properly exports the country code arrays following TypeScript conventions.

Also applies to: 638-639


639-941: LGTM! Well-structured Icelandic translations.

The Icelandic translations:

  • Maintain consistent data structure with the English version
  • Preserve special format properties for relevant countries
  • Include all countries from the English list

@norda-gunni norda-gunni force-pushed the as-translate-countries branch from 4621033 to 6cf3a36 Compare November 4, 2024 15:23
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (3)
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

638-940: Consider refactoring to reduce duplication

The EN and IS arrays share the same structure with only names being different. Consider using a base array with translations:

interface CountryCodeBase {
  flag: string;
  code: string;
  dial_code: string;
  format?: string;
}

interface CountryCodeTranslations {
  en: string;
  is: string;
}

const baseCountryCodes: (CountryCodeBase & { id: string })[] = [/*...*/]
const translations: Record<string, CountryCodeTranslations> = {/*...*/}

export const countryCodesEN = baseCountryCodes.map(country => ({
  ...country,
  name: translations[country.id].en
}))

export const countryCodesIS = baseCountryCodes.map(country => ({
  ...country,
  name: translations[country.id].is
}))
libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (2)

19-19: Optimize import of country code data to reduce bundle size

Importing both countryCodesIS and countryCodesEN may unnecessarily increase the bundle size since only one is needed at runtime based on the locale. Consider dynamically importing the country code data or restructuring it to leverage tree-shaking, thereby improving bundling efficiency.


113-113: Set a default value for locale to simplify code

By setting a default value for locale when destructuring props, you can avoid repeatedly using locale || 'is' throughout the component, enhancing code readability.

Apply this diff to set a default value:

     const {
       name,
       label,
-      locale,
+      locale = 'is',
       errorMessage = '',
       hasError = Boolean(errorMessage),
       // ...other props
     } = props

Then, you can simplify the following lines by removing the defaulting:

-    const defaultCountryCode = getDefaultCountryCode(
-      locale || 'is',
-      value || defaultValue,
-    )
+    const defaultCountryCode = getDefaultCountryCode(
+      locale,
+      value || defaultValue,
+    )
-    const countryCodes = getCountryCodes(locale || 'is', allowedCountryCodes)
+    const countryCodes = getCountryCodes(locale, allowedCountryCodes)
-    const countryCodeList = locale === 'is' ? countryCodesIS : countryCodesEN
+    const countryCodeList = locale === 'is' ? countryCodesIS : countryCodesEN
-    const updatedCC = getDefaultCountryCode(
-      locale || 'is',
-      e.currentTarget.value,
-    )
+    const updatedCC = getDefaultCountryCode(
+      locale,
+      e.currentTarget.value,
+    )
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4621033 and 6cf3a36.

📒 Files selected for processing (4)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx (3 hunks)
  • libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (6 hunks)
  • libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (4 hunks)
  • libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • libs/application/ui-fields/src/lib/PhoneFormField/PhoneFormField.tsx
  • libs/shared/form-fields/src/lib/PhoneInputController/PhoneInputController.tsx
🧰 Additional context used
📓 Path-based instructions (2)
libs/island-ui/core/src/lib/PhoneInput/PhoneInput.tsx (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (1)
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

1-1: ⚠️ Potential issue

Breaking change: Renamed export from countryCodes to countryCodesEN

This rename improves code clarity but requires updates in all importing files.

✅ Verification successful

No breaking changes detected - rename is safe

The search results show that the old countryCodes export was not directly imported anywhere in the codebase. The PhoneInput component already uses the new countryCodesEN and countryCodesIS imports internally, and other files only import the PhoneInput component itself. The only other usage of countryCodes is in countries.ts, but this is a different constant with a different type.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all files importing the old constant name
rg "import.*\{.*countryCodes.*\}.*from.*PhoneInput"

Length of output: 53


Script:

#!/bin/bash
# Try a broader search for any imports from PhoneInput
rg "from.*PhoneInput"

# Also search for direct usage of countryCodes
rg "countryCodes[^A-Za-z]"

# Search for any file that imports from the PhoneInput directory
rg "import.*from.*PhoneInput"

Length of output: 2356

libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

646-948: LGTM with suggestions for improvement.

The Icelandic translations are well-implemented and maintain consistency with the English version. Consider these improvements:

  1. Extract phone number formats into a separate constant to avoid duplication between language versions
  2. Consider sorting countries alphabetically within each language array for easier maintenance

Example of format extraction:

const PHONE_FORMATS = {
  CA: '(###) ###-####',
  DK: '## ## ## ##',
  GB: '#### ######',
  IS: '###-####',
  PL: '## ### ## ##',
  UA: '## ###-##-##',
  US: '(###) ###-####',
} as const;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6cf3a36 and e805bcc.

📒 Files selected for processing (1)
  • libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (2)
libs/island-ui/core/src/lib/PhoneInput/countryCodes.ts (2)

1-7: LGTM! Well-defined TypeScript interface.

The CountryCode interface properly defines all required fields with appropriate types.


365-365: LGTM! Country entries updated correctly.

The changes properly update the Netherlands Antilles flag and add the North Macedonia entry.

Also applies to: 386-386

@norda-gunni norda-gunni added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 7, 2024
@norda-gunni norda-gunni added deprecated:automerge (Disabled) Merge this PR as soon as all checks pass and removed deprecated:automerge (Disabled) Merge this PR as soon as all checks pass labels Nov 7, 2024
@kodiakhq kodiakhq bot merged commit b0a8c22 into main Nov 7, 2024
121 checks passed
@kodiakhq kodiakhq bot deleted the as-translate-countries branch November 7, 2024 13:02
robertaandersen pushed a commit that referenced this pull request Nov 11, 2024
…pdown (#16708)

* chore(application-system): Translate country list in phone prefix dropdown

* PR comments

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
jonnigs pushed a commit that referenced this pull request Nov 12, 2024
…pdown (#16708)

* chore(application-system): Translate country list in phone prefix dropdown

* PR comments

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants