Add comprehensive metrics display to fertilizer application page#306
Conversation
…ding an icon for the type of fertilizer and better usage of spacing and aligning
🦋 Changeset detectedLatest commit: 45c86cd 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 |
|
Warning Rate limit exceeded@SvenVw has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 29 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (4)
WalkthroughThis PR refactors the fertilizer applications page UI, introducing a new metrics dashboard component that displays norms, nitrogen balance, and nutrient advice data. It includes new calculator integration functions, updates the fertilizer applications list and card components, modifies nutrient advice card precision formatting, and adds related changesets for minor and patch version releases. Changes
Sequence DiagramsequenceDiagram
participant Route as Fertilizer Route
participant Loader as Loader
participant Calc as Calculator<br/>Integrations
participant FDM as FDM Tooling
participant UI as Metrics Card
participant User as User
User->>Route: Navigate to fertilizer page
Route->>Loader: Execute loader
Loader->>Calc: getNorms(fdm, principal_id, b_id)
Calc->>FDM: collectNormsInput + computeNorms
FDM-->>Calc: norms data
Calc-->>Loader: {value, filling}
Loader->>Calc: getNitrogenBalanceforField(...)
Calc->>FDM: collectInputForNitrogenBalance + compute
FDM-->>Calc: N balance data
Calc-->>Loader: NitrogenBalanceNumeric
Loader->>Calc: getNutrientAdviceForField(...)
Calc->>FDM: Fetch soil, cultivations + compute
FDM-->>Calc: nutrient advice
Calc-->>Loader: advice data
Loader-->>Route: {norms, nitrogenBalance,<br/>nutrientAdvice, ...}
Route->>UI: Render with metrics data
UI->>UI: Load with Suspense/Await
UI->>UI: Render skeleton states
UI-->>User: Display 3 sections:<br/>Norms, Balance, Advice
rect rgb(200, 220, 255)
Note over UI: Each section shows<br/>progress bar + values<br/>with color logic
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas requiring extra attention:
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## development #306 +/- ##
============================================
Coverage 93.31% 93.31%
============================================
Files 96 96
Lines 15325 15325
Branches 1557 1557
============================================
Hits 14301 14301
Misses 1022 1022
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:
|
Signed-off-by: Sven Verweij <37927107+SvenVw@users.noreply.github.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
gerardhros
left a comment
There was a problem hiding this comment.
nice. might be good to add later for a specific selection of fields or farm level.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
fdm-calculator/src/norms/nl/2025/value/input.ts (1)
54-54: Remove redundant type cast.The cast
as PrincipalIdis unnecessary sinceprincipal_idis already declared asPrincipalIdat line 27.Apply this diff:
- principal_id as PrincipalId, + principal_id,fdm-app/app/components/blocks/fertilizer-applications/metrics.tsx (2)
461-478: Use localtaskvariable consistently.The conditional label logic at lines 462-467 and 472-477 references
resolvedNitrogenBalance.balance.task, but a localtaskvariable is already calculated at lines 326-330. Using the local variable is clearer and avoids redundant property access.Apply this diff:
<TooltipTrigger asChild > <p className="text-xl font-bold whitespace-nowrap px-2"> - {resolvedNitrogenBalance - .balance - .task < - 0 + {task < 0 ? "Opgave" : "Ruimte"} </p> </TooltipTrigger> <TooltipContent> <p> - {resolvedNitrogenBalance - .balance - .task < - 0 + {task < 0 ? "Hoeveelheid totaal stikstof die verminderd moet worden om het doel te halen" : "Hoeveelheid totaal stikstof die nog over waarbij het doel gehaald kan worden"} </p> </TooltipContent>
721-747: Minor formatting inconsistency in skeleton components.Line 725 has inconsistent spacing (
text-right px-2with double space) compared to lines 732 and 740.Apply this diff for consistency:
<div className="grid grid-cols-[1fr_auto] items-center"> <p className="whitespace-nowrap px-2">Stikstof</p> - <span className="text-right px-2"> + <span className="text-right px-2"> {<Spinner className="h-3" />} kg N </span> </div>fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx (1)
119-131: Improve type safety for fertilizer parameter metadata.Lines 120, 126-128 use
anytype annotations for parameter metadata. Consider adding proper types or using type assertions to improve type safety.If
getFertilizerParametersDescription()returns a well-defined type, use it instead ofany:const applicationMethods = fertilizerParameterDescription.find( - (x: any) => x.parameter === "p_app_method_options", + (x) => x.parameter === "p_app_method_options", ) if (!applicationMethods) throw new Error("Parameter metadata missing") // Map fertilizers to options for the combobox const fertilizerOptions = fertilizers.map((fertilizer) => { const applicationMethodOptions = fertilizer.p_app_method_options - .map((opt: any) => { + .map((opt) => { const meta = applicationMethods.options.find( - (x: any) => x.value === opt, + (x) => x.value === opt, ) return meta ? { value: opt, label: meta.label } : undefined }) .filter(Boolean)fdm-app/app/components/blocks/fertilizer-applications/list.tsx (1)
131-143: Simplify delete handler invocation.The code wraps a single
p_app_idin an array at line 139-141, but thehandleDeletesignature at line 44 acceptsstring | string[]. This makes the wrapping unnecessary.Apply this diff to simplify:
onClick={() => { if ( application.p_app_ids ) { handleDelete( application.p_app_ids, ) } else { handleDelete( - [ - application.p_app_id, - ] + application.p_app_id ) } }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
fdm-app/app/components/ui/progress.tsxis excluded by!fdm-app/app/components/ui/**fdm-app/app/components/ui/spinner.tsxis excluded by!fdm-app/app/components/ui/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
.changeset/clear-phones-flash.md(1 hunks).changeset/common-ears-make.md(1 hunks).changeset/eight-lizards-listen.md(1 hunks).changeset/slow-ears-stand.md(1 hunks)fdm-app/app/components/blocks/fertilizer-applications/card.tsx(3 hunks)fdm-app/app/components/blocks/fertilizer-applications/cards.tsx(0 hunks)fdm-app/app/components/blocks/fertilizer-applications/list.tsx(1 hunks)fdm-app/app/components/blocks/fertilizer-applications/metrics.tsx(1 hunks)fdm-app/app/components/blocks/nutrient-advice/cards.tsx(3 hunks)fdm-app/app/integrations/calculator.ts(1 hunks)fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx(8 hunks)fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsx(2 hunks)fdm-app/package.json(1 hunks)fdm-calculator/src/norms/nl/2025/filling/input.ts(2 hunks)fdm-calculator/src/norms/nl/2025/value/input.ts(1 hunks)
💤 Files with no reviewable changes (1)
- fdm-app/app/components/blocks/fertilizer-applications/cards.tsx
🧰 Additional context used
🧠 Learnings (36)
📓 Common learnings
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 274
File: fdm-app/app/routes/farm.$b_id_farm._index.tsx:160-163
Timestamp: 2025-09-23T12:29:34.184Z
Learning: In the FDM application, the fertilizer application route intentionally uses `${calendar}/field/fertilizer` instead of the originally planned `/farm/{farmId}/add/fertilizer` structure. This design decision prioritizes starting from the field list view to provide better field selection workflow before applying fertilizer, rather than direct dashboard-to-action navigation.
📚 Learning: 2025-03-04T09:03:04.358Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 87
File: fdm-core/src/farm.ts:22-25
Timestamp: 2025-03-04T09:03:04.358Z
Learning: In the FDM codebase, functions that insert/create data (like `addFarm`) intentionally use `principal_id: string` instead of `PrincipalId` to enforce that only a single principal ID can be used for creation operations, while read operations use the more flexible `PrincipalId` type which supports both single IDs and arrays of IDs.
Applied to files:
fdm-calculator/src/norms/nl/2025/value/input.tsfdm-calculator/src/norms/nl/2025/filling/input.ts
📚 Learning: 2025-07-21T12:06:07.070Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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-calculator/src/norms/nl/2025/value/input.tsfdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-08-11T11:55:26.053Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 233
File: fdm-app/app/integrations/nmi.ts:54-0
Timestamp: 2025-08-11T11:55:26.053Z
Learning: The NMI API Estimates endpoint (`https://api.nmi-agro.nl/estimates`) always returns the fields `b_gwl_ghg`, `b_gwl_glg`, and `cultivations` according to its specification. These fields should be kept as required (not optional) in the TypeScript return type and Zod validation schema in `fdm-app/app/integrations/nmi.ts`.
Applied to files:
fdm-calculator/src/norms/nl/2025/value/input.tsfdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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-calculator/src/norms/nl/2025/value/input.tsfdm-calculator/src/norms/nl/2025/filling/input.ts
📚 Learning: 2025-09-23T12:29:34.184Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 274
File: fdm-app/app/routes/farm.$b_id_farm._index.tsx:160-163
Timestamp: 2025-09-23T12:29:34.184Z
Learning: In the FDM application, the fertilizer application route intentionally uses `${calendar}/field/fertilizer` instead of the originally planned `/farm/{farmId}/add/fertilizer` structure. This design decision prioritizes starting from the field list view to provide better field selection workflow before applying fertilizer, rather than direct dashboard-to-action navigation.
Applied to files:
.changeset/clear-phones-flash.md.changeset/slow-ears-stand.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/components/blocks/fertilizer-applications/card.tsxfdm-app/app/components/blocks/fertilizer-applications/list.tsx
📚 Learning: 2025-09-26T08:34:50.413Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 279
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.norms.tsx:277-283
Timestamp: 2025-09-26T08:34:50.413Z
Learning: In the fdm project, fdm-core and fdm-app are updated together as part of a monorepo structure, which eliminates legacy data concerns when new fields like b_isproductive are introduced. Both packages are synchronized, so there's no need for defensive coding against undefined values for newly introduced database fields.
Applied to files:
fdm-app/package.jsonfdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2024-12-11T12:09:35.540Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/package.json
📚 Learning: 2024-11-25T12:42:32.783Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/package.json
📚 Learning: 2025-03-04T10:56:35.540Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 88
File: fdm-calculator/src/doses/calculate-dose.ts:18-18
Timestamp: 2025-03-04T10:56:35.540Z
Learning: In the FDM calculator, fertilizer nutrient rates (p_n_rt, p_p_rt, p_k_rt) are measured in g/kg, and are converted to fractions by dividing by 10 during dose calculations.
Applied to files:
.changeset/eight-lizards-listen.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-02-14T09:56:37.606Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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:
.changeset/eight-lizards-listen.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/integrations/calculator.tsfdm-app/app/components/blocks/fertilizer-applications/card.tsx
📚 Learning: 2025-09-23T12:27:07.391Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 274
File: fdm-app/app/routes/farm.$b_id_farm._index.tsx:151-204
Timestamp: 2025-09-23T12:27:07.391Z
Learning: In the FDM application, field overview functionality is implemented as a dedicated page accessible via `farm/{farmId}/{calendar}/field` rather than as a direct listing on the dashboard. The dashboard includes a "Perceelsoverzicht" quick action card that provides navigation to this comprehensive field management interface.
Applied to files:
.changeset/slow-ears-stand.mdfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsx
📚 Learning: 2025-09-23T12:37:58.711Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 274
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field._index.tsx:113-148
Timestamp: 2025-09-23T12:37:58.711Z
Learning: In the FDM application, the current field data fetching implementation using Promise.all with individual API calls (getCultivations, getFertilizerApplications, getCurrentSoilData) performs acceptably even with farms containing 90+ fields. No performance issues have been observed in practice with this approach.
Applied to files:
.changeset/slow-ears-stand.mdfdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-08-13T10:33:05.313Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 0
File: :0-0
Timestamp: 2025-08-13T10:33:05.313Z
Learning: In the fdm project, fdm-calculator integration for new features like b_lu_variety is handled in separate updates from the core data model changes. When fdm-core functions are updated to support new fields, fdm-calculator can consume these enhanced APIs without requiring changes in the same PR that introduces the core functionality.
Applied to files:
fdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-09-24T14:02:48.574Z
Learnt from: BoraIneviNMI
Repo: SvenVw/fdm PR: 272
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer.manage.new.$p_id.tsx:85-101
Timestamp: 2025-09-24T14:02:48.574Z
Learning: Both getFertilizer and getFertilizers functions in svenvw/fdm-core perform authorization checks using the user's principal_id to verify farm access before returning fertilizer data.
Applied to files:
fdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-02-13T08:35:59.306Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsx
📚 Learning: 2025-09-23T10:02:32.123Z
Learnt from: BoraIneviNMI
Repo: SvenVw/fdm PR: 272
File: fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue.manage.$p_id.tsx:151-164
Timestamp: 2025-09-23T10:02:32.123Z
Learning: The getFertilizer function from svenvw/fdm-core throws an exception if the fertilizer doesn't exist, rather than returning null or undefined.
Applied to files:
fdm-calculator/src/norms/nl/2025/filling/input.tsfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2025-04-18T13:49:17.029Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/nutrient-advice/cards.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/fertilizer-applications/metrics.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/components/blocks/fertilizer-applications/card.tsxfdm-app/app/components/blocks/fertilizer-applications/list.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.$b_id.fertilizer._index.tsxfdm-app/app/components/blocks/fertilizer-applications/list.tsx
📚 Learning: 2025-08-11T12:24:32.200Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 233
File: fdm-app/app/components/blocks/atlas-fields/cultivation-history.tsx:53-53
Timestamp: 2025-08-11T12:24:32.200Z
Learning: In `fdm-app/app/components/blocks/atlas-fields/cultivation-history.tsx`, the NMI API for cultivations guarantees that each year will be unique in the cultivation history data, so using `cultivation.year` as a React list key is safe and won't cause duplicate key warnings.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-09-24T14:02:48.574Z
Learnt from: BoraIneviNMI
Repo: SvenVw/fdm PR: 272
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer.manage.new.$p_id.tsx:85-101
Timestamp: 2025-09-24T14:02:48.574Z
Learning: The getFertilizer function in svenvw/fdm-core does not perform authorization checks, unlike getFertilizers which includes a checkPermission call to verify farm access. This means getFertilizer(fdm, p_id) can potentially return fertilizer details for any fertilizer ID without validating user permissions.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsxfdm-app/app/integrations/calculator.ts
📚 Learning: 2024-12-16T10:56:07.561Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-04-29T11:28:44.181Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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 replaced with `data()` for creating responses in loaders and actions.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-04-29T11:28:44.181Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-05-09T14:41:43.484Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 138
File: fdm-app/app/components/custom/fertilizer-applications/form.tsx:6-6
Timestamp: 2025-05-09T14:41:43.484Z
Learning: The project uses React Router v7 which exports a Form component directly from the "react-router" package, not from "remix-run/react".
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-07-24T08:29:44.044Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 198
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen.$b_id.tsx:146-148
Timestamp: 2025-07-24T08:29:44.044Z
Learning: In React Router v7, the defer() function has been removed. Instead, loaders can return promises directly in the response object, and components use Suspense and Await to handle them without needing defer().
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-05-09T14:41:43.484Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 138
File: fdm-app/app/components/custom/fertilizer-applications/form.tsx:6-6
Timestamp: 2025-05-09T14:41:43.484Z
Learning: The project uses React Router v7 which exports a Form component directly from the "react-router" package, making importing from "remix-run/react" unnecessary.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-07-24T08:29:44.044Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 198
File: fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen.$b_id.tsx:146-148
Timestamp: 2025-07-24T08:29:44.044Z
Learning: React Router v7 supports Suspense patterns by returning promises directly from loaders. The pattern is: return { data: somePromise } from loader, then use <Suspense><Await resolve={loaderData.data}>{resolvedData => ...}</Await></Suspense> in components.
Applied to files:
fdm-app/app/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-05-09T14:53:44.578Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsxfdm-app/app/components/blocks/fertilizer-applications/card.tsx
📚 Learning: 2025-01-14T16:06:24.294Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/routes/farm.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-01-31T15:05:14.310Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.$b_id.fertilizer._index.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.$b_id.fertilizer._index.tsx
📚 Learning: 2025-01-09T16:03:37.764Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.$b_id_farm.$calendar.field.$b_id.fertilizer._index.tsx
📚 Learning: 2025-04-04T14:27:39.518Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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.fertilizers.$b_lu_catalogue._index.tsx
📚 Learning: 2025-05-09T14:58:10.465Z
Learnt from: SvenVw
Repo: SvenVw/fdm PR: 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/fertilizer-applications/card.tsx
🔇 Additional comments (7)
fdm-calculator/src/norms/nl/2025/value/input.ts (1)
27-27: LGTM: Type alignment with PrincipalId.The parameter type update from
stringtoPrincipalIdcorrectly aligns with the core type system and matches the related change infilling/input.ts.fdm-app/package.json (1)
25-25: LGTM: Progress UI dependency added.The
@radix-ui/react-progressdependency supports the new metrics visualization features introduced in this PR.fdm-calculator/src/norms/nl/2025/filling/input.ts (2)
28-28: LGTM: Type alignment with PrincipalId.The parameter type update from
stringtoPrincipalIdcorrectly aligns with the core type system and matches the related change invalue/input.ts.
36-36: Verify downstream date range handling in database queries—this requires testing with actual data.The
endOfYearprecision change from00:00:00.000to23:59:59.999on December 31st is intentional and correctly documented. Thetimeframe2025object is passed directly to external@svenvw/fdm-corefunctions (getCultivationsandgetFertilizerApplications), which handle the actual date filtering.Since these functions are from an external package, their internal comparison logic (e.g.,
<=vs<) cannot be verified within this repository. The change is localized and aligns with the documented intent, but its impact on records retrieved from database queries depends on how the external package implements the timeframe filtering.Verify that records on December 31st are correctly included/excluded as intended when calling the norms calculator with actual field and fertilizer application data.
fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fertilizers.$b_lu_catalogue._index.tsx (2)
167-167: LGTM: Fertilizers data exposed in loader.The fertilizers data is correctly added to the loader return, enabling the component to access fertilizer metadata.
183-183: LGTM: Fertilizers prop passed to component.The fertilizers array is correctly passed to
FertilizerApplicationCard, supporting the enhanced metrics display functionality.fdm-app/app/components/blocks/nutrient-advice/cards.tsx (1)
61-61: Verify percentage default for zero advice.When
adviceis 0 or negative, the percentage defaults to 100. This might be misleading in the UI, as it suggests the target is fully met when there's actually no target defined.Please verify this is the intended behavior. If
advice === 0represents "no limit" or "not applicable," consider:
- Hiding the progress bar entirely
- Using a distinct visual indicator
- Showing "N/A" instead of a percentage
Also, consider the special case handling at lines 104-105 where
advice === 0andsymbol === "EOC"gets a green bar, which suggests this may be intentional for specific nutrients.
Summary by CodeRabbit
New Features
Improvements
Closes #291