Skip to content

Atlas: Display stored fields and improve navigation in farm creation#224

Merged
BoraIneviNMI merged 19 commits into
developmentfrom
FDM209
Aug 11, 2025
Merged

Atlas: Display stored fields and improve navigation in farm creation#224
BoraIneviNMI merged 19 commits into
developmentfrom
FDM209

Conversation

@BoraIneviNMI
Copy link
Copy Markdown
Collaborator

@BoraIneviNMI BoraIneviNMI commented Aug 5, 2025

  • New Features
    • Users see the previously created fields in green color on the farm creation wizard atlas.
    • Users can view summarized info about the previously created fields by clicking on them.
    • Users cannot select new fields that are completely covered by the previously created fields.
    • Users can go back to the new field selection screen from the edit field screen.
    • Users can continue to the edit field screen without adding any fields.

Closes #209

Summary by CodeRabbit

  • New Features
    • Show already saved fields on the atlas alongside available and selected fields.
    • Click saved fields to view a details popup with name, area, and land use.
    • Added “Terug naar kaart” button on the fields page to return to the map.
  • Improvements
    • Saved fields are excluded from selection/availability; hover respects exclusions.
    • Continue action enabled when fields are already saved.
    • Selected fields color changed to yellow.
    • New fields are numbered sequentially after existing ones.
  • Bug Fixes
    • Prevented map extent errors when no fields are present.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Aug 5, 2025

🦋 Changeset detected

Latest commit: f62e218

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@svenvw/fdm-app Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds display and click-to-info for already saved fields on the atlas, excludes saved fields from available/selected layers, updates selection panel to conditionally continue via client navigation, introduces a field details popup, adds a “back to map” button on the fields page, and adjusts naming and view bounds handling.

Changes

