learning_ai_common_plat/dashboards/admin-web/src/app/providers.tsx
saravanakumardb1 ed7fa3f9a4 feat(admin): add product switcher — filter all data by any product
- product-config.ts: add getRequestProductId(req) helper + KNOWN_PRODUCTS list
- product-context.tsx: new React context storing selected productId in localStorage
- product-switcher.tsx: dropdown component with icons for all 4 products
- api.ts: pass x-product-id header from localStorage on all API calls
- providers.tsx: wrap with ProductProvider
- sidebar-nav.tsx: render ProductSwitcher between logo and nav
- repositories/users.ts + tokens.ts: accept optional productId parameter
- 8 API routes updated: users, auth/login, auth/forgot-password, seed,
  settings/plans, themes/active, analytics/retention, analytics/revenue
2026-02-28 14:12:15 -08:00

31 lines
922 B
TypeScript

'use client';
import { useEffect, type ReactNode } from 'react';
import { AuthProvider } from '@/lib/auth-context';
import { ThemeProvider } from '@/lib/theme-context';
import { StripeConfigProvider } from '@/lib/stripe-context';
import { ProductProvider } from '@/lib/product-context';
import { ToastProvider } from '@/components/ui/toast';
import { CSPostHogProvider } from '@/components/posthog-provider';
import { initTelemetry } from '@/lib/telemetry';
export function Providers({ children }: { children: ReactNode }) {
useEffect(() => {
initTelemetry();
}, []);
return (
<CSPostHogProvider>
<ThemeProvider>
<ProductProvider>
<AuthProvider>
<StripeConfigProvider>
<ToastProvider>{children}</ToastProvider>
</StripeConfigProvider>
</AuthProvider>
</ProductProvider>
</ThemeProvider>
</CSPostHogProvider>
);
}