Skip to content

feat: making storeURL dynamic based on the current location - #3189

Merged
ommeirelles merged 7 commits into
feat/multilanguagefrom
feat/SFS-2968
Feb 4, 2026
Merged

ommeirelles merged 7 commits into
feat/multilanguagefrom
feat/SFS-2968

Conversation

@ommeirelles

@ommeirelles ommeirelles commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Addded two test case, one that simulates the running scenarioon on build time (node env) and other simulating browser with different locations to check wether the storeURL is returning the correct one.

image

Summary by CodeRabbit

  • New Features

    • Dynamic store URL resolution applied across the app for SEO, links, logout/redirects and cookie domain handling.
  • Refactor

    • Replaced static store URL usage with a runtime resolver to ensure consistent, localized URLs.
  • Tests

    • Added unit and browser tests for store URL resolution and updated test setup to support browser/jsdom scenarios.
  • Chores

    • Updated development/test tooling and added React test plugin.

@ommeirelles
ommeirelles requested a review from a team as a code owner January 28, 2026 15:33
@ommeirelles
ommeirelles requested review from lariciamota and lemagnetic and removed request for a team January 28, 2026 15:33
@codesandbox-ci

codesandbox-ci Bot commented Jan 28, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Replaces static store URL usages with a runtime-resolved getStoreURL() and expands localization exports (getStoreURL, withStoreURL), updating pages, components, SDKs, utils, tests, and Vitest config to use the dynamic store URL.

Changes

Cohort / File(s) Summary
Package & Test Config
packages/core/package.json, packages/core/vitest.config.ts
Added test/dev deps and integrated Vitest React plugin; split tests into browser (jsdom) and node projects.
Localization Core
packages/core/src/sdk/localization/useLocalizationConfig.tsx
Major rewrite: added storeURL to Settings, centralized settings derivation, session subscription, exported getStoreURL() and withStoreURL(), and adjusted default export shape.
Pages / SEO
packages/core/src/pages/index.tsx, packages/core/src/pages/s.tsx, packages/core/src/pages/[slug]/p.tsx
Replaced storeConfig.storeUrl with getStoreURL() for canonical/OpenGraph/SiteLinksSearchBoxJsonLd URLs and search action targets.
Components
packages/core/src/components/.../OrganizationDrawer/OrganizationDrawer.tsx, packages/core/src/components/templates/.../LandingPage.tsx, packages/core/src/components/templates/.../ProductListingPage.tsx
Switched logout redirect, canonical/OpenGraph, breadcrumb and related URL constructions to use getStoreURL().
SDK & Server
packages/core/src/sdk/account/refreshToken.ts, packages/core/src/sdk/analytics/platform/vtex/search.ts, packages/core/src/sdk/offer/fetcher.ts, packages/core/src/server/cms/index.ts
Replaced static store URL usage with runtime getStoreURL() for Host header, cookie domain, base URL resolution, and CMS client host derivation.
Utilities
packages/core/src/utils/getBaseDomain.ts
Switched hostname extraction to derive from getStoreURL() in unified-domain branch.
Tests
packages/core/test/sdk/localization/store-url.test.ts, packages/core/test/sdk/localization/store-url.browser.test.ts, packages/core/test/utils/match-url.test.ts
Added unit/browser tests for store URL resolution and enabled localization in an existing test mock.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #3182 — Modifies OrganizationDrawer logout flow and URL handling; overlaps with this PR's logout redirect changes.
  • #3165 — Alters the localization hook and runtime settings; touches the same localization logic and exports.
  • #3176 — Renames/imports localization artifacts and intersects with the new localization exports and paths.

Suggested labels

enhancement

Suggested reviewers

  • lariciamota
  • hellofanny
  • lemagnetic

Poem

🌍 Configs loosen, runtime wakes,
URLs follow locale's takes.
Pages, cookies, tests align in tune,
A small refactor — a brighter rune. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing dynamic storeURL resolution based on current location instead of static config values across multiple components and modules.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/SFS-2968

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • ✨ 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/sdk/analytics/platform/vtex/search.ts (1)

20-39: Consider lazy domain resolution for defensive SSR compatibility

createOrRefreshCookie evaluates getStoreURL() at module initialization (lines 23–28), which executes when search.ts is imported. Although getStoreURL() includes a server guard, deferring domain computation to the cookie write phase and wrapping in error handling would be more resilient.

