Skip to content

Refactor and use entities#176

Open
severo wants to merge 13 commits into
refactor-dashboard-logicfrom
refactor-and-use-entities
Open

Refactor and use entities#176
severo wants to merge 13 commits into
refactor-dashboard-logicfrom
refactor-and-use-entities

Conversation

@severo

@severo severo commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Take care: it is based on #175, not on main.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the dashboard data flow to introduce an entities layer with Zod-backed schemas, moves API client logic into features, and improves type-safety across the webapp (notably by enabling noUncheckedIndexedAccess). It also refactors the dashboard header for i18n usage and tightens some chart-related typings.

Changes:

  • Introduce @entities/dashboard/* Zod schemas and validate dashboard payloads in the API client.
  • Refactor dashboard widgets (header/year selection, year-level dashboard rendering) and add i18n strings for the header.
  • Strengthen typing in chart utilities (palette tuple typing, sunburst palettes) and enable stricter TS checks.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
webapp/tsconfig.app.json Enables noUncheckedIndexedAccess for stricter indexing safety.
webapp/src/widgets/dashboard/year-dashboard.tsx Adds year-scoped dashboard widget using entity schemas and chart adapters.
webapp/src/widgets/dashboard/loaded-dashboard.tsx Refactors year selection logic and composes Header + YearDashboard.
webapp/src/widgets/dashboard/header.tsx Replaces inline strings with i18n keys and normalizes year-change callback typing.
webapp/src/widgets/dashboard/dashboard.tsx Switches to new useApi() API and entity DashboardData typing.
webapp/src/shared/ui/chart.tsx Adds tooltip formatting TODO notes (no functional changes).
webapp/src/shared/lib/utils.ts Adds TODO notes about representing missing numeric values (no functional changes).
webapp/src/shared/lib/palette.ts Tightens chart palette typing to a fixed-length tuple.
webapp/src/shared/i18n/translations/fr/all4trees.json Adds dashboard header translation keys (FR).
webapp/src/shared/i18n/translations/en/all4trees.json Adds dashboard header translation keys (EN).
webapp/src/shared/api/client.ts Narrows shared API module to authenticated fetch helpers returning unknown.
webapp/src/features/popup/socio-eco/popup-socio-eco.tsx Simplifies TABS typing via as const.
webapp/src/features/popup/forest-inventory/popup-forest-inventory.tsx Simplifies TABS typing via as const.
webapp/src/features/hooks/useApi.ts Points useApi() to the new @features/contexts/ApiContext.
webapp/src/features/contexts/ApiContext.ts Moves API context typing to @features/api/client.
webapp/src/features/charts/soil/lib/taxon.ts Adds validation around taxon parsing (currently conflicts with caller expectations).
webapp/src/features/charts/soil/lib/sunburst.ts Replaces slice() with fixed tuples for palette levels.
webapp/src/features/charts/components/radar-benef-control.tsx Updates tooltip content (currently contains debug label formatting).
webapp/src/features/charts/biodiversity/chart-forest-potential.tsx Adds fromEpfData() adapter to map entity data into chart props.
webapp/src/features/api/client.ts Introduces feature-level API client that validates responses with Zod.
webapp/src/entities/dashboard/generic.ts Adds generic dashboard schemas/types (years, dictionaries, dashboard record).
webapp/src/entities/dashboard/epf.ts Adds EPF-specific schema/type for biodiversity chart inputs.
webapp/src/app/providers/ApiProvider.tsx Updates imports to the new API client/context locations.
webapp/package.json Adds zod dependency.
webapp/package-lock.json Locks zod dependency.
webapp/biome.json Updates import sorting/organization to include @entities/**.
Files not reviewed (1)
  • webapp/package-lock.json: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread webapp/src/entities/dashboard/generic.ts Outdated
Comment thread webapp/src/widgets/dashboard/loaded-dashboard.tsx
Comment thread webapp/src/features/charts/components/radar-benef-control.tsx
Comment thread webapp/src/features/charts/soil/lib/taxon.ts Outdated
Comment thread webapp/src/app/providers/ApiProvider.tsx
@severo severo force-pushed the refactor-and-use-entities branch from ccf5650 to 00338ed Compare June 25, 2026 14:21
severo and others added 5 commits June 25, 2026 10:22
@severo severo force-pushed the refactor-and-use-entities branch from 60d0156 to 66feeed Compare June 25, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants