Skip to content

refactor(i18n): migrate orders, tables, customers, and dashboard to use-intl - #401

Merged
khaira777 merged 2 commits into
mainfrom
chore/378-i18n-migration-5c
Aug 19, 2026
Merged

khaira777 merged 2 commits into
mainfrom
chore/378-i18n-migration-5c

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

Migrate the order management, table management, customer management, and dashboard pages (plus the OrderHistoryGrid component) from the legacy useI18n()/t() flat-key API to use-intl useTranslations(), completing Phase 3 batch 5C (issue #378) of the i18n migration epic (#372).

Scope is exactly 6 files: orders/page.tsx, tables/page.tsx, customers/page.tsx, dashboard/page.tsx, components/orders/OrderHistoryGrid.tsx, and lib/i18n-enums.ts.

Key decisions:

  • Each component uses useTranslations(namespace) with typed leaf keys; multi-namespace files split into per-namespace translators (tOrders/tCommon/tNav/tWhatsappSend etc.).
  • i18n-enums.ts: ORDER_STATUS_LABEL_KEYS, TABLE_STATUS_LABEL_KEYS, and ITEM_STATUS_LABEL_KEYS converted from generic Record<string,string> dotted keys to exhaustively typed leaf-key maps (satisfies Record<Order['status'], OrdersKey> / Record<Table['status'], TablesKey> / Record<ItemStatusUnion, OrdersKey>). The other maps (ROLE/TENANT_STATUS/BUSINESS_TYPE/PAYMENT_STATUS) stay dotted because settings (batch 5E) still consumes TENANT_STATUS_LABEL_KEYS via the legacy bridge.
  • dashboard/page.tsx dynamic status interpolation t(orders.${order.status} as ...) replaced with a typed ORDER_STATUS_LABEL_KEYS lookup that keeps the raw-status fallback; the redundant localizeTemplate helper was removed in favor of direct ICU params (t('minutesValue', { minutes })).
  • Payment-method labels in the dashboard use a local typed BUILT_IN_PAYMENT_KEYS map because PAYMENT_METHODS.labelKey stays dotted for other unmigrated consumers.
  • orders/page.tsx and OrderHistoryGrid use local typed ORDER_TYPE_KEYS maps because the shared ORDER_TYPE_LABEL_KEYS stays dotted for the not-yet-migrated KDS batch (5D).
  • sendBillViaFlo still takes a legacy dotted-key translator; orders/page.tsx bridges it with a typed whatsapp.send adapter (same pattern as PaymentModal) rather than reintroducing legacy t().

Constraints: no wording, logic, or behavior changes; no new dependencies or migrations; the legacy useI18n bridge and compatibility adapter must remain for unmigrated batches (its removal is owned by #381); the two e2e assertions pinning setup/fa behavior must not be altered.

What Changed

  • Migrated orders, tables, customers, dashboard pages, and the OrderHistoryGrid component from the legacy useI18n() flat-key hook to use-intl useTranslations() with per-namespace translators and direct ICU parameter interpolation.
  • Converted ORDER_STATUS_LABEL_KEYS, ITEM_STATUS_LABEL_KEYS, and TABLE_STATUS_LABEL_KEYS in frontend/src/lib/i18n-enums.ts from dotted string maps to exhaustively typed use-intl leaf keys.
  • Added Playwright end-to-end test suite (frontend/e2e/i18n-batch-5c.spec.ts) validating English LTR and Persian RTL rendering across all migrated pages.

Risk Assessment

✅ Low: The migration from legacy useI18n to use-intl across the 6 scoped files is clean, strictly conforms to the approved scope and acceptance criteria, and introduces no regressions.

Testing

Executed translation integrity suite, RTL and chunk-splitting suites, Next.js desktop export build, and dedicated Playwright E2E tests validating localized rendering in English and Persian across all 5 migrated surfaces; all checks passed cleanly and captured full-page visual evidence.

  • Evidence: Dashboard Page (English LTR) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/dashboard-en.png)
  • Evidence: Dashboard Page (Persian RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/dashboard-fa.png)
  • Evidence: Orders Page (English LTR) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/orders-en.png)
  • Evidence: Orders Page (Persian RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/orders-fa.png)
  • Evidence: Tables Page (English LTR) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/tables-en.png)
  • Evidence: Tables Page (Persian RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/tables-fa.png)
  • Evidence: Customers Page (English LTR) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/customers-en.png)
  • Evidence: Customers Page (Persian RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/customers-fa.png)
  • Evidence: Order History Grid Component (English LTR) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/order-history-grid-en.png)
  • Evidence: Order History Grid Component (Persian RTL) (local file: /var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/no-mistakes-evidence/01M0D6PY3HABMDFH71W637DKE8/order-history-grid-fa.png)
  • Outcome: ⚠️ 1 info across 1 run (5m33s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ frontend/e2e/i18n-batch-5c.spec.ts - new test file written by agent: frontend/e2e/i18n-batch-5c.spec.ts
  • npm run test:translations
  • npm run test:locale-chunks
  • npm run test:rtl-dashboard-pos-common
  • npm run test:rtl-foundation
  • npm run test:rtl-setup-auth-settings
  • npm run test:rtl-kds-server-whatsapp
  • cd frontend && npx cross-env NEXT_BUILD_MODE=desktop npm run build
  • cd frontend && npx playwright test e2e/i18n-batch-5c.spec.ts
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…se-intl

Phase 3 batch 5C (issue #378). Replace useI18n()/t() with useTranslations() across the orders, tables, customers, and dashboard pages plus OrderHistoryGrid. ORDER_STATUS_LABEL_KEYS, TABLE_STATUS_LABEL_KEYS, and ITEM_STATUS_LABEL_KEYS are now exhaustively typed leaf-key maps; dynamic order-status interpolation and the sendBillViaFlo dotted-key callback are bridged with typed adapters. No wording or logic changes; the legacy bridge remains for later batches.
@khaira777
khaira777 merged commit c9fab25 into main Aug 19, 2026
12 checks passed
@khaira777
khaira777 deleted the chore/378-i18n-migration-5c branch August 19, 2026 14:42
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.

1 participant