Skip to content

refactor(i18n): component migration 5C — orders, tables, customers, dashboard #378

Closed

Description

@khaira777

Refs: #372
Depends on: #375
Can parallel with: #376, #377, #379, #380

Context

Migrate order management, table management, customer management, and dashboard summary views from legacy useI18n() to useTranslations() from use-intl.

Global Component Migration Rules

  • Use const t = useTranslations('namespace') from use-intl.
  • Access keys via namespaced identifiers (e.g. useTranslations('orders') -> t('pending')).
  • Use compile-time type-safe keys verified against AppConfig.
  • Eliminate template-literal dynamic key construction; use exhaustively typed lookup mappings.
  • Do NOT remove the compatibility adapter or legacy hook in this PR. Issue refactor(i18n): remove legacy custom i18n implementation #381 owns final removal.
  • Do NOT alter translation wording or domain logic.

Files to Migrate (5 files)

  • frontend/src/app/(dashboard)/orders/page.tsx
  • frontend/src/app/(dashboard)/tables/page.tsx
  • frontend/src/app/(dashboard)/customers/page.tsx
  • frontend/src/app/(dashboard)/dashboard/page.tsx
  • frontend/src/components/orders/OrderHistoryGrid.tsx

Dynamic Key Handling

dashboard/page.tsx

Currently uses a type assertion on dynamic status interpolation:

t(`orders.${order.status}` as 'orders.pending' | ...)

Replace with exhaustively typed lookup mappings using the domain mappings from frontend/src/lib/i18n-enums.ts (ORDER_STATUS_LABEL_KEYS, TABLE_STATUS_LABEL_KEYS).

Ensure enum mappings in i18n-enums.ts are exhaustively typed against actual domain status types (e.g. satisfies Record<OrderStatus, OrderMessageKey>) rather than generic Record<string, string>.

What NOT to do

  • Do NOT remove frontend/src/hooks/useI18n.ts or the compatibility bridge in frontend/src/lib/i18n.ts.
  • Do NOT change any translation content or wording.
  • Do NOT replace application enum mappings with ICU select (domain enum lookups belong in typed TypeScript mappings).

Acceptance Criteria

  • All 5 files migrated to useTranslations().
  • Dynamic order/table status lookups use exhaustively typed mappings.
  • No unchecked string assertions or template-literal translation calls.
  • Compatibility bridge remains operational for unmigrated batches.

Verification

npm run lint
npm run build:frontend
npm test
npm run test:rtl-dashboard-pos-common

Activity

  1. added
    enhancement
    area:frontend
    on Aug 17, 2026
  2. self-assigned this
    on Aug 19, 2026
  3. khaira777 commented on Aug 19, 2026

    @khaira777
    ContributorAuthor

    Migrated and merged via #401.

    Confirmed: all 5 in-scope pages/components still used the legacy useI18n()/t() flat-key API.

    Changed:

    • orders/page.tsx, tables/page.tsx, customers/page.tsx, dashboard/page.tsx, and components/orders/OrderHistoryGrid.tsx → useTranslations('<namespace>') with typed leaf keys (multi-namespace files split into per-namespace translators).
    • lib/i18n-enums.ts → ORDER_STATUS_LABEL_KEYS, TABLE_STATUS_LABEL_KEYS, and ITEM_STATUS_LABEL_KEYS are now exhaustively typed (satisfies Record<…, MessageKey>); the other maps stay dotted until the settings batch (5E) migrates their consumers.
    • dashboard/page.tsx dynamic t(\orders.${order.status}`)interpolation replaced with the typedORDER_STATUS_LABEL_KEYSlookup (raw-status fallback preserved); the redundantlocalizeTemplate` helper was removed in favor of direct ICU params.
    • orders/page.tsx and OrderHistoryGrid use local typed ORDER_TYPE_KEYS maps; the sendBillViaFlo dotted-key callback is bridged with a typed whatsapp.send adapter.

    Tests/verification: lint 0 errors, tsc --noEmit clean, static export 25/25 routes, test:translations, test:locale-chunks, and test:rtl-dashboard-pos-common all green; No Mistakes pipeline review 0 findings, CI green. The pipeline also added frontend/e2e/i18n-batch-5c.spec.ts covering English (LTR) and Persian (RTL) rendering of all five pages.

    Acceptance criteria: all 4 items satisfied — no unchecked string assertions or template-literal translation calls remain, and the legacy compatibility bridge is left operational for the remaining batches.

    Remaining: legacy bridge removal is owned by #381; batches 5D (#379) and 5E (#380) are still open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:frontendenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions