From ac106ed9177c41cc076a5e217e6d1337325d5706 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Sat, 28 Feb 2026 14:15:18 -0800 Subject: [PATCH] =?UTF-8?q?feat(tracker):=20add=20product=20switcher=20?= =?UTF-8?q?=E2=80=94=20filter=20items=20by=20any=20product?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - product-config.ts: add getRequestProductId(req) + KNOWN_PRODUCTS - product-context.tsx: client-side product selection context - product-switcher.tsx: native select dropdown component - tracker-client.ts: inject x-product-id header on all API calls - proxy route: forward x-product-id header to platform-service - providers.tsx: wrap with ProductProvider - dashboard/layout.tsx: render ProductSwitcher in top nav --- .../src/app/api/tracker/[...path]/route.ts | 4 ++ .../tracker-web/src/app/dashboard/layout.tsx | 2 + dashboards/tracker-web/src/app/providers.tsx | 5 +- .../src/components/product-switcher.tsx | 22 +++++++++ .../tracker-web/src/lib/product-config.ts | 17 +++++++ .../tracker-web/src/lib/product-context.tsx | 48 +++++++++++++++++++ .../tracker-web/src/lib/tracker-client.ts | 13 ++++- 7 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 dashboards/tracker-web/src/components/product-switcher.tsx create mode 100644 dashboards/tracker-web/src/lib/product-context.tsx diff --git a/dashboards/tracker-web/src/app/api/tracker/[...path]/route.ts b/dashboards/tracker-web/src/app/api/tracker/[...path]/route.ts index 7c4a035e..a9cf0d9d 100644 --- a/dashboards/tracker-web/src/app/api/tracker/[...path]/route.ts +++ b/dashboards/tracker-web/src/app/api/tracker/[...path]/route.ts @@ -28,6 +28,10 @@ async function proxy(req: NextRequest, { params }: { params: Promise<{ path: str headers['Authorization'] = `Bearer ${tokenHeader}`; } + // Forward product switcher header so platform-service filters by product + const productId = req.headers.get('x-product-id'); + if (productId) headers['x-product-id'] = productId; + const fetchOptions: RequestInit = { method: req.method, headers, diff --git a/dashboards/tracker-web/src/app/dashboard/layout.tsx b/dashboards/tracker-web/src/app/dashboard/layout.tsx index 7eae1955..ad60edde 100644 --- a/dashboards/tracker-web/src/app/dashboard/layout.tsx +++ b/dashboards/tracker-web/src/app/dashboard/layout.tsx @@ -4,6 +4,7 @@ import { useEffect } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { useAuth } from '@/lib/auth-context'; +import { ProductSwitcher } from '@/components/product-switcher'; const NAV_ITEMS = [ { href: '/dashboard', label: 'Overview' }, @@ -51,6 +52,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
+ {user.email}