turash/bugulma/frontend/hooks/pages/useOrganizationPage.ts
Damir Mukimov 28f06d5787
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 31s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Failing after 1m22s
CI/CD Pipeline / frontend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
fix: resolve React Compiler and linting errors
- Fix React Compiler memoization issues in useOrganizationPage.ts
- Replace useCallback with useRef pattern in useKeyboard.ts
- Remove unnecessary dependencies from useMemo hooks
- Fix prettier formatting in api-client.ts and api-config.ts
- Replace any types with proper types in error-handling, http-client, security
- Remove unused imports and variables
- Move ImpactBreakdownChart component outside render in ImpactMetrics.tsx
- Fix setState in effect by using useMemo in HeritageBuildingPage.tsx
- Memoize getHistoryTitle with useCallback in MatchDetailPage and MatchNegotiationPage
- Add i18n for literal strings in community pages and LoginPage
- Fix missing dependencies in DashboardPage and DiscoveryPage
2025-12-25 00:21:47 +01:00

41 lines
1.5 KiB
TypeScript

import { useCallback } from 'react';
import { useAuth } from '@/contexts/AuthContext.tsx';
import type { Organization } from '@/types';
import { useOrganizations } from '@/hooks/useOrganizations';
import { useOrganizationActions } from '@/hooks/pages/useOrganizationActions';
import { useOrganizationAI } from '@/hooks/pages/useOrganizationAI';
import { useOrganizationProposals } from '@/hooks/pages/useOrganizationProposals.ts';
export const useOrganizationPage = (organization: Organization | undefined) => {
const { updateOrganization } = useOrganizations();
const { isAuthenticated } = useAuth();
const actions = useOrganizationActions();
const ai = useOrganizationAI(organization);
const proposals = useOrganizationProposals(organization);
const handleUpdateOrganization = (updatedOrg: Organization) => {
updateOrganization(updatedOrg);
};
const handleAnalyzeSymbiosis = useCallback(() => {
if (!isAuthenticated) return;
ai.handleAnalyzeSymbiosis();
}, [isAuthenticated, ai]);
const handleFetchWebIntelligence = useCallback(() => {
if (!isAuthenticated) return;
ai.handleFetchWebIntelligence();
}, [isAuthenticated, ai]);
return {
symbiosisState: ai.symbiosisState,
proposalState: proposals.proposalState,
handleAnalyzeSymbiosis,
handleFetchWebIntelligence,
handleSelectOrg: actions.handleSelectOrg,
handleUpdateOrganization,
handleMapNavigation: actions.handleMapNavigation,
actions: proposals.actions,
};
};