diff --git a/dashboards/tracker-web/src/lib/auth-context.tsx b/dashboards/tracker-web/src/lib/auth-context.tsx index 730ab4d4..ca7d1313 100644 --- a/dashboards/tracker-web/src/lib/auth-context.tsx +++ b/dashboards/tracker-web/src/lib/auth-context.tsx @@ -1,6 +1,7 @@ 'use client'; import { createContext, useContext, useState, useEffect, useCallback, type ReactNode } from 'react'; +import { PRODUCT_ID } from './product-constants'; interface User { id: string; @@ -54,10 +55,15 @@ export function AuthProvider({ children }: { children: ReactNode }) { }, []); const login = useCallback(async (email: string, password: string) => { + // platform-service LoginSchema requires productId — use the selected product + // (set by the product switcher) or fall back to the default product. + const productId = + (typeof window !== 'undefined' && localStorage.getItem('tracker_selected_product')) || + PRODUCT_ID; const res = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ email, password }), + body: JSON.stringify({ email, password, productId }), }); if (!res.ok) { const body = await res.json().catch(() => ({}));