chore: refactor project structure and clean up unused components
- Updated `TODO.md` to reflect new testing tasks and final structure expectations. - Simplified TypeScript path mappings in `tsconfig.json` for better clarity. - Revised business logic separation rules in `.cursor/rules` to align with new directory structure. - Deleted unused client components and services to streamline the codebase. - Adjusted import paths in scripts to match the new structure.
This commit is contained in:
43
src/hooks/useJiraAnalytics.ts
Normal file
43
src/hooks/useJiraAnalytics.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useTransition, useCallback } from 'react';
|
||||
import { getJiraAnalytics } from '@/actions/jira-analytics';
|
||||
import { JiraAnalytics } from '@/lib/types';
|
||||
|
||||
export function useJiraAnalytics() {
|
||||
const [analytics, setAnalytics] = useState<JiraAnalytics | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const loadAnalytics = useCallback((forceRefresh = false) => {
|
||||
startTransition(async () => {
|
||||
try {
|
||||
setError(null);
|
||||
|
||||
const result = await getJiraAnalytics(forceRefresh);
|
||||
|
||||
if (result.success && result.data) {
|
||||
setAnalytics(result.data);
|
||||
} else {
|
||||
setError(result.error || 'Erreur lors du chargement des analytics');
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMessage = err instanceof Error ? err.message : 'Erreur lors du chargement des analytics';
|
||||
setError(errorMessage);
|
||||
console.error('Erreur analytics Jira:', err);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
const refreshAnalytics = useCallback(() => {
|
||||
loadAnalytics(true); // Force refresh quand on actualise manuellement
|
||||
}, [loadAnalytics]);
|
||||
|
||||
return {
|
||||
analytics,
|
||||
isLoading: isPending,
|
||||
error,
|
||||
loadAnalytics,
|
||||
refreshAnalytics
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user