- 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.
45 lines
1.1 KiB
TypeScript
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 };
|
|
}
|