import { useMsal } from '@azure/msal-react'; import { useMemo } from 'react'; import { createAuthenticatedApiClient } from '../../config/apiClientFactory'; import type { ApiClient } from '../../kiota/apiClient'; /** * Hook to get an authenticated API client instance * Uses MSAL for authentication */ export function useApiClient(): ApiClient { const { instance } = useMsal(); const apiClient = useMemo(() => { return createAuthenticatedApiClient(instance); }, [instance]); return apiClient; } /** * Hook to get the current user ID from MSAL */ export function useUserId(): string | null { const { accounts } = useMsal(); if (accounts.length === 0) { return null; } // Return the localAccountId (user's unique identifier) return accounts[0].localAccountId; }