feat: add project key support for Jira analytics
- Introduced `projectKey` and `ignoredProjects` fields in Jira configuration to enhance analytics capabilities. - Implemented project validation logic in `JiraConfigClient` and integrated it into the `JiraConfigForm` for user input. - Updated `IntegrationsSettingsPageClient` to display analytics dashboard link based on the configured project key. - Enhanced API routes to handle project key in Jira sync and user preferences. - Marked related tasks as complete in `TODO.md`.
This commit is contained in:
43
hooks/useJiraAnalytics.ts
Normal file
43
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(() => {
|
||||
startTransition(async () => {
|
||||
try {
|
||||
setError(null);
|
||||
|
||||
const result = await getJiraAnalytics();
|
||||
|
||||
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();
|
||||
}, [loadAnalytics]);
|
||||
|
||||
return {
|
||||
analytics,
|
||||
isLoading: isPending,
|
||||
error,
|
||||
loadAnalytics,
|
||||
refreshAnalytics
|
||||
};
|
||||
}
|
||||
@@ -55,7 +55,9 @@ export function useJiraConfig() {
|
||||
baseUrl: '',
|
||||
email: '',
|
||||
apiToken: '',
|
||||
enabled: false
|
||||
enabled: false,
|
||||
projectKey: '',
|
||||
ignoredProjects: []
|
||||
});
|
||||
return { success: true, message: response.message };
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user