# ESA Funding Integration

## Purpose

`ESAFunding` renders backend-owned ESA funding training content through the three-layer frontend architecture.

```text
View -> Business Logic -> API/Data Access -> Backend
```

Static ESA explanatory copy and FAQs live in dedicated frontend constants. Editable ESA lists, staff role guidance, parent conversation script, and resource records belong to the backend content catalog. The frontend also owns local UI state, URL validation, acknowledgement interaction state, and presentation.

## Frontend Layers

View:

- `frontend/src/components/frameworks/ESAFunding.tsx`
- `frontend/src/components/esa-funding/EsaFundingView.tsx`
- `frontend/src/components/esa-funding/EsaFundingHeader.tsx`
- `frontend/src/components/esa-funding/EsaFundingHero.tsx`
- `frontend/src/components/esa-funding/EsaFundingStateNotice.tsx`
- `frontend/src/components/esa-funding/EsaFundingKeyPoints.tsx`
- `frontend/src/components/esa-funding/EsaFundingApprovedUses.tsx`
- `frontend/src/components/esa-funding/EsaFundingImpactRoles.tsx`
- `frontend/src/components/esa-funding/EsaFundingFaq.tsx`
- `frontend/src/components/esa-funding/EsaFundingQuickReference.tsx`
- `frontend/src/components/esa-funding/EsaFundingResources.tsx`
- `frontend/src/components/esa-funding/EsaFundingAcknowledgement.tsx`
- `frontend/src/components/esa-funding/EsaFundingIcon.tsx`

Business logic:

- `frontend/src/business/esa-funding/hooks.ts`
- `frontend/src/business/esa-funding/selectors.ts`
- `frontend/src/business/esa-funding/types.ts`

Shared contracts:

- `frontend/src/shared/types/esaFunding.ts`
- `frontend/src/shared/constants/esaFunding.ts`
- `frontend/src/shared/constants/contentCatalog.ts`

## Backend Contract

The page reads:

- `GET /api/public/content-catalog/esa-funding-content`

Content payload is seeded in:

- `backend/src/db/seeders/content-catalog-data/content-catalog-seed-payloads.js`

## Behavior

- `useEsaFundingPage` loads ESA funding content and owns local FAQ expansion plus acknowledgement state.
- Static ESA intro, state notice copy, and FAQs are read from `frontend/src/shared/constants/esaFunding.ts`.
- Selectors handle FAQ toggling and resource URL validation.
- View components receive a prepared page model and do not call API/data access modules.
- Loading and error states are explicit through `StatePanel`.
- Resource records with valid `http` or `https` URLs render as external links. Invalid or placeholder URLs render as unavailable instead of using no-op click handlers.

## Data Ownership Rules

- Static ESA explanatory copy and FAQs may live in `frontend/src/shared/constants/esaFunding.ts`.
- Do not add editable ESA funding records such as approved uses, key points, checklist items, role guidance, conversation scripts, or resource records to frontend constants.
- Do not add frontend fallback ESA content payloads.
- Keep frontend logic limited to workflow state, resource URL validation, icon mapping, and presentation.
- Test-only fixtures may live in selector tests or `frontend/src/test-seeds/`.
