agent-ecosystem/src/renderer/hooks/useMemberStats.ts
iliya c99a9cfc48 feat: integrate CLI installer service and UI components
- Introduced the CliInstallerService to manage CLI installation, including status checks and installation processes.
- Added IPC handlers for CLI installer operations, enabling communication between main and renderer processes.
- Implemented the CliStatusBanner and CliStatusSection components to display CLI installation status and controls in the dashboard and settings.
- Enhanced the dashboard and settings UI to provide users with real-time feedback on CLI installation progress and errors.
- Updated the TeamDataService to support task clarification features, improving task management capabilities.
2026-02-26 17:58:51 +02:00

45 lines
1.1 KiB
TypeScript

import { useEffect, useState } from 'react';
import { api } from '@renderer/api';
import type { MemberFullStats } from '@shared/types';
export function useMemberStats(
teamName: string,
memberName: string | null
): { stats: MemberFullStats | null; loading: boolean; error: string | null } {
const [stats, setStats] = useState<MemberFullStats | null>(null);
const [loading, setLoading] = useState(memberName !== null);
const [error, setError] = useState<string | null>(null);
useEffect(() => {
if (!memberName) {
setStats(null);
setLoading(false);
setError(null);
return;
}
let cancelled = false;
setStats(null);
setLoading(true);
setError(null);
void (async () => {
try {
const result = await api.teams.getMemberStats(teamName, memberName);
if (!cancelled) setStats(result);
} catch (e) {
if (!cancelled) setError(e instanceof Error ? e.message : 'Unknown error');
} finally {
if (!cancelled) setLoading(false);
}
})();
return () => {
cancelled = true;
};
}, [teamName, memberName]);
return { stats, loading, error };
}