feat(muk): Migrate use micro region hook #19777
Open
+3,237
−2,360
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Overview
Refactored the
useTranslatedMicroRegions
hook to use centralized translations from@ovh-ux/manager-common-translations
instead of maintaining duplicate translation files locally. Improved code organization and added comprehensive Storybook documentation.🗑️ Cleanup - Translation Files Removed (8 files, -2,304 lines)
Removed duplicate translation files that are now provided by
@ovh-ux/manager-common-translations
:♻️ Refactored Code
useTranslatedMicroRegions.tsx
Before:
After:
Key Changes:
NAMESPACES.REGION
constanti18n.exists()
useTranslatedMicroRegions.utils.ts (NEW)
Extracted utility functions for better separation of concerns:
getMacroRegion(region: string)
- Parses region string to extract macro-region identifierisLocalZone(region: string)
- Detects if a region is a local zone (contains 'LZ' pattern)📚 Documentation Added
Storybook Stories (NEW)
useTranslatedMicroRegions.stories.tsx
with 5 interactive examples:GRA-1
(Gravelines)EU-WEST-LZ-MAD-A
(Madrid Local Zone)WES1
(West)US-EAST-VA-1
(Virginia)Comprehensive Documentation (NEW)
documentation.mdx
includes:🏗️ Code Organization
Test Files Reorganized
Export Structure
Updated
src/hooks/index.ts
:Created
src/hooks/region/index.ts
:📊 API
Hook Returns
translateMicroRegion
(region: string) => string
translateMacroRegion
(region: string) => string
translateContinentRegion
(region: string) => string
Utility Functions
getMacroRegion
(region: string) => string
isLocalZone
(region: string) => boolean
✅ Benefits
@ovh-ux/manager-common-translations
📊 Statistics
🔗 Reference
NAMESPACES.REGION
@ovh-ux/manager-common-translations