Cohort / File(s) Summary
Atlas panels and interaction
fdm-app/app/components/blocks/atlas/atlas-panels.tsx
Adds NavLink; expands layerExclude to string or string[]; normalizes exclusion query; attaches/removes map click/load listeners; FieldsPanelSelection gains numFieldsSaved and continueTo; early return on empty selection; conditional “Doorgaan” NavLink vs save button.
Atlas sources and filtering
fdm-app/app/components/blocks/atlas/atlas-sources.tsx
Adds excludedLayerId to FieldsSourceSelected to block clicks on excluded layer; FieldsSourceAvailable gains exclude prop to filter features by b_id_source; updates effect deps.
Atlas viewstate
fdm-app/app/components/blocks/atlas/atlas-viewstate.tsx
getBounds guards against empty features before geojsonExtent.
Field details popup
fdm-app/app/components/blocks/field/popup.tsx
New FieldDetailsInfoPopup dialog showing name, area, and land use for a field; optional hint tooltip.
Sidebar container
fdm-app/app/components/custom/sidebar-page.tsx
Accepts and renders children after nav items.
Farm create atlas route
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
Loader fetches existing fields, derives cultivation names, returns fieldsSaved and continueTo; MapGL adds non-interactive saved fields layer and excludes it elsewhere; click on saved field opens FieldDetailsInfoPopup; hover excludes saved layer; action continues field numbering after existing count with fallback.
Farm create fields route
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
Renders a button inside SidebarPage linking back to the atlas.
Farm create new field route
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
Passes exclude={fieldsSaved.features} to FieldsSourceAvailable to hide already saved fields.
Changesets
.changeset/happy-olives-drop.md, .changeset/nine-bushes-rest.md, .changeset/thin-bushes-remain.md, .changeset/wicked-apes-smell.md
Notes minor releases: back-to-atlas button, show stored fields on atlas, selected color change to yellow, and continued numbering of new fields.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant R as Atlas Route (loader/action)
  participant S as Services (getFields, getCultivations)
  participant C as Atlas Component
  participant M as MapGL
  participant P as FieldDetailsInfoPopup

  U->>R: Load /farm/create/:farm/:calendar/atlas
  R->>S: getFields(farm, timeframe)
  S-->>R: fields[]
  loop per field
    R->>S: getCultivations(field)
    S-->>R: cultivations|empty
  end
  R-->>C: { fieldsSaved, continueTo, timeframe }

  C->>M: Render layers (saved, available, selected), exclude saved
  U->>M: Click saved field
  M-->>C: saved field feature
  C->>P: Open with name, area, cultivation

  alt Has saved fields and no new selections
    U->>C: Click "Doorgaan" (NavLink)
    C-->>U: Navigate to fields page
  else New selections present
    U->>C: Click "Velden opslaan"
    C->>R: POST selected fields
    R-->>C: Response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Fetch and display stored fields on atlas; adjust initial view to stored fields bbox (#209) Stored fields are fetched and displayed; bbox adjustment to stored fields is not explicit.
Field state coloring: Available Blue, Selected Yellow, Stored Light Green (#209) Selected color changed to yellow; specific colors for available and stored not verified.
Stored field interaction: click shows popup with Name, Area (ha), Cultivation Name (#209)
Fields page: button to navigate back to atlas (#209)
Conditional atlas continue button with client-side navigation when only stored fields exist (#209)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Change selected color to yellow (.changeset/thin-bushes-remain.md) Color specification partly overlaps with issue but exact palette and stored/available colors are not defined here; however, it is tangentially related. Marking as potentially borderline but acceptable.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • gerardhros

Poem

In fields of green I hop with cheer,
Saved plots whisper, “We’re right here!”
A yellow glow for picks anew,
A button back to map—woohoo!
Click a patch, a tale will pop—
Names and hectares, crop by crop.
Thump-thump—onward, nonstop! 🐇🌾🗺️


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0682007 and f62e218.

📒 Files selected for processing (4)
  • .changeset/happy-olives-drop.md (1 hunks)
  • .changeset/nine-bushes-rest.md (1 hunks)
  • .changeset/thin-bushes-remain.md (1 hunks)
  • .changeset/wicked-apes-smell.md (1 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch FDM209

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.88%. Comparing base (d8e5967) to head (f62e218).
⚠️ Report is 20 commits behind head on development.

Additional details and impacted files
@@             Coverage Diff              @@
##           development     #224   +/-   ##
============================================
  Coverage        92.88%   92.88%           
============================================
  Files               85       85           
  Lines            12885    12885           
  Branches          1294     1294           
============================================
  Hits             11968    11968           
  Misses             915      915           
  Partials             2        2           
Flag Coverage Δ
fdm-calculator 94.61% <ø> (ø)
fdm-core 91.60% <ø> (ø)
fdm-data 94.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BoraIneviNMI BoraIneviNMI requested a review from SvenVw August 5, 2025 14:01
@BoraIneviNMI BoraIneviNMI marked this pull request as ready for review August 5, 2025 14:10
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (1)
fdm-app/app/components/blocks/atlas/atlas-sources.tsx (1)

77-77: Add missing dependency to useEffect

The excludedLayerId prop should be included in the useEffect dependency array to ensure the click handler uses the current value and re-registers when it changes.

-    }, [map, availableLayerId, setFieldsData])
+    }, [map, availableLayerId, setFieldsData, excludedLayerId])
🧹 Nitpick comments (2)
fdm-app/app/components/blocks/atlas/atlas-sources.tsx (1)

168-181: Remove unused variable

The count variable is incremented but never used. Consider removing it to clean up the code.

-                            let count = 0
                             for await (const feature of iter) {
                                 if (
                                     !unwantedIds.has(
                                         feature.properties!.b_id_source,
                                     )
                                 ) {
                                     featureClass.features.push({
                                         ...feature,
                                         id: i,
                                     })
-                                } else {
-                                    count++
                                 }
                                 i += 1
                             }
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

115-137: Consider extracting cultivation name logic

The logic for determining cultivation names is complex and could be extracted into a separate function for better maintainability and testability.

async function getCultivationName(field: Field, fdm: any, principalId: string, timeframe: any): Promise<string> {
    if (field.b_lu_name) {
        return field.b_lu_name;
    }
    
    try {
        const cultivations = await getCultivations(
            fdm,
            principalId,
            field.b_id,
            timeframe,
        );
        
        return cultivations.length > 0 
            ? cultivations[0].b_lu_name 
            : "geen gewassen";
    } catch (e) {
        console.warn(e);
        return "gewassen onbekend";
    }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8914fbc and bc6ae23.

📒 Files selected for processing (8)
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx (7 hunks)
  • fdm-app/app/components/blocks/atlas/atlas-sources.tsx (6 hunks)
  • fdm-app/app/components/blocks/atlas/atlas-styles.tsx (1 hunks)
  • fdm-app/app/components/blocks/atlas/atlas-viewstate.tsx (1 hunks)
  • fdm-app/app/components/blocks/field/popup.tsx (1 hunks)
  • fdm-app/app/components/custom/sidebar-page.tsx (2 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (11 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx (1 hunks)
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: the `farmlayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structu...
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The `FarmLayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structure for farm-related pages, with support for farm selection dropdown, customizable breadcrumb titles, and flexible content rendering through either children or Outlet components.

Applied to files:

  • fdm-app/app/components/custom/sidebar-page.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the fdm project, navlink and other routing components can be imported from either "react-router" ...
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-app/app/components/custom/farm/farm-title.tsx:3-3
Timestamp: 2025-04-18T13:49:17.029Z
Learning: In the fdm project, NavLink and other routing components can be imported from either "react-router" or "react-router-dom" as react-router-dom is included in react-router.

Applied to files:

  • fdm-app/app/components/custom/sidebar-page.tsx
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: in react-map-gl components, when querying rendered features via map.queryrenderedfeatures(), the eff...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/components/blocks/atlas/atlas-sources.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: when handling different map event types in react-map-gl v7.1.8, use maplayermouseevent for mouse eve...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the project uses `react-router` v7, and the `data` function is exported and used for error handling ...
Learnt from: SvenVw
PR: SvenVw/fdm#16
File: fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_catalogue.fertilizers.tsx:1-1
Timestamp: 2024-12-16T10:56:07.561Z
Learning: The project uses `react-router` v7, and the `data` function is exported and used for error handling in loaders and actions.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: map configuration in the application should be modularized using the `usemapconfig` hook and `mapcon...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:164-212
Timestamp: 2025-01-31T16:06:33.810Z
Learning: Map configuration in the application should be modularized using the `useMapConfig` hook and `MapControls` component to maintain consistency across all MapGL instances.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: when facing prop name inconsistencies with react-map-gl (like mapboxaccesstoken vs mapboxapiaccessto...
Learnt from: SvenVw
PR: SvenVw/fdm#161
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2025-06-10T13:10:03.154Z
Learning: When facing prop name inconsistencies with react-map-gl (like mapboxAccessToken vs mapboxApiAccessToken), using different import statements can resolve the issue more elegantly than changing prop names across multiple files.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: in `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of mapbox gl resources is not nec...
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/components/blocks/atlas/atlas-sources.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the context of this react router v7 project, it's important to follow the pattern of importing on...
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:53:44.578Z
Learning: In the context of this React Router v7 project, it's important to follow the pattern of importing only the types (like UseFormReturn) from "react-hook-form" while importing the Form component from "react-router" to avoid naming conflicts.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: when updating react components that use both react-hook-form and react router v7, it's important to ...
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:58:10.465Z
Learning: When updating React components that use both react-hook-form and React Router v7, it's important to only import types (like UseFormReturn, FieldValues) from react-hook-form to avoid naming conflicts with React Router's Form component. Use `import type { ... } from 'react-hook-form'` syntax to ensure only types are imported.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: in react router v7+, to ensure error pages are displayed correctly: 1. export the errorboundary comp...
Learnt from: SvenVw
PR: SvenVw/fdm#81
File: fdm-app/app/root.tsx:79-79
Timestamp: 2025-02-18T11:00:54.405Z
Learning: In React Router v7+, to ensure error pages are displayed correctly:
1. Export the ErrorBoundary component from the root route
2. Include the Scripts component in the Layout
3. Export the Layout through the default App component

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: in the atlas component's mapfieldsprops interface, mapstyle is intentionally restricted to "mapbox:/...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-sources.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🔇 Additional comments (16)
fdm-app/app/components/blocks/atlas/atlas-viewstate.tsx (1)

8-8: LGTM! Defensive programming improvement.

The addition of fields.features.length > 0 check prevents potential errors when geojsonExtent is called on empty feature collections. This is a solid defensive programming practice that ensures robust handling of edge cases.

fdm-app/app/components/custom/sidebar-page.tsx (2)

12-17: LGTM! Clean implementation of explicit children prop.

The explicit destructuring of the children prop in the function signature improves code clarity and enables the sidebar to render additional content beyond navigation items. This maintains backward compatibility while enabling new functionality.


45-46: Good placement of children after navigation items.

Rendering children after the mapped navigation items provides a logical content flow where primary navigation comes first, followed by additional interactive elements.

fdm-app/app/components/blocks/field/popup.tsx (2)

23-28: LGTM! Well-structured component interface.

The component follows React best practices with proper TypeScript typing, controlled state pattern, and clear prop interface. The use of Feature<Polygon> type ensures type safety for GeoJSON data.


35-42: Nice implementation of conditional tooltip.

The conditional rendering of the hint tooltip with proper accessibility considerations (using TooltipTrigger asChild) provides a clean user experience for additional field information.

fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx (1)

155-155: Good UX enhancement with the "Add more fields" button.

The addition of a dedicated button for adding more fields improves the user flow by providing clear navigation back to field selection, which aligns with the PR objective of enhancing navigation flexibility.

fdm-app/app/components/blocks/atlas/atlas-styles.tsx (3)

36-37: LGTM! Color change aligns with PR objectives.

The change from red to yellow (#ffcf0d) for selected fields implements the required color-coding where "newly selected fields" should be displayed in yellow. The opacity of 0.6 provides good visual prominence without being overwhelming.


43-46: Verify if separate styling is needed for "fieldsPreviouslyCreated" vs "fieldsSaved".

Both "fieldsPreviouslyCreated" and "fieldsSaved" layers have identical styling (green color #10b981, opacity 0.9). While this might be intentional if they represent the same conceptual state, consider if they need visual distinction.

Please verify if these two layer types should have different visual styling to help users distinguish between previously created fields and newly saved fields, or if the identical styling is intentional.


39-42: Good opacity adjustment for saved fields.

Increasing the opacity to 0.9 for saved fields makes them more prominent, which is appropriate for indicating their permanent/stored state compared to available or selected fields.

fdm-app/app/components/blocks/atlas/atlas-panels.tsx (4)

28-28: Good backward-compatible implementation

The flexible type for layerExclude and the normalization logic correctly handle both single string and array inputs, maintaining backward compatibility while supporting the new requirement to exclude multiple layers.

Also applies to: 46-48


170-170: Good defensive programming

The early return prevents unnecessary API calls when no fields are selected.


288-288: Verify layout consistency after removing fixed width

The removal of the w-[350px] class may affect the panel's layout consistency. Ensure this doesn't cause unwanted layout shifts in different viewport sizes.


297-303: Well-implemented navigation flow

The conditional navigation using NavLink aligns perfectly with the PR objectives, allowing users to continue without selecting new fields when previously created fields exist.

fdm-app/app/components/blocks/atlas/atlas-sources.tsx (1)

137-141: Efficient exclusion implementation

Good use of Set for O(1) lookup performance when filtering features.

fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (2)

269-282: Well-implemented click handling for previously created fields

The click handler correctly identifies polygon features from the specific source and triggers the popup display. Good type safety with the Feature cast.


303-303: Excellent implementation of field exclusion and display logic

The configuration correctly prevents selection overlap between new and existing fields while maintaining visual distinction. The use of FieldsSourceNotClickable for previously created fields is a clean architectural choice.

Also applies to: 315-315, 320-325

Comment on lines +45 to +49
{field.properties.b_area}
{" ha"}
</DialogDescription>
<DialogDescription>
{field.properties.b_lu_name}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Inconsistent optional chaining for field properties.

Line 34 correctly uses optional chaining (field.properties?.b_name) with a fallback, but lines 45 and 49 access properties without optional chaining. This could cause runtime errors if field.properties is undefined.

Apply this diff to ensure consistent optional chaining:

                    <DialogDescription>
-                        {field.properties.b_area}
+                        {field.properties?.b_area ?? "Onbekend"}
                        {" ha"}
                    </DialogDescription>
                    <DialogDescription>
-                        {field.properties.b_lu_name}
+                        {field.properties?.b_lu_name ?? "Onbekend"}
                    </DialogDescription>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{field.properties.b_area}
{" ha"}
</DialogDescription>
<DialogDescription>
{field.properties.b_lu_name}
<DialogDescription>
{field.properties?.b_area ?? "Onbekend"}
{" ha"}
</DialogDescription>
<DialogDescription>
{field.properties?.b_lu_name ?? "Onbekend"}
</DialogDescription>
🤖 Prompt for AI Agents
In fdm-app/app/components/blocks/field/popup.tsx around lines 45 to 49, the code
accesses field properties without optional chaining, which risks runtime errors
if field.properties is undefined. Update these lines to use optional chaining
(e.g., field.properties?.b_area and field.properties?.b_lu_name) to safely
access the properties and maintain consistency with line 34.

Comment thread fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
Comment thread fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
@coderabbitai coderabbitai Bot added the branch:development Issue only affecting development, not the main branch (yet) label Aug 5, 2025
Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw left a comment

Choose a reason for hiding this comment

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

Looks good! I made some small improvements as well. Can you check the comments left?

Comment thread .changeset/crazy-ends-sell.md Outdated
---

- minor: On the farm create wizard atlas page show the already stored fields as well, next to the available fields and selected fields
- minor: Add a button at the fields page on the farm create wizard to go back to the atlas page to select more fields
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use separate changeset per change. Otherwise this will not line up correctly for the changelog

<Button className="w-full" disabled>
<Check /> Sla geselecteerde percelen op
</Button>
<NavLink to={continueTo} className="flex-1">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In case the user has no fields selected of saved fields at the farm the button is still active, but the /fields page is not working, In this case can the button be disabled to prevent the user clicking on it?

Comment thread fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (2)

104-176: Verify cultivation fetching error handling and consider performance optimization.

The loader function correctly fetches existing fields and generates GeoJSON features. However, there are potential areas for improvement:

  1. Error handling: The cultivation fetching has proper try-catch with fallback values, which is good.
  2. Performance concern: Each field triggers a separate getCultivations call, which could be inefficient for farms with many fields.

Consider batching cultivation queries or implementing a single query that joins fields with their cultivations:

// Instead of individual getCultivations calls per field, consider:
const allCultivations = await getAllCultivationsForFields(fdm, session.principal_id, fieldIds, timeframe)
// Then map cultivations to fields in memory

388-402: Improve error handling and consider field naming strategy.

The field naming logic correctly accounts for existing fields, but there are some considerations:

  1. Error handling: The try-catch approach is good for handling potential getFields failures
  2. Naming strategy: Sequential numbering may not be ideal if fields can be deleted, as it could create gaps or confusion

Consider a more robust field naming strategy:

// Option 1: Always use timestamp-based or UUID-based naming
const b_name = `Perceel ${Date.now()}-${index}`

// Option 2: Find the highest existing field number and increment
const existingNumbers = fields
    .map(f => f.b_name?.match(/Perceel (\d+)/)?.[1])
    .filter(Boolean)
    .map(Number)
const nextNumber = existingNumbers.length > 0 ? Math.max(...existingNumbers) + 1 : 1
const b_name = `Perceel ${nextNumber + index}`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c92084f and 5208dc6.

📒 Files selected for processing (3)
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx (6 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (12 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
🧰 Additional context used
🧠 Learnings (27)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.
📚 Learning: a shared layout component `farmlayoutbase` has been created in `components/custom/farm-layout-base.t...
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `farmlayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structu...
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The `FarmLayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structure for farm-related pages, with support for farm selection dropdown, customizable breadcrumb titles, and flexible content rendering through either children or Outlet components.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `updatefield` function in fdm-core has optional parameters after `fdm` and `b_id`. the typescrip...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core has optional parameters after `fdm` and `b_id`. The TypeScript definitions might show 8 required parameters due to a potential version mismatch.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the fdm application, cultivation retrieval logic should be centralized in utility functions rathe...
Learnt from: SvenVw
PR: SvenVw/fdm#116
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx:111-154
Timestamp: 2025-04-04T14:27:39.518Z
Learning: In the FDM application, cultivation retrieval logic should be centralized in utility functions rather than duplicated across loader and action functions to improve maintainability and ensure consistent behavior.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: a comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `basef...
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in fdm-app/app/routes/signin._index.tsx, the redirect destinations are intentionally inconsistent by...
Learnt from: SvenVw
PR: SvenVw/fdm#151
File: fdm-app/app/routes/signin._index.tsx:101-101
Timestamp: 2025-06-02T10:31:27.097Z
Learning: In fdm-app/app/routes/signin._index.tsx, the redirect destinations are intentionally inconsistent by design: the component defaults new sign-ins to "/welcome" (line 101) while the loader redirects authenticated users to "/farm" (line 80) and the action uses "/farm" as fallback (line 434). This creates appropriate user flows where new users complete their profile via the welcome page, while existing authenticated users bypass it and go directly to the main application.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: when adding multiple harvests in fdm-app, use promise.all instead of promise.allsettled to ensure at...
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `addfield` function in fdm-core should verify field creation within the same transaction by chec...
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.027Z
Learning: The `addField` function in fdm-core should verify field creation within the same transaction by checking the existence of the field and all its required relations (field data, acquiring info, geometry) before resolving its promise.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `updatefield` function in fdm-core has optional parameters that don't need to be passed as undef...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:34:20.850Z
Learning: The `updateField` function in fdm-core has optional parameters that don't need to be passed as undefined. Only `fdm` and `b_id` are required.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: authentication for the “app.addfarm.new” route is already handled globally in “fdm-app/app/routes/ap...
Learnt from: SvenVw
PR: SvenVw/fdm#23
File: fdm-app/app/routes/app.addfarm.new.tsx:15-17
Timestamp: 2024-12-19T13:20:44.152Z
Learning: Authentication for the “app.addfarm.new” route is already handled globally in “fdm-app/app/routes/app.tsx,” automatically redirecting unauthenticated users to the SignIn page.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `addfield` function in fdm-core should use database transactions and field verification to ensur...
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.028Z
Learning: The `addField` function in fdm-core should use database transactions and field verification to ensure field availability before resolving its promise, eliminating the need for sleep workarounds.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `getusersinorganization` function in fdm-core/src/organization.ts needs to include user id and e...
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needs to include user ID and email fields to support role updates and user removal operations, which will be fixed in a future commit (b17fac16c9e5a0de56d0346e712b2ce966d305d5).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `updatefield` function in fdm-core requires 8 parameters: fdm, b_id (required), and 6 optional p...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires 8 parameters: fdm, b_id (required), and 6 optional parameters (b_name, b_id_source, b_geometry, b_acquiring_date, b_acquiring_method, b_discarding_date).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `getusersinorganization` function in fdm-core/src/organization.ts currently returns only firstna...
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts currently returns only firstname, surname, image, and role, but needs to include id and email fields to support downstream operations like role updates and user removal. This will be fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `getusersinorganization` function in fdm-core/src/organization.ts needed to include id and email...
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needed to include id and email fields for users, which was fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: when using `updatefield` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_nam...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the `addfield` function in fdm-core should use database transactions to ensure atomicity, and since ...
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:28:01.882Z
Learning: The `addField` function in fdm-core should use database transactions to ensure atomicity, and since transactions provide ACID guarantees, awaiting the inserts is sufficient to ensure field availability - no additional verification queries are needed.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of mapbox gl resources is not nec...
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in `fdm-data/src/cultivations/index.test.ts`, the `fdm` object created by `drizzle` does not have an...
Learnt from: SvenVw
PR: SvenVw/fdm#9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In `fdm-data/src/cultivations/index.test.ts`, the `fdm` object created by `drizzle` does not have an `.end()` method. Cleanup code should not attempt to call `fdm.end();`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the atlas component's mapfieldsprops interface, mapstyle is intentionally restricted to "mapbox:/...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the errorboundary component of fdm-app/app/root.tsx, all client errors (400, 401, 403, 404) are i...
Learnt from: SvenVw
PR: SvenVw/fdm#84
File: fdm-app/app/root.tsx:89-145
Timestamp: 2025-02-24T10:49:54.523Z
Learning: In the ErrorBoundary component of fdm-app/app/root.tsx, all client errors (400, 401, 403, 404) are intentionally displayed with a 404 status code for security purposes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in the `fdm-app` project, svenvw is preparing for migration to remix v3 and may include type declara...
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/vite.config.ts:5-9
Timestamp: 2024-11-25T12:42:32.783Z
Learning: In the `fdm-app` project, SvenVw is preparing for migration to Remix v3 and may include type declarations or configurations for v3 features in advance, such as in `vite.config.ts`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: the harvestform component in fdm-app expects undefined (not 0) for b_lu_yield when no yield informat...
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: when handling different map event types in react-map-gl v7.1.8, use maplayermouseevent for mouse eve...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: in react-map-gl components, when querying rendered features via map.queryrenderedfeatures(), the eff...
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: functions in the fdm-calculator with "nl2025" in their names are specifically designed for netherlan...
Learnt from: SvenVw
PR: SvenVw/fdm#156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🔇 Additional comments (8)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (8)

5-8: LGTM! Proper import additions for new functionality.

The imports for getCultivations, getFields, and the new popup component are correctly added to support the enhanced field display functionality.

Also applies to: 58-58


9-14: LGTM! GeoJSON type imports for field feature handling.

The GeoJSON type imports are properly added to support the feature collection structure for stored fields.


195-204: LGTM! Clean state management for field popup interaction.

The state variables and click handler for the field details popup are properly implemented with clear naming and appropriate typing.


209-211: LGTM! Consistent naming pattern for saved fields layer.

The saved fields layer follows the same naming convention as other field layers in the component.


265-277: LGTM! Robust click event handling for saved fields.

The click handler properly:

  • Checks for the existence of features
  • Filters for the correct source and geometry type
  • Safely casts the feature type
  • Handles the field selection appropriately

315-320: LGTM! Proper integration of non-clickable fields source.

The FieldsSourceNotClickable component is correctly configured with the saved fields data and styling.


348-355: LGTM! Conditional rendering of field details popup.

The popup is correctly conditionally rendered based on field selection state with appropriate props passed including the helpful hint text.


298-298: LGTM! Comprehensive integration of saved fields exclusion.

The saved fields are properly:

  • Excluded from available field selection
  • Excluded from selected field interactions
  • Included in hover layer exclusions
  • Passed to the fields panel for navigation

This ensures a clean separation between existing and new fields while maintaining proper user interaction.

Also applies to: 310-310, 325-325, 333-336

@BoraIneviNMI BoraIneviNMI self-assigned this Aug 7, 2025
@coderabbitai coderabbitai Bot added the fdm-core label Aug 8, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (4)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (4)

33-41: Fix event handling: guard evt.point and stop attaching non-mouse events to a mouse-event handler

updatePanel unconditionally reads evt.point but is also bound to "zoom" and "load" events which don’t provide a point → runtime errors. Bind mouse events only, and clean up all listeners (including "click").

Apply these diffs:

For the handler signature:

-        function updatePanel(evt: MapMouseEvent | MapBoxZoomEvent) {
+        function updatePanel(evt: MapLayerMouseEvent) {

For event registration and cleanup:

-        if (map) {
-            map.on("mousemove", throttledUpdatePanel)
-            map.on("click", updatePanel)
-            map.on("zoom", throttledUpdatePanel)
-            map.on("load", updatePanel)
-            return () => {
-                map.off("mousemove", throttledUpdatePanel)
-                map.off("zoom", throttledUpdatePanel)
-            }
-        }
+        if (map) {
+            map.on("mousemove", throttledUpdatePanel)
+            map.on("click", updatePanel)
+            return () => {
+                map.off("mousemove", throttledUpdatePanel)
+                map.off("click", updatePanel)
+            }
+        }

Also update the import to match the correct mouse-event type (see separate comment).

Also applies to: 91-96, 97-101


183-188: Don’t throw react-router data() from component code; handle errors locally

data() is for loaders/actions in React Router v7. Throwing it inside a component callback won’t behave as intended and can break error handling. Show UI feedback (toast/alert) and return.

-                throw data({
-                    status: 500,
-                    statusText: `Failed to submit fields: ${error}`,
-                })
-                // TODO: adding a toast notification with error
+                // TODO: surface a user-visible error (toast/alert). Avoid throwing here.
+                return

318-318: Effect deps missing: panel won’t update when saved fields arrive

FieldsPanelSelection’s effect renders the “Doorgaan” state when no selection exists. If numFieldsSaved or continueTo change (e.g., after fetch) while fields remains empty, the panel won’t refresh. Include both props in deps.

-    }, [fields, isSubmitting, map, submitSelectedFields])
+    }, [fields, isSubmitting, map, submitSelectedFields, numFieldsSaved, continueTo])

65-76: Include cultivation name in saved-field popup

In fdm-app/app/components/blocks/atlas/atlas-panels.tsx, update the CardDescription for saved fields to append the land-use name (b_lu_name) when it’s available:

• File: fdm-app/app/components/blocks/atlas/atlas-panels.tsx
• Location: around lines 65–76

-<CardDescription>
-  {layer === "fieldsSaved"
-      ? `${features[0].properties.b_area} ha`
-      : layer === "fieldsAvailable"
-        ? "Klik om te selecteren"
-        : "Klik om te verwijderen"}
-</CardDescription>
+<CardDescription>
+  {layer === "fieldsSaved"
+      ? `${features[0].properties.b_area} ha${
+            features[0].properties.b_lu_name
+              ? ` • ${features[0].properties.b_lu_name}`
+              : ""
+        }`
+      : layer === "fieldsAvailable"
+        ? "Klik om te selecteren"
+        : "Klik om te verwijderen"}
+</CardDescription>

This ensures saved-field popups show both area and cultivation name (b_lu_name).

♻️ Duplicate comments (1)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (1)

299-310: Addresses prior feedback: disables action when no saved/selected fields

This resolves the earlier issue where users could proceed to a broken /fields page. Good guard.

🧹 Nitpick comments (1)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (1)

301-304: Nit: use ArrowRight for “Doorgaan” to communicate forward navigation

You already import ArrowRight; it better matches the intent than Check.

-                                        <Button className="w-full">
-                                            <Check />
+                                        <Button className="w-full">
+                                            <ArrowRight className="h-4 w-4" />
                                             <span>Doorgaan</span>
                                         </Button>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5208dc6 and 60fc048.

📒 Files selected for processing (2)
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx (6 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (12 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-05-09T14:58:10.465Z
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:58:10.465Z
Learning: When updating React components that use both react-hook-form and React Router v7, it's important to only import types (like UseFormReturn, FieldValues) from react-hook-form to avoid naming conflicts with React Router's Form component. Use `import type { ... } from 'react-hook-form'` syntax to ensure only types are imported.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-06-10T13:10:03.154Z
Learnt from: SvenVw
PR: SvenVw/fdm#161
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2025-06-10T13:10:03.154Z
Learning: When facing prop name inconsistencies with react-map-gl (like mapboxAccessToken vs mapboxApiAccessToken), using different import statements can resolve the issue more elegantly than changing prop names across multiple files.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T14:29:37.599Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2024-11-25T14:42:26.660Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T15:06:35.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T15:41:43.741Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-04-18T13:49:17.029Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-app/app/components/custom/farm/farm-title.tsx:3-3
Timestamp: 2025-04-18T13:49:17.029Z
Learning: In the fdm project, NavLink and other routing components can be imported from either "react-router" or "react-router-dom" as react-router-dom is included in react-router.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core has optional parameters after `fdm` and `b_id`. The TypeScript definitions might show 8 required parameters due to a potential version mismatch.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-14T16:06:24.294Z
Learnt from: SvenVw
PR: SvenVw/fdm#45
File: fdm-app/app/routes/farm.$b_id_farm._index.tsx:1-1
Timestamp: 2025-01-14T16:06:24.294Z
Learning: In the fdm-app codebase, the `redirect` function should be imported from `react-router`, not `react-router-dom`.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T16:06:33.810Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:164-212
Timestamp: 2025-01-31T16:06:33.810Z
Learning: Map configuration in the application should be modularized using the `useMapConfig` hook and `MapControls` component to maintain consistency across all MapGL instances.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2024-12-16T10:56:07.561Z
Learnt from: SvenVw
PR: SvenVw/fdm#16
File: fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_catalogue.fertilizers.tsx:1-1
Timestamp: 2024-12-16T10:56:07.561Z
Learning: The project uses `react-router` v7, and the `data` function is exported and used for error handling in loaders and actions.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T16:06:33.810Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:164-212
Timestamp: 2025-01-31T16:06:33.810Z
Learning: MapGL implementations should use the shared `useMapConfig` hook for configuration and `getLayerStyle` utility for consistent styling. The hook supports both interactive and non-interactive maps, handling bounds calculation and view state management.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-05-09T14:53:44.578Z
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:53:44.578Z
Learning: In the context of this React Router v7 project, it's important to follow the pattern of importing only the types (like UseFormReturn) from "react-hook-form" while importing the Form component from "react-router" to avoid naming conflicts.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-04-29T11:28:44.181Z
Learnt from: SvenVw
PR: SvenVw/fdm#132
File: fdm-app/app/routes/farm.create.$b_id_farm.$calendar.access.tsx:54-68
Timestamp: 2025-04-29T11:28:44.181Z
Learning: In React Router v7, the `json()` function has been deprecated and removed. Instead, either return plain JavaScript objects directly from loaders/actions, or use the `data()` function for responses with custom status codes and headers.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
🧬 Code Graph Analysis (1)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (1)
fdm-core/src/db/schema.ts (1)
  • fields (87-103)
🔇 Additional comments (2)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (2)

46-49: Good: normalized exclusion layers to array

Handling both string and string[] here removes branching downstream and avoids subtle bugs.


170-171: Good: early return avoids no-op POST

Skipping submission when nothing is selected prevents unnecessary network round-trips.

import { Check, Info } from "lucide-react"
import { ArrowRight, Check, Info } from "lucide-react"
import { useCallback, useEffect, useState } from "react"
import type { MapBoxZoomEvent, MapMouseEvent } from "react-map-gl/mapbox"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use the correct react-map-gl event type per project convention

Per team learning, prefer MapLayerMouseEvent for mouse handlers.

-import type { MapBoxZoomEvent, MapMouseEvent } from "react-map-gl/mapbox"
+import type { MapLayerMouseEvent } from "react-map-gl/mapbox"

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In fdm-app/app/components/blocks/atlas/atlas-panels.tsx at line 5, replace the
imported event types MapBoxZoomEvent and MapMouseEvent from
"react-map-gl/mapbox" with the MapLayerMouseEvent type as per the project
convention for mouse event handlers. Update the import statement to import
MapLayerMouseEvent instead and adjust any related type annotations accordingly.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (1)

91-100: Event listeners leak on every render

click and load handlers are registered but never removed. Re-mounts (e.g., hot reloads, route re-entries) will accumulate handlers, causing duplicate callbacks and memory growth.

 map.on("mousemove", throttledUpdatePanel)
 map.on("click", updatePanel)
 map.on("zoom", throttledUpdatePanel)
 map.on("load", updatePanel)
 return () => {
     map.off("mousemove", throttledUpdatePanel)
+    map.off("click", updatePanel)
+    map.off("load", updatePanel)
     map.off("zoom", throttledUpdatePanel)
 }
🧹 Nitpick comments (3)
fdm-app/app/components/blocks/atlas/atlas-panels.tsx (2)

3-3: Remove unused import to keep bundle lean

ArrowRight is imported but never referenced. Drop it to avoid dead code and keep tree-shaking effective.

-import { ArrowRight, Check, Info } from "lucide-react"
+import { Check, Info } from "lucide-react"

318-318: Include all reactive props in the effect dependencies

numFieldsSaved and continueTo are read inside updatePanel but missing from the dependency array; if either changes the panel won’t refresh. Add them for correctness.

-}, [fields, isSubmitting, map, submitSelectedFields])
+}, [fields, isSubmitting, map, submitSelectedFields, numFieldsSaved, continueTo])
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

392-406: Handle failure of getFields once, reuse result

getFields is called here in the action after already being fetched in the loader. Consider passing the length through the form (hidden input) or caching it server-side to avoid a second DB round-trip and the extra try/catch.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5208dc6 and 60fc048.

📒 Files selected for processing (2)
  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx (6 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (12 hunks)
🧰 Additional context used
🧠 Learnings (36)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-05-09T14:58:10.465Z
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:58:10.465Z
Learning: When updating React components that use both react-hook-form and React Router v7, it's important to only import types (like UseFormReturn, FieldValues) from react-hook-form to avoid naming conflicts with React Router's Form component. Use `import type { ... } from 'react-hook-form'` syntax to ensure only types are imported.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-06-10T13:10:03.154Z
Learnt from: SvenVw
PR: SvenVw/fdm#161
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2025-06-10T13:10:03.154Z
Learning: When facing prop name inconsistencies with react-map-gl (like mapboxAccessToken vs mapboxApiAccessToken), using different import statements can resolve the issue more elegantly than changing prop names across multiple files.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2024-11-25T14:42:26.660Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T14:29:37.599Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:06:35.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:41:43.741Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T13:49:17.029Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-app/app/components/custom/farm/farm-title.tsx:3-3
Timestamp: 2025-04-18T13:49:17.029Z
Learning: In the fdm project, NavLink and other routing components can be imported from either "react-router" or "react-router-dom" as react-router-dom is included in react-router.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core has optional parameters after `fdm` and `b_id`. The TypeScript definitions might show 8 required parameters due to a potential version mismatch.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-14T16:06:24.294Z
Learnt from: SvenVw
PR: SvenVw/fdm#45
File: fdm-app/app/routes/farm.$b_id_farm._index.tsx:1-1
Timestamp: 2025-01-14T16:06:24.294Z
Learning: In the fdm-app codebase, the `redirect` function should be imported from `react-router`, not `react-router-dom`.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T16:06:33.810Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:164-212
Timestamp: 2025-01-31T16:06:33.810Z
Learning: Map configuration in the application should be modularized using the `useMapConfig` hook and `MapControls` component to maintain consistency across all MapGL instances.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2024-12-16T10:56:07.561Z
Learnt from: SvenVw
PR: SvenVw/fdm#16
File: fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_catalogue.fertilizers.tsx:1-1
Timestamp: 2024-12-16T10:56:07.561Z
Learning: The project uses `react-router` v7, and the `data` function is exported and used for error handling in loaders and actions.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-31T16:06:33.810Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:164-212
Timestamp: 2025-01-31T16:06:33.810Z
Learning: MapGL implementations should use the shared `useMapConfig` hook for configuration and `getLayerStyle` utility for consistent styling. The hook supports both interactive and non-interactive maps, handling bounds calculation and view state management.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-05-09T14:53:44.578Z
Learnt from: SvenVw
PR: SvenVw/fdm#138
File: fdm-app/app/components/custom/combobox.tsx:34-37
Timestamp: 2025-05-09T14:53:44.578Z
Learning: In the context of this React Router v7 project, it's important to follow the pattern of importing only the types (like UseFormReturn) from "react-hook-form" while importing the Form component from "react-router" to avoid naming conflicts.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-04-29T11:28:44.181Z
Learnt from: SvenVw
PR: SvenVw/fdm#132
File: fdm-app/app/routes/farm.create.$b_id_farm.$calendar.access.tsx:54-68
Timestamp: 2025-04-29T11:28:44.181Z
Learning: In React Router v7, the `json()` function has been deprecated and removed. Instead, either return plain JavaScript objects directly from loaders/actions, or use the `data()` function for responses with custom status codes and headers.

Applied to files:

  • fdm-app/app/components/blocks/atlas/atlas-panels.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The `FarmLayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structure for farm-related pages, with support for farm selection dropdown, customizable breadcrumb titles, and flexible content rendering through either children or Outlet components.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-04T14:27:39.518Z
Learnt from: SvenVw
PR: SvenVw/fdm#116
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx:111-154
Timestamp: 2025-04-04T14:27:39.518Z
Learning: In the FDM application, cultivation retrieval logic should be centralized in utility functions rather than duplicated across loader and action functions to improve maintainability and ensure consistent behavior.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-06-02T10:31:27.097Z
Learnt from: SvenVw
PR: SvenVw/fdm#151
File: fdm-app/app/routes/signin._index.tsx:101-101
Timestamp: 2025-06-02T10:31:27.097Z
Learning: In fdm-app/app/routes/signin._index.tsx, the redirect destinations are intentionally inconsistent by design: the component defaults new sign-ins to "/welcome" (line 101) while the loader redirects authenticated users to "/farm" (line 80) and the action uses "/farm" as fallback (line 434). This creates appropriate user flows where new users complete their profile via the welcome page, while existing authenticated users bypass it and go directly to the main application.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T09:03:11.890Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:34:20.850Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:34:20.850Z
Learning: The `updateField` function in fdm-core has optional parameters that don't need to be passed as undefined. Only `fdm` and `b_id` are required.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.027Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.027Z
Learning: The `addField` function in fdm-core should verify field creation within the same transaction by checking the existence of the field and all its required relations (field data, acquiring info, geometry) before resolving its promise.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-12-19T13:20:44.152Z
Learnt from: SvenVw
PR: SvenVw/fdm#23
File: fdm-app/app/routes/app.addfarm.new.tsx:15-17
Timestamp: 2024-12-19T13:20:44.152Z
Learning: Authentication for the “app.addfarm.new” route is already handled globally in “fdm-app/app/routes/app.tsx,” automatically redirecting unauthenticated users to the SignIn page.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.028Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.028Z
Learning: The `addField` function in fdm-core should use database transactions and field verification to ensure field availability before resolving its promise, eliminating the need for sleep workarounds.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needs to include user ID and email fields to support role updates and user removal operations, which will be fixed in a future commit (b17fac16c9e5a0de56d0346e712b2ce966d305d5).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires 8 parameters: fdm, b_id (required), and 6 optional parameters (b_name, b_id_source, b_geometry, b_acquiring_date, b_acquiring_method, b_discarding_date).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts currently returns only firstname, surname, image, and role, but needs to include id and email fields to support downstream operations like role updates and user removal. This will be fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needed to include id and email fields for users, which was fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-24T11:28:01.882Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:28:01.882Z
Learning: The `addField` function in fdm-core should use database transactions to ensure atomicity, and since transactions provide ACID guarantees, awaiting the inserts is sufficient to ensure field availability - no additional verification queries are needed.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-27T12:15:36.425Z
Learnt from: SvenVw
PR: SvenVw/fdm#9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In `fdm-data/src/cultivations/index.test.ts`, the `fdm` object created by `drizzle` does not have an `.end()` method. Cleanup code should not attempt to call `fdm.end();`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-24T10:49:54.523Z
Learnt from: SvenVw
PR: SvenVw/fdm#84
File: fdm-app/app/root.tsx:89-145
Timestamp: 2025-02-24T10:49:54.523Z
Learning: In the ErrorBoundary component of fdm-app/app/root.tsx, all client errors (400, 401, 403, 404) are intentionally displayed with a 404 status code for security purposes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-25T12:42:32.783Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/vite.config.ts:5-9
Timestamp: 2024-11-25T12:42:32.783Z
Learning: In the `fdm-app` project, SvenVw is preparing for migration to Remix v3 and may include type declarations or configurations for v3 features in advance, such as in `vite.config.ts`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T08:35:59.306Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-07-21T12:06:07.070Z
Learnt from: SvenVw
PR: SvenVw/fdm#156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🔇 Additional comments (1)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

260-266: Clarify intent for saved-field interactivity

fieldsSavedId is included in interactiveLayerIds, making saved fields clickable even though they are marketed “not selectable”. This is fine for the info-popup, but please double-check that downstream logic (e.g., selection tools) ignores this layer to avoid accidental edits.

Comment on lines +300 to +305
<NavLink to={continueTo} className="flex-1">
<Button className="w-full">
<Check />
<span>Doorgaan</span>
</Button>
</NavLink>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid nested interactive elements

Wrapping a <button> inside a <NavLink> (anchor) violates HTML a11y rules and confuses screen-readers. Render a single interactive element instead, e.g.:

-<NavLink to={continueTo} className="flex-1">
-    <Button className="w-full">
-        <Check />
-        <span>Doorgaan</span>
-    </Button>
-</NavLink>
+<Button asChild className="w-full">
+    <NavLink to={continueTo} className="flex items-center gap-2">
+        <Check />
+        <span>Doorgaan</span>
+    </NavLink>
+</Button>

Also applies to: 307-310

🤖 Prompt for AI Agents
In fdm-app/app/components/blocks/atlas/atlas-panels.tsx around lines 300 to 310,
avoid nesting a <button> inside a <NavLink> as it violates accessibility rules.
Instead, render a single interactive element by either making the <NavLink>
styled as a button or using the <Button> component with navigation logic inside
it. Refactor both instances (lines 300-305 and 307-310) to remove nested
interactive elements and ensure only one clickable element is present.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

299-306: Exclude saved features by geometry, not just ID

The exclude prop in FieldsSourceAvailable is currently only used to build an ID‐based filter (unwantedIds = new Set(exclude.map(f ⇒ f.properties.b_id_source))). There’s no geometric check to remove available features that fall entirely within saved polygons. To fully satisfy the “prevent fully covered selection” requirement, you’ll need to augment this logic:

• In app/components/blocks/atlas/atlas-sources.tsx, around the unwantedIds setup (lines ~141–143), also compute a spatial index or use a geometry library (e.g. turf.js) to test each candidate feature against the saved feature geometries.
• In the loop (lines ~189–208), skip features where feature.geometry is completely contained by any polygon in exclude.

Without this, users could still select fields that are geometrically fully covered (but have different IDs). Please implement geometry‐based filtering here or let me know if you’d prefer a different approach.

♻️ Duplicate comments (1)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

396-410: Sequential naming index uses timeframe-aware field count

Good fix; this addresses the earlier review about missing timeframe on getFields. Thanks for adding a fallback.

🧹 Nitpick comments (3)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (3)

5-8: Imports: aligned with new functionality

Good additions for cultivations, fields, GeoJSON types, and the not-clickable source. Consider using the ~ alias for FieldDetailsInfoPopup for consistency with other imports.

-import FieldDetailsInfoPopup from "../components/blocks/field/popup"
+import FieldDetailsInfoPopup from "~/components/blocks/field/popup"

Also applies to: 9-14, 41-41, 58-58


75-80: Fix JSDoc tags and link markup

Use standard JSDoc tags and link syntax.

- * This loader function ... transformed using {~link handleLoaderError}.
- *
- * ~throws {Response} ...
- *
- * ~returns An object containing ...
+ * This loader function ... transformed using {@link handleLoaderError}.
+ *
+ * @throws {Response} ...
+ *
+ * @returns An object containing ...

104-158: Saved fields loader: correct but watch N+1 cultivations; consider centralizing

Fetching cultivations per field can lead to N+1 queries. If possible, batch-fetch cultivations for the farm/timeframe or move the “derive cultivation display name” into a shared utility, per previous learning to centralize cultivation retrieval logic.

  • Benefit: fewer DB calls, shared behavior across routes.
  • If batching is not available, keep current approach but cache in-memory per field id during the loop.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 827ee17 and e40bc3f.

📒 Files selected for processing (2)
  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx (1 hunks)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (12 hunks)
🧰 Additional context used
🧠 Learnings (29)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:38:05.693Z
Learning: The field creation and cultivation addition should be performed within a single database transaction to ensure atomicity and prevent transaction isolation issues that could lead to "Field does not exist" errors.
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core has optional parameters after `fdm` and `b_id`. The TypeScript definitions might show 8 required parameters due to a potential version mismatch.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The `FarmLayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structure for farm-related pages, with support for farm selection dropdown, customizable breadcrumb titles, and flexible content rendering through either children or Outlet components.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:34:20.850Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:34:20.850Z
Learning: The `updateField` function in fdm-core has optional parameters that don't need to be passed as undefined. Only `fdm` and `b_id` are required.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-25T14:42:26.660Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-12-19T13:20:44.152Z
Learnt from: SvenVw
PR: SvenVw/fdm#23
File: fdm-app/app/routes/app.addfarm.new.tsx:15-17
Timestamp: 2024-12-19T13:20:44.152Z
Learning: Authentication for the “app.addfarm.new” route is already handled globally in “fdm-app/app/routes/app.tsx,” automatically redirecting unauthenticated users to the SignIn page.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-12-11T12:09:35.540Z
Learnt from: SvenVw
PR: SvenVw/fdm#20
File: fdm-app/tsconfig.json:8-9
Timestamp: 2024-12-11T12:09:35.540Z
Learning: In the `fdm-app/tsconfig.json` file, the include path `.react-router/types/**/*` refers to a build-time generated directory which is intentionally not included in the repository.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires 8 parameters: fdm, b_id (required), and 6 optional parameters (b_name, b_id_source, b_geometry, b_acquiring_date, b_acquiring_method, b_discarding_date).

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T14:29:37.599Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-04T14:27:39.518Z
Learnt from: SvenVw
PR: SvenVw/fdm#116
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx:111-154
Timestamp: 2025-04-04T14:27:39.518Z
Learning: In the FDM application, cultivation retrieval logic should be centralized in utility functions rather than duplicated across loader and action functions to improve maintainability and ensure consistent behavior.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-06-02T10:31:27.097Z
Learnt from: SvenVw
PR: SvenVw/fdm#151
File: fdm-app/app/routes/signin._index.tsx:101-101
Timestamp: 2025-06-02T10:31:27.097Z
Learning: In fdm-app/app/routes/signin._index.tsx, the redirect destinations are intentionally inconsistent by design: the component defaults new sign-ins to "/welcome" (line 101) while the loader redirects authenticated users to "/farm" (line 80) and the action uses "/farm" as fallback (line 434). This creates appropriate user flows where new users complete their profile via the welcome page, while existing authenticated users bypass it and go directly to the main application.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T09:03:11.890Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.027Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.027Z
Learning: The `addField` function in fdm-core should verify field creation within the same transaction by checking the existence of the field and all its required relations (field data, acquiring info, geometry) before resolving its promise.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.028Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.028Z
Learning: The `addField` function in fdm-core should use database transactions and field verification to ensure field availability before resolving its promise, eliminating the need for sleep workarounds.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needs to include user ID and email fields to support role updates and user removal operations, which will be fixed in a future commit (b17fac16c9e5a0de56d0346e712b2ce966d305d5).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts currently returns only firstname, surname, image, and role, but needs to include id and email fields to support downstream operations like role updates and user removal. This will be fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needed to include id and email fields for users, which was fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-24T11:28:01.882Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:28:01.882Z
Learning: The `addField` function in fdm-core should use database transactions to ensure atomicity, and since transactions provide ACID guarantees, awaiting the inserts is sufficient to ensure field availability - no additional verification queries are needed.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-27T12:15:36.425Z
Learnt from: SvenVw
PR: SvenVw/fdm#9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In `fdm-data/src/cultivations/index.test.ts`, the `fdm` object created by `drizzle` does not have an `.end()` method. Cleanup code should not attempt to call `fdm.end();`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-24T10:49:54.523Z
Learnt from: SvenVw
PR: SvenVw/fdm#84
File: fdm-app/app/root.tsx:89-145
Timestamp: 2025-02-24T10:49:54.523Z
Learning: In the ErrorBoundary component of fdm-app/app/root.tsx, all client errors (400, 401, 403, 404) are intentionally displayed with a 404 status code for security purposes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-25T12:42:32.783Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/vite.config.ts:5-9
Timestamp: 2024-11-25T12:42:32.783Z
Learning: In the `fdm-app` project, SvenVw is preparing for migration to Remix v3 and may include type declarations or configurations for v3 features in advance, such as in `vite.config.ts`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T08:35:59.306Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:41:43.741Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:06:35.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-07-21T12:06:07.070Z
Learnt from: SvenVw
PR: SvenVw/fdm#156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires exactly 8 arguments and does not support an object-based parameter approach.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🔇 Additional comments (10)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (10)

185-195: Map initial view state updated to fit saved fields

LGTM; using saved fields to compute initial view improves UX.


196-205: Popup state for saved fields

LGTM; minimal and clear state handling.


313-314: Selection source excludes saved layer

LGTM; prevents selecting polygons that overlap the saved source.


318-325: Non-clickable saved source with outline

LGTM; good visual distinction. Name suggests non-clickable, but clicks are handled at Map level; current setup is fine.


329-334: Conditional continue wiring

LGTM; providing numFieldsSaved and continueTo enables the desired conditional flow.


341-344: Hover exclusion for saved and selected layers

LGTM; avoids confusing hovers over excluded layers.


356-363: Saved field info popup

LGTM; concise UX. Dutch hint aligns with other labels.


428-428: Sequential field naming

LGTM; Perceel ${firstFieldIndex + index} yields stable, non-colliding names.


463-466: Incorrect issue: getSoilParameterEstimates accepts both Feature and Polygon
The function signature in app/integrations/nmi.ts is:

export async function getSoilParameterEstimates(
  field: Feature | Polygon,
  nmiApiKey: string | undefined,
): Promise<>

Since it explicitly allows a Feature, passing field (a GeoJSON Feature) is valid. No change is needed here.

Likely an incorrect or invalid review comment.


265-280: interactiveLayerIds correctly use getFieldsStyle layer IDs
interactiveLayerIds is set to the same IDs (fieldsAvailable, fieldsSelected, fieldsSaved) that getFieldsStyle assigns as layer .id, so feature picking will work as expected.

id={fieldsAvailableId}
calendar={loaderData.calendar}
zoomLevelFields={ZOOM_LEVEL_FIELDS}
exclude={fieldsSaved.features}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm exclusion semantics to prevent covered selections

Passing exclude={fieldsSaved.features} looks correct and aligns with the PR goals. Please confirm the exclusion logic in FieldsSourceAvailable uses geometric coverage/intersection (not just ID equality) so fields fully covered by saved ones are truly excluded.

Run to inspect how exclude is implemented:


🏁 Script executed:

#!/bin/bash
# Locate and inspect the atlas sources implementation for exclude handling
fd atlas-sources.tsx
rg -n "FieldsSourceAvailable|exclude" -A 60 $(fd -a atlas-sources.tsx)

Length of output: 5940


FieldsSourceAvailable’s exclude filter only checks IDs, not geometry
Currently, exclude is reduced to a Set of b_id_source (lines 139–143) and used in loadData (around lines 190–194) to drop any feature whose ID matches. This means fields that are geometrically covered by a saved field—but have a different ID—will still appear.

To fully exclude fields covered/intersected by saved ones, we need to replace or augment that ID check with a spatial test (for example using Turf.js’s booleanContains/booleanOverlap or intersect) against the geometries in exclude.

• Location: fdm-app/app/components/blocks/atlas/atlas-sources.tsx
– Replace the filter
ts if (!unwantedIds.has(feature.properties!.b_id_source)) { … }
with something like
ts // skip if any excluded feature fully contains or intersects this feature if ( !exclude.some(excluded => turf.booleanContains(excluded.geometry, feature.geometry) || turf.booleanOverlap(excluded.geometry, feature.geometry) ) ) { … }

Please update the exclusion logic so it tests geometric coverage/intersection, not just ID equality.

🤖 Prompt for AI Agents
In fdm-app/app/components/blocks/atlas/atlas-sources.tsx around lines 139 to
194, the current exclusion logic only filters out features by matching their IDs
against a Set of excluded IDs, which misses features that overlap or are
contained geometrically but have different IDs. To fix this, replace the
ID-based filter with a spatial test using Turf.js functions like booleanContains
and booleanOverlap to check if any excluded feature's geometry contains or
overlaps the current feature's geometry, and exclude those features accordingly.

Comment thread fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

427-459: Possible undefined b_lu_catalogue

b_lu_catalogue comes from field.properties; for available GeoJSON this key isn’t guaranteed. If it is undefined, addCultivation will throw and the whole Promise.all rejects. Guard or default before calling:

- const b_lu_catalogue = field.properties.b_lu_catalogue
+ const b_lu_catalogue = field.properties.b_lu_catalogue ?? DEFAULT_LU
+ if (!b_lu_catalogue) throw new Error("missing: b_lu_catalogue")
🧹 Nitpick comments (4)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (4)

115-152: Avoid N + 1 getCultivations calls

getCultivations is executed once per field. With dozens of fields this becomes a round-trip loop and slows the loader. Prefer a single batched query (e.g. getCultivationsForFields(fdm, principalId, b_ids, timeframe)) or extend getFields to include the first cultivation name.


195-205: Redundant open state

open duplicates the truthiness of selectedField; a single selectedField (null / feature) suffices. Dropping open simplifies the popup logic.


209-214: Name contradicts behaviour

Layer fieldsSaved is rendered via FieldsSourceNotClickable, yet it is included in interactiveLayerIds, enabling clicks (needed for the popup). The helper’s name now misleads—consider renaming to FieldsSourceSaved or documenting that click-through is intentional.

Also applies to: 317-323


395-409: Race-condition on sequential field naming

firstFieldIndex is determined before the parallel Promise.all. Concurrent submissions (e.g. two browser tabs) can pick the same starting index, producing duplicate Perceel N names. Consider obtaining the next index inside the DB transaction or suffix with a timestamp/UUID.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c398fff and 0682007.

📒 Files selected for processing (1)
  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (12 hunks)
🧰 Additional context used
🧠 Learnings (30)
📓 Common learnings
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:38:05.693Z
Learning: The field creation and cultivation addition should be performed within a single database transaction to ensure atomicity and prevent transaction isolation issues that could lead to "Field does not exist" errors.
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A shared layout component `FarmLayoutBase` has been created in `components/custom/farm-layout-base.tsx` to maintain consistency across farm-related pages. The component handles farm selection dropdown, breadcrumb navigation, and provides a common layout structure.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The `FarmLayout` component in `components/custom/farm-layout.tsx` provides a reusable layout structure for farm-related pages, with support for farm selection dropdown, customizable breadcrumb titles, and flexible content rendering through either children or Outlet components.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-04T14:27:39.518Z
Learnt from: SvenVw
PR: SvenVw/fdm#116
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.new.tsx:111-154
Timestamp: 2025-04-04T14:27:39.518Z
Learning: In the FDM application, cultivation retrieval logic should be centralized in utility functions rather than duplicated across loader and action functions to improve maintainability and ensure consistent behavior.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core has optional parameters after `fdm` and `b_id`. The TypeScript definitions might show 8 required parameters due to a potential version mismatch.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: A comprehensive farm layout system has been created in `components/custom/farm-layouts/` with `BaseFarmLayout` and `FarmSidebarLayout` components. The system supports both simple and sidebar-based layouts while maintaining consistent header and farm selection functionality across all farm routes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-06-02T10:31:27.097Z
Learnt from: SvenVw
PR: SvenVw/fdm#151
File: fdm-app/app/routes/signin._index.tsx:101-101
Timestamp: 2025-06-02T10:31:27.097Z
Learning: In fdm-app/app/routes/signin._index.tsx, the redirect destinations are intentionally inconsistent by design: the component defaults new sign-ins to "/welcome" (line 101) while the loader redirects authenticated users to "/farm" (line 80) and the action uses "/farm" as fallback (line 434). This creates appropriate user flows where new users complete their profile via the welcome page, while existing authenticated users bypass it and go directly to the main application.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T09:03:11.890Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.create.$b_id_farm.cultivations.$b_lu_catalogue.crop.harvest._index.tsx:111-135
Timestamp: 2025-02-13T09:03:11.890Z
Learning: When adding multiple harvests in fdm-app, use Promise.all instead of Promise.allSettled to ensure atomic behavior - if one harvest addition fails, all should fail and rollback to maintain data consistency.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:34:20.850Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:34:20.850Z
Learning: The `updateField` function in fdm-core has optional parameters that don't need to be passed as undefined. Only `fdm` and `b_id` are required.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.027Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.027Z
Learning: The `addField` function in fdm-core should verify field creation within the same transaction by checking the existence of the field and all its required relations (field data, acquiring info, geometry) before resolving its promise.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#42
File: fdm-app/app/routes/farm/_b_id_farm/layout.tsx:46-95
Timestamp: 2025-01-09T16:03:37.764Z
Learning: The farm layout system has been reorganized into separate components (`FarmHeader`, `ContentLayout`, `PaginationLayout`) to support different navigation patterns (sidebar, pagination) while maintaining consistent styling. Each layout component is designed to be used independently or combined as needed.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-23T15:17:23.028Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-23T15:17:23.028Z
Learning: The `addField` function in fdm-core should use database transactions and field verification to ensure field availability before resolving its promise, eliminating the need for sleep workarounds.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needs to include user ID and email fields to support role updates and user removal operations, which will be fixed in a future commit (b17fac16c9e5a0de56d0346e712b2ce966d305d5).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires 8 parameters: fdm, b_id (required), and 6 optional parameters (b_name, b_id_source, b_geometry, b_acquiring_date, b_acquiring_method, b_discarding_date).

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts currently returns only firstname, surname, image, and role, but needs to include id and email fields to support downstream operations like role updates and user removal. This will be fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-04-18T14:51:48.033Z
Learnt from: SvenVw
PR: SvenVw/fdm#124
File: fdm-core/src/organization.ts:300-339
Timestamp: 2025-04-18T14:51:48.033Z
Learning: The `getUsersInOrganization` function in fdm-core/src/organization.ts needed to include id and email fields for users, which was fixed in commit b17fac16c9e5a0de56d0346e712b2ce966d305d5.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: When using `updateField` from fdm-core, all 8 parameters must be provided in order: fdm, b_id, b_name, b_geometry, b_area, b_id_source, b_id_farm, and b_id_farm_source.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-24T11:28:01.882Z
Learnt from: SvenVw
PR: SvenVw/fdm#49
File: fdm-app/app/routes/farm.create.$b_id_farm.atlas.tsx:208-208
Timestamp: 2025-01-24T11:28:01.882Z
Learning: The `addField` function in fdm-core should use database transactions to ensure atomicity, and since transactions provide ACID guarantees, awaiting the inserts is sufficient to ensure field availability - no additional verification queries are needed.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-13T08:35:59.306Z
Learnt from: SvenVw
PR: SvenVw/fdm#71
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.cultivation.$b_lu.harvest.$b_id_harvesting.tsx:114-124
Timestamp: 2025-02-13T08:35:59.306Z
Learning: The HarvestForm component in fdm-app expects undefined (not 0) for b_lu_yield when no yield information is available, as 0 would incorrectly imply that yield data exists.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-12-16T10:56:07.561Z
Learnt from: SvenVw
PR: SvenVw/fdm#16
File: fdm-app/app/routes/app.addfarm.$b_id_farm.cultivations.$b_lu_catalogue.fertilizers.tsx:1-1
Timestamp: 2024-12-16T10:56:07.561Z
Learning: The project uses `react-router` v7, and the `data` function is exported and used for error handling in loaders and actions.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-25T14:42:26.660Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/app/components/blocks/field-map.tsx:0-0
Timestamp: 2024-11-25T14:42:26.660Z
Learning: In `fdm-app/app/components/blocks/field-map.tsx`, explicit cleanup of Mapbox GL resources is not necessary, as `react-map-gl` handles it automatically upon component unmount, and `MapRef` does not have a `remove` method.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-27T12:15:36.425Z
Learnt from: SvenVw
PR: SvenVw/fdm#9
File: fdm-data/src/cultivations/index.test.ts:57-59
Timestamp: 2024-11-27T12:15:36.425Z
Learning: In `fdm-data/src/cultivations/index.test.ts`, the `fdm` object created by `drizzle` does not have an `.end()` method. Cleanup code should not attempt to call `fdm.end();`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T14:29:37.599Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas.d.tsx:8-8
Timestamp: 2025-01-31T14:29:37.599Z
Learning: In the Atlas component's MapFieldsProps interface, mapStyle is intentionally restricted to "mapbox://styles/mapbox/satellite-streets-v12" as it's currently the only supported style option.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-02-24T10:49:54.523Z
Learnt from: SvenVw
PR: SvenVw/fdm#84
File: fdm-app/app/root.tsx:89-145
Timestamp: 2025-02-24T10:49:54.523Z
Learning: In the ErrorBoundary component of fdm-app/app/root.tsx, all client errors (400, 401, 403, 404) are intentionally displayed with a 404 status code for security purposes.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-11-25T12:42:32.783Z
Learnt from: SvenVw
PR: SvenVw/fdm#6
File: fdm-app/vite.config.ts:5-9
Timestamp: 2024-11-25T12:42:32.783Z
Learning: In the `fdm-app` project, SvenVw is preparing for migration to Remix v3 and may include type declarations or configurations for v3 features in advance, such as in `vite.config.ts`.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2024-12-19T13:20:44.152Z
Learnt from: SvenVw
PR: SvenVw/fdm#23
File: fdm-app/app/routes/app.addfarm.new.tsx:15-17
Timestamp: 2024-12-19T13:20:44.152Z
Learning: Authentication for the “app.addfarm.new” route is already handled globally in “fdm-app/app/routes/app.tsx,” automatically redirecting unauthenticated users to the SignIn page.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:41:43.741Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-panels.tsx:28-28
Timestamp: 2025-01-31T15:41:43.741Z
Learning: When handling different map event types in react-map-gl v7.1.8, use MapLayerMouseEvent for mouse events (which have the point property) and ViewStateChangeEvent for view state changes. Use a type guard like 'point' in evt to safely access event-specific properties.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:06:35.764Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/components/custom/atlas/atlas-sources.tsx:21-66
Timestamp: 2025-01-31T15:06:35.764Z
Learning: In react-map-gl components, when querying rendered features via map.queryRenderedFeatures(), the effect's dependency array must include any props that affect the map's rendered state (like source data) to ensure features are queried against the current map state.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-07-21T12:06:07.070Z
Learnt from: SvenVw
PR: SvenVw/fdm#156
File: fdm-calculator/src/norms/nl/2025/stikstofgebruiksnorm.ts:295-303
Timestamp: 2025-07-21T12:06:07.070Z
Learning: Functions in the fdm-calculator with "NL2025" in their names are specifically designed for Netherlands 2025 agricultural norms calculation and hardcoded 2025 dates are appropriate in this context, as different years would have separate calculation modules.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
PR: SvenVw/fdm#67
File: fdm-app/app/routes/farm.create.$b_id_farm.fields.$b_id.tsx:601-610
Timestamp: 2025-01-31T15:05:14.310Z
Learning: The `updateField` function in fdm-core requires exactly 8 arguments and does not support an object-based parameter approach.

Applied to files:

  • fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
🔇 Additional comments (1)
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)

139-149: Verify geometry type before casting

field.b_geometry is blindly cast to Polygon, but the DB may hold MultiPolygon for merged parcels. If a MultiPolygon slips through, Mapbox won’t render and popup logic may crash.
Either narrow the type with a type-guard or accept Polygon | MultiPolygon.

Copy link
Copy Markdown
Collaborator

@SvenVw SvenVw left a comment

Choose a reason for hiding this comment

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

Thanks! I checked it and it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

branch:development Issue only affecting development, not the main branch (yet) fdm-app fdm-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Atlas: Display stored fields and improve navigation in farm creation

2 participants