turash/bugulma/frontend/hooks/pages/useOrganizationAI.ts
Damir Mukimov 6347f42e20
Consolidate repositories: Remove nested frontend .git and merge into main repository
- Remove nested git repository from bugulma/frontend/.git
- Add all frontend files to main repository tracking
- Convert from separate frontend/backend repos to unified monorepo
- Preserve all frontend code and development history as tracked files
- Eliminate nested repository complexity for simpler development workflow

This creates a proper monorepo structure with frontend and backend
coexisting in the same repository for easier development and deployment.
2025-11-25 06:02:57 +01:00

49 lines
1.4 KiB
TypeScript

/**
* Organization AI analysis hook
* Handles symbiosis analysis and web intelligence for organizations
* Separated from other concerns for better SRP
*/
import { useMemo } from 'react';
import type { Organization } from '@/types.ts';
import { useAnalyzeSymbiosis, useGetWebIntelligence } from '@/hooks/useGemini.ts';
import { useOrganizations } from '@/hooks/useOrganizations.ts';
import { useTranslation } from '@/hooks/useI18n.tsx';
export const useOrganizationAI = (organization: Organization | undefined) => {
const { organizations } = useOrganizations();
const { t } = useTranslation();
const {
data: symbiosisResult,
isPending: isAnalyzing,
error: analysisError,
refetch: analyzeSymbiosis,
} = useAnalyzeSymbiosis(organization!, organizations, t);
const {
data: webIntelResult,
isPending: isFetchingWebIntel,
error: webIntelError,
refetch: fetchWebIntelligence,
} = useGetWebIntelligence(organization?.Name, t);
const symbiosisState = useMemo(
() => ({
symbiosisResult,
isAnalyzing,
analysisError: analysisError?.message || null,
webIntelResult,
isFetchingWebIntel,
webIntelError: webIntelError?.message || null,
}),
[symbiosisResult, isAnalyzing, analysisError, webIntelResult, isFetchingWebIntel, webIntelError]
);
return {
symbiosisState,
handleAnalyzeSymbiosis: analyzeSymbiosis,
handleFetchWebIntelligence: fetchWebIntelligence,
};
};