Hooks

43 custom hooks in frontend/src/hooks/, providing reusable stateful logic for forms, calculations, UI interactions, authentication, and URL state management.

Core Hooks

HookFilePurpose
useEntityFormuseEntityForm.tsGeneric entity CRUD form state management
useFinancialDocumentFormuseFinancialDocumentForm.tsShared form logic for Quotes and Invoices
useAmountCalculationuseAmountCalculation.tsLine item amount/tax calculations
useLineItemsTableuseLineItemsTable.tsLine item table add/edit/remove state
useDialogManageruseDialogManager.tsCoordinated dialog open/close state
useInlineEdituseInlineEdit.tsClick-to-edit inline field editing
useResizableColumnsuseResizableColumns.tsDrag-to-resize table column state
useCleanupTimeoutuseCleanupTimeout.tsSafe setTimeout with auto-cleanup on unmount

Auth & Permissions

HookPurpose
useAuthInitBootstrap authentication state on app load
usePermissionsCheck RBAC Authorization permissions for current user
useSessionStorageTyped session storage wrapper

See Authentication for the full auth flow.

Domain-Specific Hooks

HookDomainRelated
useUValueCalculationThermal U-value calculationsEnergy Calculations, Building Components
useGeocodingAddress geolocation lookupBuildings
useContactLookupContact search/autocompleteContacts
useDynamicFaviconEnvironment-aware faviconFrontend Architecture

URL State Hooks (hooks/url-state/)

Mandatory — never use raw useSearchParams. See URL State Management.

HookPurpose
useTabState(validTabs, default)Tab switching synced to URL
useFilterState(defaults)Multi-param filter state in URL
useModalState(param?)Deep-linkable modal/dialog
useMultiSortState(columns, defaultSort)Multi-column sort with Shift+Click stacking

Property Mapping Hooks (hooks/property-mappings/)

Hooks for HubSpot Integration property field mapping configuration between HubSpot and Renewa One entities.

Usage Rules

Data TypeCorrect ToolWrong Tool
Server entitiesReact Query Pattern via lib/queries/useState
URL-shareable UIURL state hooksraw useSearchParams
Form fieldsreact-hook-form + Zodmanual useState per field
Transient UIuseStateZustand

See State Management for the complete decision matrix.