Refactor and use entities#176
Open
severo wants to merge 13 commits into
Open
Conversation
There was a problem hiding this comment.
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.
ccf5650 to
00338ed
Compare
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
60d0156 to
66feeed
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Take care: it is based on #175, not on main.