Closed Datayama38 closed 4 months ago
The recent updates enhance the observatory's user interface by refining the dashboard and its components, improving data handling, and streamlining navigation and state management across various components. The changes focus on better usability, dynamic data interaction, and robust handling of user inputs and API interactions.
File Path | Change Summary |
---|---|
.../Dashboard.tsx |
Introduced a new dashboard component for data visualization and user interaction. |
.../FluxGraph.tsx |
Updated label handling in chart data to manage null values correctly. |
.../page.tsx |
Refactored to import and render the Dashboard component, simplifying the component's structure. |
.../common/SelectInList.tsx |
Added disabled property to list items for enabling/disabling options. |
.../observatoire/SelectPeriod.tsx |
Enhanced state management to dynamically disable months based on selected periods. |
.../observatoire/SelectTerritory.tsx |
Overhauled navigation and state management, and improved API interaction for territory selection. |
.../helpers/search.ts , .../hooks/useDashboard.ts , .../interfaces/common/contextInterface.ts |
Added new functions and updated interfaces to support enhanced functionality in the dashboard and its components. |
SelectTerritory
component improve autocomplete functionality, which aligns with the issue's objective to enhance autocomplete capabilities in the observatory.🐰✨ A dash of code, a sprinkle of UI, Refactored, enhanced, for you and I. Maps and graphs, all in their place, A smoother flow, a quicker pace. Hop along, let's explore, 🌍 With every click, discover more!
public/src/components/common/SelectInList.tsx (2)
`10-10`: Added optional `disabled` property to list items. This change allows individual items in the list to be disabled, enhancing the component's flexibility. --- `28-28`: Utilization of the `disabled` property in `MenuItem`. The `disabled` state of each item is now effectively controlled, which aligns with the new property addition in the list items interface.public/src/app/observatoire/territoire/page.tsx (2)
`3-3`: Imported `Dashboard` component. This import is necessary for the new structure where the `Dashboard` component is used to centralize the functionality. --- `18-18`: Usage of `Suspense` for lazy loading the `Dashboard` component. This is a good practice for potentially heavy components, improving the page load performance.public/src/interfaces/common/contextInterface.ts (4)
`1-1`: Imported `INSEECode` and `PerimeterType`. These imports are necessary for the new type definitions in the context interface. --- `5-5`: Changed `code` type to `INSEECode` in `Params`. This change ensures type safety by using a more specific type for the `code`. --- `21-21`: Added `lastPeriod` in `DashboardContextType`. This addition supports the new feature to restrict date selection based on the latest available data. --- `25-25`: Added new functions `onLoadTerritory`, `getName`, and `getLastPeriod`. These functions enhance the dashboard's functionality by managing territory data and period constraints dynamically. Also applies to: 27-27, 29-29public/src/helpers/search.ts (2)
`3-3`: Imported `PerimeterType`. This import is necessary for the new function `castPerimeterType` which uses this type. --- `25-39`: Implemented `castPerimeterType` function. This function correctly maps `PerimeterType` values to corresponding strings, enhancing readability and maintainability of the code where these mappings are needed.public/src/components/observatoire/SelectPeriod.tsx (2)
`6-6`: Imported `useState` and `useEffect`. These hooks are essential for implementing the dynamic state management in this component. --- `19-29`: Implemented dynamic disabling of months. This implementation correctly uses state and effects to dynamically disable months based on the last selected period, aligning with the PR objectives to restrict date selection.public/src/components/observatoire/SelectTerritory.tsx (3)
`6-6`: Replaced `useSearchParams` with `useRouter`. This change likely improves navigation handling by utilizing the router's capabilities directly. --- `20-29`: Updated API call logic and state management for search results. These changes enhance the component's functionality by dynamically fetching and managing search results based on user input. --- `36-64`: Updated rendering of options in the Autocomplete component. The rendering logic now correctly utilizes the updated state and provides a better user experience by displaying more informative labels and handling no-option scenarios.public/src/app/observatoire/territoire/graphs/FluxGraph.tsx (1)
`41-44`: Updated handling of `labels` assignment to correctly manage null values. This update ensures that the labels are correctly assigned even when `data` might be null, preventing runtime errors and improving data resilience.public/src/hooks/useDashboard.ts (3)
`3-3`: Imported `INSEECode` and `PerimeterType`. These imports are necessary for the updated type usage in the hook's state and functions. --- `11-18`: Modified initial state for `params`. The initial state now includes more specific types and default values, aligning with the updated requirements. --- `32-41`: Added new functions `onLoadTerritory`, `getLastPeriod`, and `getName`. These functions are crucial for dynamically managing territory data and period constraints, supporting the enhanced functionality of the dashboard. Also applies to: 76-96public/src/app/observatoire/territoire/Dashboard.tsx (7)
`1-1`: Use of 'use client' directive is appropriate for client-side components in Next.js. --- `28-131`: The `Dashboard` function component is well-structured and modular, effectively integrating various UI components and managing state transitions based on user interactions. --- `34-39`: Ensure proper error handling for `searchParams.get` calls. --- `108-108`: Consider simplifying the conditional logic for filtering `mapList`. It might be more readable to extract this logic into a separate function or use a more declarative approach. --- `51-128`: The loading state handling using `CircularProgress` is correctly implemented, ensuring a good user experience during data fetching. --- `113-117`: The conditional rendering logic for `SelectObserve` is clear and concise. --- `108-108`: The use of a hardcoded 'XXXXX' as a fallback code in the map list filtering logic could be replaced with a more meaningful default or obtained from a configuration. Consider using a constant that explains the significance of 'XXXXX', or fetch it from an environment variable or configuration file.
@Datayama38 je pense qu'il manque un coup de linter sur ton code mais sinon ça me semble ok
Sur la page territoire de l'observatoire:
Summary by CodeRabbit