Description
Currently, on the farm balance pages, users see a list of fields in the right-hand card. This list only displays the field name and its area, which provides limited context. We need to enhance this list by displaying the main cultivation (crop) for that year as a badge next to the area. If a field has multiple cultivations (e.g., a main crop and a catch crop / 'vanggewas'), we should indicate this with a "+X" (e.g., "+1") note next to the badge. Clicking this indicator should open a modal showing all cultivations for that field along with their key details.
Current Behavior
- The right-hand card on farm balance pages shows a list of fields.
- Each list item only displays the field name and the area (e.g., in hectares).
- Users cannot see which crops are on the field for the selected year.
Expected Behavior
- Each field in the list should display a badge representing the main cultivation for the selected year.
- The main cultivation should be determined using the existing
getDefaultCultivation helper function.
- Clicking the main cultivation badge should open a Modal dialog with details about the cultivation.
- If a field has more than one cultivation in the selected year, a "+X" note (e.g., "+1") should be displayed next to the badge, which also triggers the modal when clicked.
- The modal should list all cultivations for that field in the given year (even if there is only one), including the following key details for each:
- Cultivation / Crop Name
- Start Date
- End Date
- Harvest Date(s)
Technical Details & Context
- Relevant Routes: This change applies to the balance pages, primarily located at:
fdm-app/app/routes/farm.$b_id_farm.$calendar.balance._index.tsx
fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsx
fdm-app/app/routes/farm.$b_id_farm.$calendar.balance.organic-matter._index.tsx
- Helper Function: Use
getDefaultCultivation from fdm-app/app/lib/cultivation-helpers.ts to identify the main crop to display in the badge.
- UI Components: Use the design system's
Badge component for the main crop and the Dialog / Modal component (from shadcn) for the expanded cultivation details.
Acceptance Criteria
Description
Currently, on the farm balance pages, users see a list of fields in the right-hand card. This list only displays the field name and its area, which provides limited context. We need to enhance this list by displaying the main cultivation (crop) for that year as a badge next to the area. If a field has multiple cultivations (e.g., a main crop and a catch crop / 'vanggewas'), we should indicate this with a "+X" (e.g., "+1") note next to the badge. Clicking this indicator should open a modal showing all cultivations for that field along with their key details.
Current Behavior
Expected Behavior
getDefaultCultivationhelper function.Technical Details & Context
fdm-app/app/routes/farm.$b_id_farm.$calendar.balance._index.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.nitrogen._index.tsxfdm-app/app/routes/farm.$b_id_farm.$calendar.balance.organic-matter._index.tsxgetDefaultCultivationfromfdm-app/app/lib/cultivation-helpers.tsto identify the main crop to display in the badge.Badgecomponent for the main crop and theDialog/Modalcomponent (fromshadcn) for the expanded cultivation details.Acceptance Criteria
getDefaultCultivationhelper.