turash/bugulma/frontend/hooks/features/useLandingPage.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

72 lines
1.8 KiB
TypeScript

import { useCallback, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '@/contexts/AuthContext.tsx';
import { Organization } from '@/types.ts';
import { useNavigation } from '@/hooks/useNavigation.tsx';
import { useOrganizations } from '@/hooks/useOrganizations.ts';
import { useUI } from '@/hooks/useUI.ts';
export const useLandingPage = () => {
const { viewOrganization } = useNavigation();
const { openAddOrgWizard } = useUI();
const { organizations } = useOrganizations();
const { isAuthenticated } = useAuth();
const navigate = useNavigate();
const addOrgButtonRef = useRef<HTMLButtonElement>(null);
const [searchTerm, setSearchTerm] = useState('');
const onNavigateToMap = useCallback(
(sector?: string) => {
navigate(`/map${sector ? `?sector=${sector}` : ''}`);
},
[navigate]
);
const onNavigate = useCallback(
(page: string) => {
navigate(`/${page}`);
window.scrollTo(0, 0);
},
[navigate]
);
const onNavigateToAdmin = useCallback(() => {
navigate('/admin');
}, [navigate]);
const onAddOrganizationClick = useCallback(() => {
if (!isAuthenticated) {
navigate('/login');
return;
}
openAddOrgWizard();
}, [isAuthenticated, navigate, openAddOrgWizard]);
const onSearchSubmit = useCallback(() => {
if (searchTerm.trim()) {
navigate(`/map?search=${searchTerm.trim()}`);
}
}, [searchTerm, navigate]);
const onViewOrganization = useCallback(
(org: Organization) => {
viewOrganization(org);
},
[viewOrganization]
);
return {
addOrgButtonRef,
onNavigateToMap,
onAddOrganizationClick,
onViewOrganization,
onNavigate,
onNavigateToAdmin,
organizations,
searchTerm,
setSearchTerm,
onSearchSubmit,
};
};