Update FDM app to use calendar-based dataset selection and new env variable#226
Conversation
🦋 Changeset detectedLatest commit: 2e2a490 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
WalkthroughThis change updates the FDM app to use a new environment variable ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AtlasView
participant FieldsSourceAvailable
participant getAvailableFieldsUrl
participant Config
User->>AtlasView: Selects calendar year
AtlasView->>FieldsSourceAvailable: Passes calendar year prop
FieldsSourceAvailable->>getAvailableFieldsUrl: Requests URL for year
getAvailableFieldsUrl->>Config: Reads PUBLIC_FDM_DATASETS_URL
getAvailableFieldsUrl-->>FieldsSourceAvailable: Returns constructed dataset URL
FieldsSourceAvailable-->>AtlasView: Loads and displays fields for selected year
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes found. Possibly related PRs
Suggested reviewers
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development #226 +/- ##
============================================
Coverage 93.02% 93.02%
============================================
Files 85 85
Lines 12812 12812
Branches 1293 1293
============================================
Hits 11919 11919
Misses 891 891
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
fdm-app/app/root.tsx (1)
48-54: Validate presence of the new env variable early.
PUBLIC_FDM_DATASETS_URLis now required by many Atlas components, but the loader silently passes throughundefined.
Failing fast (e.g. throwing if the variable is missing in production) prevents hard-to-debug 404s later.const runtimeEnv = { @@ - PUBLIC_FDM_DATASETS_URL: process.env.PUBLIC_FDM_DATASETS_URL, + PUBLIC_FDM_DATASETS_URL: (() => { + if (process.env.PUBLIC_FDM_DATASETS_URL) return process.env.PUBLIC_FDM_DATASETS_URL + if (process.env.NODE_ENV === "development") return undefined + throw new Error("PUBLIC_FDM_DATASETS_URL is not set") + })(),
🧹 Nitpick comments (8)
.changeset/blue-kiwis-dress.md (1)
5-5: Wording nit – use “environment variable” instead of “environmental”.
environmentalsounds like ecology‐related; the conventional phrasing in a changeset headline is “environment variable”.
Example:-Replace environmental FDM_PUBLIC_DATA with PUBLIC_FDM_DATASETS_URL +Replace environment variable FDM_PUBLIC_DATA with PUBLIC_FDM_DATASETS_URL.changeset/silver-oranges-vanish.md (1)
5-5: Minor copy edit – clarify sentence structure.Consider making the note active/imperative for consistency with other change-set messages:
-At Atlas show for the available fields the dataset for the selected calendar year +Atlas: show the available-fields dataset for the selected calendar yearfdm-app/app/root.tsx (1)
70-78: Optional: drop the empty fallback object.When the guarded assignment above is added, the catch-branch becomes redundant and can be removed, simplifying the loader.
fdm-app/app/types/config.d.ts (1)
62-63: Consistency – keep optionality in sync.If
ServerConfig.datasets_urlremains required,ClientConfig.datasets_urlshould also be required (and vice-versa) to avoid accidentalundefinedon the client.fdm-app/app/components/blocks/atlas/atlas-url.ts (3)
7-7: Fix typo in comment.There's a spelling error in the comment.
- // Set year accoriding to available at FDM public datasets + // Set year according to available at FDM public datasets
8-14: Consider input validation and error handling.The
Math.round(Number(calendar))approach will handle non-numeric strings by returning NaN, which then gets clamped to 2020. Consider adding explicit validation for better error handling.- let year = Math.round(Number(calendar)) - if (year < 2020) { - year = 2020 - } - if (year > 2025) { - year = 2025 - } + const parsedYear = parseInt(calendar, 10) + if (isNaN(parsedYear)) { + throw new Error(`Invalid calendar year: ${calendar}`) + } + let year = Math.max(2020, Math.min(2025, parsedYear))
23-23: Consider internationalization for hardcoded country code.The hardcoded "nl" in the URL path may need consideration for future internationalization, though it's acceptable for the current Netherlands-focused implementation.
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (1)
66-70: Update JSDoc comment to reflect current implementation.The JSDoc comment mentions returning "the URL for available fields" but the loader now returns a calendar parameter instead.
- * This loader function extracts the farm ID from route parameters, validates its presence, and uses the current session to fetch the corresponding farm details. It then retrieves the Mapbox token and style configuration, and returns these along with the farm's display name and a URL for available fields. Any errors encountered during processing are transformed using {~link handleLoaderError}. + * This loader function extracts the farm ID and calendar from route parameters, validates their presence, and uses the current session to fetch the corresponding farm details. It then retrieves the Mapbox token and style configuration, and returns these along with the farm's display name and calendar parameter for dynamic field data loading. Any errors encountered during processing are transformed using {~link handleLoaderError}.- * ~returns An object containing the farm name, Mapbox token, Mapbox style, and the URL for available fields. + * ~returns An object containing the farm name, Mapbox token, Mapbox style, and calendar parameter for field data selection.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
fdm-app/app/lib/config.server.tsis excluded by!fdm-app/app/lib/**fdm-app/app/lib/config.tsis excluded by!fdm-app/app/lib/**
📒 Files selected for processing (11)
.changeset/blue-kiwis-dress.md(1 hunks).changeset/silver-oranges-vanish.md(1 hunks)fdm-app/.env.example(1 hunks)fdm-app/app/components/blocks/atlas/atlas-sources.tsx(4 hunks)fdm-app/app/components/blocks/atlas/atlas-url.ts(1 hunks)fdm-app/app/components/blocks/atlas/atlas.d.tsx(0 hunks)fdm-app/app/root.tsx(1 hunks)fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx(2 hunks)fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx(3 hunks)fdm-app/app/types/config.d.ts(2 hunks)fdm-app/app/types/public-env.d.ts(1 hunks)
💤 Files with no reviewable changes (1)
- fdm-app/app/components/blocks/atlas/atlas.d.tsx
🧰 Additional context used
🧠 Learnings (32)
📓 Common learnings
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.
Learnt from: SvenVw
PR: SvenVw/fdm#88
File: fdm-core/src/cultivation.ts:246-246
Timestamp: 2025-03-04T11:09:08.169Z
Learning: In the FDM codebase, the `fdm` parameter should be documented as "The FDM instance providing the connection to the database. The instance can be created with {link createFdmServer}." in JSDoc comments.
📚 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:
.changeset/blue-kiwis-dress.mdfdm-app/app/root.tsxfdm-app/app/types/config.d.tsfdm-app/app/types/public-env.d.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx
📚 Learning: in the fdm codebase, the `fdm` parameter should be documented as "the fdm instance providing the con...
Learnt from: SvenVw
PR: SvenVw/fdm#88
File: fdm-core/src/cultivation.ts:246-246
Timestamp: 2025-03-04T11:09:08.169Z
Learning: In the FDM codebase, the `fdm` parameter should be documented as "The FDM instance providing the connection to the database. The instance can be created with {link createFdmServer}." in JSDoc comments.
Applied to files:
.changeset/blue-kiwis-dress.mdfdm-app/app/root.tsxfdm-app/app/types/config.d.tsfdm-app/.env.example
📚 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:
.changeset/blue-kiwis-dress.md.changeset/silver-oranges-vanish.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-app/.env.examplefdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 Learning: sentry dsn being public in client-side code is not a security concern as per sentry documentation, b...
Learnt from: SvenVw
PR: SvenVw/fdm#82
File: fdm-app/app/entry.client.tsx:13-13
Timestamp: 2025-02-19T10:50:50.200Z
Learning: Sentry DSN being public in client-side code is not a security concern as per Sentry documentation, but it can be made configurable using Vite's environment variables system with the `VITE_` prefix.
Applied to files:
.changeset/blue-kiwis-dress.mdfdm-app/app/root.tsxfdm-app/app/types/public-env.d.ts
📚 Learning: in the fdm project, `redirect` and other routing utilities should be imported from `react-router` in...
Learnt from: SvenVw
PR: SvenVw/fdm#45
File: fdm-app/app/routes/farm.$b_id_farm.settings._index.tsx:1-1
Timestamp: 2025-01-14T16:06:21.832Z
Learning: In the fdm project, `redirect` and other routing utilities should be imported from `react-router` instead of `react-router-dom`.
Applied to files:
.changeset/blue-kiwis-dress.mdfdm-app/app/root.tsx
📚 Learning: in the fdm-app codebase, the `redirect` function should be imported from `react-router`, not `react-...
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:
.changeset/blue-kiwis-dress.mdfdm-app/app/root.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx
📚 Learning: in the `fdm-app/tsconfig.json` file, the include path `.react-router/types/**/*` refers to a build-t...
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/root.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.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:
.changeset/silver-oranges-vanish.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-app/app/components/blocks/atlas/atlas-url.tsfdm-app/.env.examplefdm-app/app/components/blocks/atlas/atlas-sources.tsxfdm-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.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx
📚 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.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-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.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-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.$b_id_farm.$calendar.balance.nitrogen._index.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.$b_id_farm.$calendar.balance.nitrogen._index.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.$b_id_farm.$calendar.balance.nitrogen._index.tsx
📚 Learning: the `calculatedose` function in `@svenvw/fdm-calculator` is a synchronous function that includes bui...
Learnt from: SvenVw
PR: SvenVw/fdm#75
File: fdm-app/app/routes/farm.$b_id_farm.field.$b_id.fertilizer.tsx:68-71
Timestamp: 2025-02-14T09:56:37.606Z
Learning: The `calculateDose` function in `svenvw/fdm-calculator` is a synchronous function that includes built-in validation for negative application amounts and nutrient rates.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.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.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-app/.env.example
📚 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.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-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.$b_id_farm.$calendar.balance.nitrogen._index.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.$b_id_farm.$calendar.balance.nitrogen._index.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.$b_id_farm.$calendar.balance.nitrogen._index.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.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.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-sources.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-sources.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-sources.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-sources.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-sources.tsx
📚 Learning: mapgl implementations should use the shared `usemapconfig` hook for configuration and `getlayerstyle...
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-sources.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: 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: the farm layout system has been reorganized into separate components (`farmheader`, `contentlayout`,...
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
🧬 Code Graph Analysis (1)
fdm-app/app/components/blocks/atlas/atlas-sources.tsx (2)
fdm-app/app/components/blocks/atlas/atlas-functions.tsx (1)
generateFeatureClass(4-9)fdm-app/app/components/blocks/atlas/atlas-url.ts (1)
getAvailableFieldsUrl(3-25)
🔇 Additional comments (12)
fdm-app/app/types/public-env.d.ts (1)
5-5: LGTM – type surface updated correctly.fdm-app/app/types/config.d.ts (1)
5-6: Check existing config files for breakages.The new
datasets_urlis mandatory (string). AnyserverConfig.json/clientConfig.tschecked into other environments will now fail type-checking unless updated.
If backward compatibility is desirable, mark the field optional or supply a sensible default.fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx (2)
39-39: LGTM! Centralized configuration import added.The addition of
serverConfigimport supports the centralization of dataset URL configuration, replacing direct environment variable access.
83-89: LGTM! Improved configuration management.The change from direct environment variable access to
serverConfig.datasets_urlcentralizes configuration management and improves maintainability. This aligns well with the PR objective of supporting calendar-based dataset selection.fdm-app/.env.example (1)
22-24: LGTM! New environment variable supports calendar-based dataset selection.The addition of
PUBLIC_FDM_DATASETS_URLreplaces the previous static URL approach with a configurable base URL that supports dynamic calendar-based dataset construction. The documentation clearly indicates it's required.fdm-app/app/components/blocks/atlas/atlas-url.ts (1)
3-25: LGTM! Well-structured URL generation function.The function correctly implements calendar-based dataset URL construction with appropriate year clamping and version selection logic. This directly addresses the PR objective of showing available fields per corresponding year.
fdm-app/app/components/blocks/atlas/atlas-sources.tsx (4)
4-4: LGTM! Appropriate imports for new functionality.The JSX type import and getAvailableFieldsUrl function import support the component's updated API and functionality.
Also applies to: 7-7
109-116: LGTM! Interface updated to support calendar-based URL generation.The change from
urlprop tocalendarprop with corresponding interface update correctly implements the shift to dynamic URL generation based on calendar year.
120-120: LGTM! Dynamic URL generation implemented.The internal computation of
availableFieldsUrlusinggetAvailableFieldsUrl(calendar)correctly implements the calendar-based dataset selection as required by the PR objectives.
176-176: LGTM! Effect dependency correctly updated.The dependency array correctly includes
availableFieldsUrlinstead of the previousurlprop, ensuring the effect re-runs when the computed URL changes.fdm-app/app/routes/farm.create.$b_id_farm.$calendar.atlas.tsx (2)
85-85: LGTM! Calendar parameter extraction and usage implemented.The extraction of calendar parameter and inclusion in loader data correctly supports the calendar-based dataset selection functionality.
Also applies to: 103-103
203-203: LGTM! Component prop updated to use calendar.The change from passing a URL to passing the calendar parameter correctly aligns with the updated
FieldsSourceAvailablecomponent API.
BoraIneviNMI
left a comment
There was a problem hiding this comment.
This is a very important change to allow farmers select fields from the fdm public database for previous years. The implementation looks fine. I found a few issues though
- farm.$b_id_farm.$calendar.field.new.tsx doesn't have the necessary changes.
…nent for new field page
Thanks! Resolved in 6d5a9c4 |
BoraIneviNMI
left a comment
There was a problem hiding this comment.
OK now it looks good to me.
Summary by CodeRabbit
New Features
Chores
Closes #211