Suggested improvement
 const createOrRefreshCookie = (key: string, expiresSecond: number) => {
-  const urlDomain =
-    process.env.NODE_ENV === 'development'
-      ? '.localhost'
-      : config.secureSubdomain
-        ? getBaseDomain([getStoreURL(), config.secureSubdomain])
-        : `.${new URL(getStoreURL()).hostname}`
-
   return () => {
+    const urlDomain = (() => {
+      if (process.env.NODE_ENV === 'development') return '.localhost'
+      try {
+        const storeURL = getStoreURL()
+        return config.secureSubdomain
+          ? getBaseDomain([storeURL, config.secureSubdomain])
+          : `.${new URL(storeURL).hostname}`
+      } catch {
+        return ''
+      }
+    })()
     let currentValue = getCookie(key)
     const isExpired = currentValue === undefined
     if (isExpired) {
       currentValue = randomUUID()
     }
-    document.cookie = `${key}=${currentValue}; max-age=${expiresSecond}; domain=${urlDomain}; path=/;`
+    const domainAttr = urlDomain ? `; domain=${urlDomain}` : ''
+    document.cookie = `${key}=${currentValue}; max-age=${expiresSecond}${domainAttr}; path=/;`
🤖 Fix all issues with AI agents
In
`@packages/core/src/components/account/MyAccountDrawer/OrganizationDrawer/OrganizationDrawer.tsx`:
- Around line 118-120: The logout URL uses getStoreURL() directly which can
produce malformed URLs when the store URL contains paths or query params; update
the call in the window.location.assign invocation that builds
`${storeConfig.secureSubdomain}/api/vtexid/pub/logout?scope=${storeConfig.api.storeId}&returnUrl=${getStoreURL()}`
to encode the returnUrl with encodeURIComponent(getStoreURL()) and provide a
safe fallback (e.g., encodeURIComponent('/') or encodeURIComponent(getStoreURL()
|| '/')) so the constructed logout URL is always valid; change the string
interpolation in the window.location.assign call in OrganizationDrawer.tsx
accordingly (references: window.location.assign, storeConfig, getStoreURL).

In `@packages/core/src/components/templates/LandingPage/LandingPage.tsx`:
- Around line 66-89: The storeURL returned by getStoreURL() can end with a
trailing slash which causes double slashes in Canonical and search target
strings; normalize storeURL inside the LandingPage component (e.g., in the
variable storeURL) by trimming any trailing slash before using it in
NextSeo.canonical and SiteLinksSearchBoxJsonLd.target so concatenations like
`${storeURL}/${slug}` and `${storeURL}/s/?q` never produce `//`; update
references to storeURL used in openGraph.url and SiteLinksSearchBoxJsonLd.url as
well to use the normalized value.

In
`@packages/core/src/components/templates/ProductListingPage/ProductListingPage.tsx`:
- Around line 105-116: The canonical and breadcrumb URL construction currently
concatenates getStoreURL() with pathnames (used when building canonical and in
the itemListElements map), which can duplicate locale segments; replace string
concatenation with URL joining via the URL constructor (e.g., construct new
URL(pathname, storeURL).href) when building canonical and when computing pageUrl
inside the itemListElements map to normalize and avoid duplicated locale/path
segments; update uses of canonical and pageUrl to use the URL-based result.

In `@packages/core/src/pages/s.tsx`:
- Around line 90-92: The canonical construction using searchTerm is unsafe (it
only replaces spaces); update the logic that builds canonical in pages/s.tsx to
use the URL and URLSearchParams APIs to properly encode the query: create a new
URL(getStoreURL()), call url.searchParams.set('q', searchTerm) when searchTerm
is present, and set canonical = url.toString(); keep canonical undefined when
searchTerm is falsy and ensure you reference the existing getStoreURL and
searchTerm symbols and the canonical variable.

In `@packages/core/src/sdk/account/refreshToken.ts`:
- Around line 31-35: REFRESH_TOKEN_URL and the Host header currently build from
getStoreURL() directly which can include path segments or trailing slashes;
parse getStoreURL() once with the URL constructor (e.g., const u = new
URL(getStoreURL())) and use u.origin to construct REFRESH_TOKEN_URL
(`${u.origin}/api/vtexid/refreshtoken/webstore`) and u.host (or u.hostname with
port if needed) for the Host header passed through sanitizeHost, replacing the
existing uses of getStoreURL() in the REFRESH_TOKEN_URL and headers (refer to
the REFRESH_TOKEN_URL constant, headers object, sanitizeHost and getStoreURL).

In `@packages/core/src/sdk/localization/useLocalizationConfig.tsx`:
- Around line 28-33: The render currently calls setSettings directly (comparing
settings and newSettings), which violates React rules; instead, compute
newSettings by calling getSettings(params) but perform the deepEqual check and
call setSettings(newSettings) inside a useEffect hook (e.g., in
useLocalizationConfig's body) with appropriate dependencies (params or the
specific values used to derive newSettings) so updates happen after render; keep
the initial useState<Settings>(getSettings(params)) initializer, remove the
direct setSettings from the render, and reference getSettings, settings,
newSettings, and deepEqual when moving the logic into the effect.

In `@packages/core/test/sdk/localization/store-url.browser.test.ts`:
- Around line 92-95: The test restores window.location in an afterAll hook which
causes cross-test pollution; change the hook to afterEach so window.location is
reset after each individual test. Locate the existing afterAll block that
assigns window.location = oldWindowLocation and replace it with afterEach to
ensure each test that mutates window.location is cleaned up; keep the
oldWindowLocation variable reference and restore it inside the afterEach
callback exactly as was done in the afterAll.
🧹 Nitpick comments (7)
packages/core/src/pages/[slug]/p.tsx (1)

114-121: Cache getStoreURL() before mapping breadcrumbs.
Line 114-121: getStoreURL() is called per item; compute once for clarity and minor perf.

Suggested fix
   const description =
     meta?.description ||
     pdpSeo.descriptionTemplate.replace(/%s/g, () => title) ||
     storeSeo.description
+
+  const storeURL = getStoreURL()
 
   let itemListElements = product.breadcrumbList.itemListElement ?? []
   if (itemListElements.length !== 0) {
     itemListElements = itemListElements.map(
       ({ item: pathname, name, position }) => {
-        const pageUrl = getStoreURL() + pathname
+        const pageUrl = storeURL + pathname
 
         return { name, position, item: pageUrl }
       }
     )
   }
packages/core/test/sdk/localization/store-url.test.ts (1)

90-95: Consider expanding test coverage for edge cases.

The test only verifies the default locale (pt-BR) returns its first binding. Consider adding tests for:

  • When localization is disabled
  • When binding lookup fails (fallback behavior)
  • Non-default locale resolution

This would complement the browser tests that cover window.location scenarios.

packages/core/src/sdk/offer/fetcher.ts (1)

7-14: Consider caching getStoreURL() result for performance.

getStoreURL() is called on every getUrl(skuId) invocation. Since getStoreURL() performs URL matching internally, repeated calls in hot paths (e.g., batch SKU lookups) could add overhead.

If getUrl is called frequently, consider caching the base URL:

♻️ Optional performance optimization
 const IS_PROD = process.env.NODE_ENV === 'production'
+let cachedBaseUrl: string | null = null
 
 export function getUrl(skuId: string) {
   const base = IS_PROD
-    ? getStoreURL()
+    ? (cachedBaseUrl ??= getStoreURL())
     : `https://${api.storeId}.${api.environment}.com.br`
   const url = new URL(`${base}/api/intelligent-search/product_search`)
packages/core/test/sdk/localization/store-url.browser.test.ts (2)

104-119: delete window.location may not work reliably in strict mode.

Using delete window.location can fail silently in strict mode or newer JSDOM versions. Consider using Object.defineProperty to override instead:

♻️ More robust location mocking
   it('should return the correct binding when window.location.href is defined', () => {
-    delete window.location
-    window.location = Object.defineProperties(
-      {},
+    Object.defineProperty(window, 'location', {
+      configurable: true,
+      writable: true,
+      value: Object.defineProperties({}, {
+        ...Object.getOwnPropertyDescriptors(oldWindowLocation),
+        href: {
+          configurable: true,
+          value: config.localization.locales['en-US'].bindings[0].url,
+        },
+      }),
+    })
-      {
-        ...Object.getOwnPropertyDescriptors(oldWindowLocation),
-        href: {
-          configurable: true,
-          value: config.localization.locales['en-US'].bindings[0].url,
-        },
-      }
-    )

4-86: Consider extracting shared mock configuration to reduce duplication.

The mock configuration is nearly identical to store-url.test.ts. Extract to a shared test fixture:

// test/fixtures/localization-mock.ts
export const mockLocalizationConfig = { enabled: true, defaultLocale: 'pt-BR', ... }
packages/core/src/sdk/localization/useLocalizationConfig.tsx (2)

128-138: Avoid as unknown as Props type assertion.

The double cast through unknown bypasses TypeScript's type checking. Consider a cleaner generic constraint:

♻️ Improved type safety
 export function withStoreURL<
   Props extends { storeURL: string },
-  PartialProps extends Omit<Props, 'storeURL'> & { storeURL?: string },
->(Component: React.ComponentType<Props>): React.ComponentType<PartialProps> {
-  return (props: PartialProps) => {
-    return React.createElement(Component, {
+>(Component: React.ComponentType<Props>): React.ComponentType<Omit<Props, 'storeURL'> & { storeURL?: string }> {
+  const WrappedComponent = (props: Omit<Props, 'storeURL'> & { storeURL?: string }) => {
+    const resolvedProps = {
       ...props,
       storeURL: props.storeURL ?? getStoreURL(),
-    } as unknown as Props)
+    } as Props
+    return React.createElement(Component, resolvedProps)
   }
+  WrappedComponent.displayName = `withStoreURL(${Component.displayName || Component.name || 'Component'})`
+  return WrappedComponent
 }

109-115: Redundant config check - localization was already accessed.

The check if (!config.localization) on line 109 occurs after config.localization.locales was already accessed on lines 84-86. If localization were missing, this would have already thrown.

♻️ Move check earlier or remove
 function getSettings(params?: { url?: string | URL }) {
   let url = params?.url ?? ''
+
+  if (!config.localization) {
+    throw new Error('Missing localization configuration in faststore config file.')
+  }
+
   const defaultConfig = config.localization.locales[
     config.localization.defaultLocale
   ] as ConfigType
   // ... rest of function
-
-  if (!config.localization) {
-    const Err = new Error(
-      'Missing localization configuration in faststore config file.'
-    )
-    console.error(Err)
-    throw Err
-  }

Comment thread packages/core/src/pages/s.tsx Resolved
Comment thread packages/core/src/sdk/offer/fetcher.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/package.json (1)

95-108: ⚠️ Potential issue | 🟡 Minor

Tighten Node engine constraint for jsdom compatibility.

jsdom 27.4.0 requires Node >=20.19.0, but the package.json engines field allows >=20, which includes Node 20.0–20.18. Update engines.node to >=20.19.0 to prevent install/runtime failures. @vitejs/plugin-react 5.1.2 (Vite 7 compatible) and @testing-library/react 14.3.1 (React 18 compatible) are aligned with the project's versions.

🧹 Nitpick comments (2)
packages/core/src/sdk/localization/useLocalizationConfig.tsx (2)

88-121: Move the localization guard before first access.

The guard currently runs after dereferencing config.localization, so missing config would throw earlier with a less actionable error.

♻️ Proposed adjustment
 function getSettings(params?: { url?: string | URL }) {
+  if (!config.localization) {
+    const Err = new Error(
+      'Missing localization configuration in faststore config file.'
+    )
+    console.error(Err)
+    throw Err
+  }
   let url = params?.url ?? ''
   const defaultConfig = config.localization.locales[
     config.localization.defaultLocale
   ] as ConfigType
@@
-  if (!config.localization) {
-    const Err = new Error(
-      'Missing localization configuration in faststore config file.'
-    )
-    console.error(Err)
-    throw Err
-  }

3-3: Expose optional URL parameter to getStoreURL for SSR/SEO correctness.

getSettings already supports a URL parameter to ensure correct locale binding in server contexts, but getStoreURL doesn't. Server-side callers will always resolve the default binding when window is unavailable, which can leak the wrong locale host into canonical/SEO links. Expose an optional URL param matching getSettings' signature and ensure SSR callers pass it to build region-correct canonical links.

🔧 Proposed signature update
-export const getStoreURL = () => getSettings().storeURL
+export const getStoreURL = (params?: { url?: string | URL }) =>
+  getSettings(params).storeURL

React namespace import on line 3 is justified by withStoreURL's createElement call.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/sdk/localization/useLocalizationConfig.tsx (1)

43-63: ⚠️ Potential issue | 🟡 Minor

Potential re-render loop: session in useEffect dependencies.

Including session as a dependency while calling sessionStore.set() (which updates session state) inside the same effect can trigger unnecessary re-renders. Consider using a ref to track the previous session or restructuring to avoid this.

🛡️ One possible approach using functional update pattern
   useEffect(() => {
     if (!settings) return
 
-    const channel = JSON.parse(session.channel ?? '{}') ?? {}
-    channel.salesChannel = settings.salesChannel
-
-    const newSession = {
-      ...session,
-      locale: settings.locale,
-      currency: settings.currency,
-      channel: JSON.stringify(channel),
-    }
-
-    if (
-      newSession.channel !== session.channel ||
-      newSession.locale !== session.locale ||
-      deepEqual(newSession.currency, session.currency) === false
-    ) {
-      sessionStore.set(newSession)
-    }
-  }, [settings, session])
+    const currentSession = sessionStore.read() ?? sessionStore.readInitial()
+    const channel = JSON.parse(currentSession.channel ?? '{}') ?? {}
+    channel.salesChannel = settings.salesChannel
+
+    const newSession = {
+      ...currentSession,
+      locale: settings.locale,
+      currency: settings.currency,
+      channel: JSON.stringify(channel),
+    }
+
+    if (
+      newSession.channel !== currentSession.channel ||
+      newSession.locale !== currentSession.locale ||
+      deepEqual(newSession.currency, currentSession.currency) === false
+    ) {
+      sessionStore.set(newSession)
+    }
+  }, [settings])
🧹 Nitpick comments (2)
packages/core/src/sdk/localization/useLocalizationConfig.tsx (2)

18-28: DRY violation: defaultConfig and defaultBinding duplicated.

This logic is repeated in both the hook body and in getSettings() (lines 90-101). Since getSettings already handles defaults, remove this duplication from the hook.

♻️ Proposed refactor
 export const useLocalizationConfig = (params?: { url?: string | URL }) => {
   const [session, setSession] = useState(
     sessionStore.read() ?? sessionStore.readInitial()
   )
-  const defaultConfig = config.localization.locales[
-    config.localization.defaultLocale
-  ] as ConfigType
-  const defaultBinding =
-    defaultConfig.bindings.find((el) => el.isDefault) ??
-    defaultConfig.bindings.at(0)
-
-  if (!defaultBinding)
-    throw new Error(
-      'Localization configuration invalid: not found default binding'
-    )
-
   const [settings, setSettings] = useState<Settings>(() => getSettings(params))

133-144: Add displayName to the HOC for better debugging.

Without a displayName, the wrapped component appears as "Anonymous" in React DevTools, making debugging harder.

♻️ Proposed improvement
 export function withStoreURL<
   Props extends { storeURL: string },
   PartialProps extends Omit<Props, 'storeURL'> & { storeURL?: string },
 >(Component: React.ComponentType<Props>): React.ComponentType<PartialProps> {
-  return (props: PartialProps) => {
+  const WrappedComponent = (props: PartialProps) => {
     return React.createElement(Component, {
       ...props,
       storeURL: props.storeURL ?? getStoreURL(),
     } as unknown as Props)
   }
+  WrappedComponent.displayName = `withStoreURL(${Component.displayName ?? Component.name ?? 'Component'})`
+  return WrappedComponent
 }

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/core/src/sdk/localization/useLocalizationConfig.tsx (1)

43-63: ⚠️ Potential issue | 🟡 Minor

Consider preventing unnecessary effect re-runs when sessionStore updates via subscription.

The effect depends on both settings and session but calls sessionStore.set, which may trigger the subscription callback (lines 37-41) that calls setSession. This causes the effect to run again when the subscription updates session state. While the deepEqual check in sessionStore.set prevents infinite loops, the effect body still executes unnecessarily. To optimize, track whether the session was just updated from the store callback or memoize the comparison logic to avoid the second execution.

🧹 Nitpick comments (3)
packages/core/src/sdk/localization/useLocalizationConfig.tsx (3)

18-28: Duplicated defaultConfig/defaultBinding logic.

Lines 18-28 duplicate the same logic found in getSettings() at lines 90-101. Extract this to a shared helper to reduce maintenance burden and ensure consistency.

♻️ Proposed refactor
+function getDefaultConfigAndBinding() {
+  const defaultConfig = config.localization.locales[
+    config.localization.defaultLocale
+  ] as ConfigType
+  const defaultBinding =
+    defaultConfig.bindings.find((el) => el.isDefault) ??
+    defaultConfig.bindings.at(0)
+
+  if (!defaultBinding) {
+    throw new Error(
+      'Localization configuration invalid: not found default binding'
+    )
+  }
+  return { defaultConfig, defaultBinding }
+}

Then use getDefaultConfigAndBinding() in both useLocalizationConfig and getSettings.


131-138: Confusing boolean expression.

!config.localization?.enabled === true is hard to parse due to operator precedence. Simplify for readability.

✨ Suggested improvement
 export const getStoreURL = () => {
   // If localization is not enabled, use storeUrl from config
-  if (!config.localization?.enabled === true) {
+  if (!config.localization?.enabled) {
     return config.storeUrl
   }

   return getSettings().storeURL
 }

140-151: HOC implementation looks correct but consider adding displayName for debugging.

The withStoreURL HOC correctly injects storeURL as an optional prop. Adding a displayName improves React DevTools debugging.

✨ Suggested improvement
 export function withStoreURL<
   Props extends { storeURL: string },
   PartialProps extends Omit<Props, 'storeURL'> & { storeURL?: string },
 >(Component: React.ComponentType<Props>): React.ComponentType<PartialProps> {
-  return (props: PartialProps) => {
+  const WrappedComponent = (props: PartialProps) => {
     return React.createElement(Component, {
       ...props,
       storeURL: props.storeURL ?? getStoreURL(),
     } as unknown as Props)
   }
+  WrappedComponent.displayName = `withStoreURL(${Component.displayName || Component.name || 'Component'})`
+  return WrappedComponent
 }

@ommeirelles
ommeirelles merged commit dc68316 into feat/multilanguage Feb 4, 2026
3 checks passed
@ommeirelles
ommeirelles deleted the feat/SFS-2968 branch February 4, 2026 14:58
lemagnetic added a commit that referenced this pull request Mar 5, 2026
## What's the purpose of this pull request?

Removing hardcoded labels:
- #3099
- #3102 
- #3107 
- #3104 
- #3103 
- #3125
- #3131
- #3116
- #3142
- #3192

Setting Up locales
- #3141
- #3143
- #3147
- #3156
- #3162
- #3145
- #3164
- #3169
- #3171
- #3176
- #3180
- #3169
 custom path
- #3185
- #3162
- #3156
- #3170

Components
- #3093
- #3175

Fetching content 

- #3165

Others
- #3176
- #3171
- #3181
- #3189
- #3205


## How to test locally?
- Run `pnpm I` (install all the new dependencies and needed packages)
- If you want to try localization feature, go
to`/discovery.config.default.js`:
Enable localization:
```
localization: {
  enabled: true
}
```
- Run `node packages/cli/bin/run.js generate-i18n ./packages/core` to
fetch the bindings

If the contentSource is not set to content platform yet, you will see a
message to update to it.
>   contentSource: {
>     type: 'CP',
>   },

⚠️ Note: Ensure the url is set to localhost for local testing. These
locale bindings are generated in `discovery.config` after running the
generate-i18n command.

```diff
localization: {
  enabled: true,
  defaultLocale: 'en-US',
   regions: {...},
    locales: {
      'pt-BR': {
           ...
        bindings: [
          {
            currencyCode: 'BRL',
-           url: 'https://brandless.fast.store/pt-BR',
+           url: 'http://localhost:3000/pt-BR',
            salesChannel: '2',
            isDefault: true,
            locales: [
              {
                code: 'pt-BR',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'it-IT': {
        ...
        bindings: [
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/it-IT',
+           url: 'http://localhost:3000/it-IT',
            salesChannel: '3',
            isDefault: true,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
          {
            currencyCode: 'EUR',
-           url: 'https://brandless.fast.store/europe/it',
+           url: 'http://localhost:3000/europe/it',
            salesChannel: '3',
            isDefault: false,
            locales: [
              {
                code: 'it-IT',
                isDefault: true,
              },
            ],
          },
        ],
      },
      'en-US': {
        code: 'en-US',
        name: 'English',
        languageCode: 'en',
        languageName: 'English',
        script: 'Latn',
        textDirection: 'ltr',
        regionCode: 'US',
        bindings: [
          {
            currencyCode: 'USD',
-           url: 'https://brandless.fast.store',
+           url: 'http://localhost:3000,
            salesChannel: '1',
            isDefault: true,
            locales: [
              {
                code: 'en-US',
                isDefault: true,
              },
            ],
          },
        ],
      },
    ...
}
```

- Go to /packages/core and run `npmn dev`

---------

Co-authored-by: Larícia Mota <[email protected]>
Co-authored-by: Leandro Rodrigues <[email protected]>
Co-authored-by: Otavio Moreira Meirelles <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.

3 participants