import { useEffect, useState } from 'react'; import { authorizedGet } from '../../api'; import { useAuthToken } from './use-auth-token'; type User = { id: string; name: string; azure_id: string; created_at: string; role: string; email: string; phone: string; position: string; }; export const useOrgUsers = () => { const [users, setUsers] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const { getToken } = useAuthToken(); const fetchUsers = async () => { setLoading(true); setError(null); try { const response = await authorizedGet("/api/organisation/users", getToken); console.log(response) setUsers(response.data) } catch (err) { setError("Failed to fetch users"); } finally { setLoading(false); } }; useEffect(() => { fetchUsers(); }, []); return { users, loading, error, refetch: fetchUsers }; };