Files
ln-bi/src/auth/useAuth.ts
kkfluous 8598aea445 feat(scheduling): restrict scheduling module to allowed users only
Only userId 1105261382487539712 and 1116631120763437056 can see the
scheduling tab. Other users see only assets + mileage modules.

- Add userId to frontend AuthState.user type
- App.tsx conditionally includes scheduling module based on user ID
- Backend already returns userId in auth exchange response

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:47:57 +08:00

20 lines
450 B
TypeScript

import { createContext, useContext } from 'react';
export interface AuthState {
isLoading: boolean;
isAuthenticated: boolean;
user: { userId: string; userName: string; permissionLevel: string; depName: string } | null;
error: string | null;
}
export const AuthContext = createContext<AuthState>({
isLoading: true,
isAuthenticated: false,
user: null,
error: null,
});
export function useAuth() {
return useContext(AuthContext);
}